Examples
There are two scenarios:
- Creating a dataset using unlabeled data
- Creating a dataset using labeled data with labels imported
Creating a Dataset Using Unlabeled Data
Data preparation: Store unlabeled data in an OBS folder.
from modelarts import workflow as wf # Use CreateDatasetStep to create a dataset of the new version using OBS data. # Define parameters of the dataset output path. dataset_output_path = wf.Placeholder(name="dataset_output_path", placeholder_type=wf.PlaceholderType.STR, placeholder_format="obs") # Define the dataset name. dataset_name = wf.Placeholder(name="dataset_name", placeholder_type=wf.PlaceholderType.STR) create_dataset = wf.steps.CreateDatasetStep( name="create_dataset", # Name of a dataset creation phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset creation", # Title, which defaults to the value of name inputs=wf.steps.CreateDatasetInput(name="input_name", data=wf.data.OBSPlaceholder(name="obs_placeholder_name", object_type="directory")),# CreateDatasetStep inputs, configured when the workflow is running; the data field can also be represented by the wf.data.OBSPath(obs_path="fake_obs_path") object. outputs=wf.steps.CreateDatasetOutput(name="output_name", config=wf.data.OBSOutputConfig(obs_path=dataset_output_path)),# CreateDatasetStep outputs properties=wf.steps.DatasetProperties( dataset_name=dataset_name, # If the dataset name does not exist, a dataset will be created using this name. If the dataset name exists, the corresponding dataset will be used. data_type=wf.data.DataTypeEnum.IMAGE, # Data type of the dataset, for example, image ) ) # Ensure that the dataset name is not used by others under the account. Otherwise, the dataset created by others will be used in the subsequent phases. workflow = wf.Workflow( name="create-dataset-demo", desc="this is a demo workflow", steps=[create_dataset] )
Creating a Dataset Using Labeled Data with Labels Imported
Data preparation: Store labeled data in an OBS folder.
For details about specifications for importing labeled data from an OBS directory, see Specifications for Importing Data from an OBS Directory.
from modelarts import workflow as wf # Use CreateDatasetStep to create a dataset of the new version using OBS data. # Define parameters of the dataset output path. dataset_output_path = wf.Placeholder(name="dataset_placeholder_name", placeholder_type=wf.PlaceholderType.STR, placeholder_format="obs") # Define the dataset name. dataset_name = wf.Placeholder(name="dataset_placeholder_name", placeholder_type=wf.PlaceholderType.STR) create_dataset = wf.steps.CreateDatasetStep( name="create_dataset", # Name of a dataset creation phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset creation", # Title, which defaults to the value of name inputs=wf.steps.CreateDatasetInput(name="input_name", data=wf.data.OBSPlaceholder(name="obs_placeholder_name", object_type="directory")),# CreateDatasetStep inputs, configured when the workflow is running; the data field can also be represented by the wf.data.OBSPath(obs_path="fake_obs_path") object. outputs=wf.steps.CreateDatasetOutput(name="output_name", config=wf.data.OBSOutputConfig(obs_path=dataset_output_path)),# CreateDatasetStep outputs properties=wf.steps.DatasetProperties( dataset_name=dataset_name, # If the dataset name does not exist, a dataset will be created using this name. If the dataset name exists, the corresponding dataset will be used. data_type=wf.data.DataTypeEnum.IMAGE, # Data type of the dataset, for example, image import_config=wf.steps.ImportConfig( annotation_format_config=[ wf.steps.AnnotationFormatConfig( format_name=wf.steps.AnnotationFormatEnum.MA_IMAGE_CLASSIFICATION_V1, # Labeling format of labeled data scene=wf.data.LabelTaskTypeEnum.IMAGE_CLASSIFICATION # Labeling scene ] ) ) ) # Ensure that the dataset name is not used by others under the account. Otherwise, the dataset created by others will be used in the subsequent phases. workflow = wf.Workflow( name="create-dataset-demo", desc="this is a demo workflow", steps=[create_dataset] )
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot