createLabelingJob method

Future<CreateLabelingJobResponse> createLabelingJob({
  1. required HumanTaskConfig humanTaskConfig,
  2. required LabelingJobInputConfig inputConfig,
  3. required String labelAttributeName,
  4. required String labelingJobName,
  5. required LabelingJobOutputConfig outputConfig,
  6. required String roleArn,
  7. String? labelCategoryConfigS3Uri,
  8. LabelingJobAlgorithmsConfig? labelingJobAlgorithmsConfig,
  9. LabelingJobStoppingConditions? stoppingConditions,
  10. List<Tag>? tags,
})

Creates a job that uses workers to label the data objects in your input dataset. You can use the labeled data to train machine learning models.

You can select your workforce from one of three providers:

  • A private workforce that you create. It can include employees, contractors, and outside experts. Use a private workforce when want the data to stay within your organization or when a specific set of skills is required.
  • One or more vendors that you select from the AWS Marketplace. Vendors provide expertise in specific areas.
  • The Amazon Mechanical Turk workforce. This is the largest workforce, but it should only be used for public data or data that has been stripped of any personally identifiable information.
You can also use automated data labeling to reduce the number of data objects that need to be labeled by a human. Automated data labeling uses active learning to determine if a data object can be labeled by machine or if it needs to be sent to a human worker. For more information, see Using Automated Data Labeling.

The data objects to be labeled are contained in an Amazon S3 bucket. You create a manifest file that describes the location of each object. For more information, see Using Input and Output Data.

The output can be used as the manifest file for another labeling job or as training data for your machine learning models.

May throw ResourceInUse. May throw ResourceLimitExceeded.

Parameter humanTaskConfig : Configures the labeling task and how it is presented to workers; including, but not limited to price, keywords, and batch size (task count).

Parameter inputConfig : Input data for the labeling job, such as the Amazon S3 location of the data objects and the location of the manifest file that describes the data objects.

Parameter labelAttributeName : The attribute name to use for the label in the output manifest file. This is the key for the key/value pair formed with the label that a worker assigns to the object. The name can't end with "-metadata". If you are running a semantic segmentation labeling job, the attribute name must end with "-ref". If you are running any other kind of labeling job, the attribute name must not end with "-ref".

Parameter labelingJobName : The name of the labeling job. This name is used to identify the job in a list of labeling jobs.

Parameter outputConfig : The location of the output data and the AWS Key Management Service key ID for the key used to encrypt the output data, if any.

Parameter roleArn : The Amazon Resource Number (ARN) that Amazon SageMaker assumes to perform tasks on your behalf during data labeling. You must grant this role the necessary permissions so that Amazon SageMaker can successfully complete data labeling.

Parameter labelCategoryConfigS3Uri : The S3 URI of the file that defines the categories used to label the data objects.

For 3D point cloud task types, see Create a Labeling Category Configuration File for 3D Point Cloud Labeling Jobs.

For all other built-in task types and custom tasks, your label category configuration file must be a JSON file in the following format. Identify the labels you want to use by replacing label_1, label_2,...,label_n with your label categories.

{

"document-version": "2018-11-28"

"labels": [

{

"label": "label_1"

},

{

"label": "label_2"

},

...

{

"label": "label_n"

}

]

}

Parameter labelingJobAlgorithmsConfig : Configures the information required to perform automated data labeling.

Parameter stoppingConditions : A set of conditions for stopping the labeling job. If any of the conditions are met, the job is automatically stopped. You can use these conditions to control the cost of data labeling.

Parameter tags : An array of key/value pairs. For more information, see Using Cost Allocation Tags in the AWS Billing and Cost Management User Guide.

Implementation

Future<CreateLabelingJobResponse> createLabelingJob({
  required HumanTaskConfig humanTaskConfig,
  required LabelingJobInputConfig inputConfig,
  required String labelAttributeName,
  required String labelingJobName,
  required LabelingJobOutputConfig outputConfig,
  required String roleArn,
  String? labelCategoryConfigS3Uri,
  LabelingJobAlgorithmsConfig? labelingJobAlgorithmsConfig,
  LabelingJobStoppingConditions? stoppingConditions,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(humanTaskConfig, 'humanTaskConfig');
  ArgumentError.checkNotNull(inputConfig, 'inputConfig');
  ArgumentError.checkNotNull(labelAttributeName, 'labelAttributeName');
  _s.validateStringLength(
    'labelAttributeName',
    labelAttributeName,
    1,
    127,
    isRequired: true,
  );
  ArgumentError.checkNotNull(labelingJobName, 'labelingJobName');
  _s.validateStringLength(
    'labelingJobName',
    labelingJobName,
    1,
    63,
    isRequired: true,
  );
  ArgumentError.checkNotNull(outputConfig, 'outputConfig');
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    20,
    2048,
    isRequired: true,
  );
  _s.validateStringLength(
    'labelCategoryConfigS3Uri',
    labelCategoryConfigS3Uri,
    0,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.CreateLabelingJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'HumanTaskConfig': humanTaskConfig,
      'InputConfig': inputConfig,
      'LabelAttributeName': labelAttributeName,
      'LabelingJobName': labelingJobName,
      'OutputConfig': outputConfig,
      'RoleArn': roleArn,
      if (labelCategoryConfigS3Uri != null)
        'LabelCategoryConfigS3Uri': labelCategoryConfigS3Uri,
      if (labelingJobAlgorithmsConfig != null)
        'LabelingJobAlgorithmsConfig': labelingJobAlgorithmsConfig,
      if (stoppingConditions != null)
        'StoppingConditions': stoppingConditions,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateLabelingJobResponse.fromJson(jsonResponse.body);
}