TrainValSplits widget in Supervisely is a tool that helps with the creation of training and validation datasets. The widget allows for easy splitting of the original dataset into training and validation sets based on customizable parameters such as percentage split or based on datasets or specific tag. TrainValSplits helps improve the performance of machine learning models by ensuring that they are trained on diverse and representative data.
Function signature
Copy TrainValSplits (
project_id = None ,
project_fs = None ,
random_splits = True ,
tags_splits = True ,
datasets_splits = True ,
widget_id = None ,
collections_splits = False ,
) Parameters
Type
Description
Path to input Project on local host
Shuffle data and split with defined probability
Images should have assigned train or val tag
Select one or several datasets for every split
If True, allows to split data into train and validation sets based on selected collections within the project.
Determine input Project ID.
type: int
default value: None
Determine path to input Project on local host.
type: str
default value: None
Shuffle data and split with defined probability.
type: bool
default value: true
Images should have assigned train or val tag.
type: bool
default value: true
datasets_splits
Select one or several datasets for every split.
type: bool
default value: true
ID of the widget.
type: str
default value: None
collections_splits
Allows to split data into train and validation sets based on the provided collections.
type: bool
default value: False
Methods and attributes
Attributes and Methods
Description
Return result train/val split.
set_project_id_for_collections()
Sets the project ID and updates available collections for train and validation splits.
get_train_collections_ids()
Returns a list of collection IDs selected for the training split.
get_val_collections_ids()
Returns a list of collection IDs selected for the validation split.
Sets the collections (by their IDs) to be used for the training and validation splits when using the "collections" split method.
set_collections_splits_by_ids()
Set for the specified split (train or val) sets the provided collection IDs.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/controls/006_train_val_splits/src/main.pyarrow-up-right
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare project_id, download project and create project_fs
Initialize Button and Text widget we will use
Create app layout
Prepare a layout for app using Card widget with the content parameter and place widget that we've just created in the Container widget.
Create app using layout
Create an app object with layout parameter.
Last updated 5 months ago