Amazon Rekognition

2021/05/19 - Amazon Rekognition - 2 updated api methods

Changes  Amazon Rekognition Custom Labels adds support for customer managed encryption, using AWS Key Management Service, of image files copied into the service and files written back to the customer.

CreateProjectVersion (updated) Link ¶
Changes (request)
{'KmsKeyId': 'string'}

Creates a new version of a model and begins training. Models are managed as part of an Amazon Rekognition Custom Labels project. You can specify one training dataset and one testing dataset. The response from CreateProjectVersion is an Amazon Resource Name (ARN) for the version of the model.

Training takes a while to complete. You can get the current status by calling DescribeProjectVersions.

Once training has successfully completed, call DescribeProjectVersions to get the training results and evaluate the model.

After evaluating the model, you start the model by calling StartProjectVersion.

This operation requires permissions to perform the rekognition:CreateProjectVersion action.

See also: AWS API Documentation

Request Syntax

client.create_project_version(
    ProjectArn='string',
    VersionName='string',
    OutputConfig={
        'S3Bucket': 'string',
        'S3KeyPrefix': 'string'
    },
    TrainingData={
        'Assets': [
            {
                'GroundTruthManifest': {
                    'S3Object': {
                        'Bucket': 'string',
                        'Name': 'string',
                        'Version': 'string'
                    }
                }
            },
        ]
    },
    TestingData={
        'Assets': [
            {
                'GroundTruthManifest': {
                    'S3Object': {
                        'Bucket': 'string',
                        'Name': 'string',
                        'Version': 'string'
                    }
                }
            },
        ],
        'AutoCreate': True|False
    },
    Tags={
        'string': 'string'
    },
    KmsKeyId='string'
)
type ProjectArn:

string

param ProjectArn:

[REQUIRED]

The ARN of the Amazon Rekognition Custom Labels project that manages the model that you want to train.

type VersionName:

string

param VersionName:

[REQUIRED]

A name for the version of the model. This value must be unique.

type OutputConfig:

dict

param OutputConfig:

[REQUIRED]

The Amazon S3 location to store the results of training.

  • S3Bucket (string) --

    The S3 bucket where training output is placed.

  • S3KeyPrefix (string) --

    The prefix applied to the training output files.

type TrainingData:

dict

param TrainingData:

[REQUIRED]

The dataset to use for training.

  • Assets (list) --

    A Sagemaker GroundTruth manifest file that contains the training images (assets).

    • (dict) --

      Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

      • GroundTruthManifest (dict) --

        The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

        • S3Object (dict) --

          Provides the S3 bucket name and object name.

          The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

          For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

          • Bucket (string) --

            Name of the S3 bucket.

          • Name (string) --

            S3 object key name.

          • Version (string) --

            If the bucket is versioning enabled, you can specify the object version.

type TestingData:

dict

param TestingData:

[REQUIRED]

The dataset to use for testing.

  • Assets (list) --

    The assets used for testing.

    • (dict) --

      Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

      • GroundTruthManifest (dict) --

        The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

        • S3Object (dict) --

          Provides the S3 bucket name and object name.

          The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

          For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

          • Bucket (string) --

            Name of the S3 bucket.

          • Name (string) --

            S3 object key name.

          • Version (string) --

            If the bucket is versioning enabled, you can specify the object version.

  • AutoCreate (boolean) --

    If specified, Amazon Rekognition Custom Labels creates a testing dataset with an 80/20 split of the training dataset.

type Tags:

dict

param Tags:

A set of tags (key-value pairs) that you want to attach to the model.

  • (string) --

    • (string) --

type KmsKeyId:

string

param KmsKeyId:

The identifier for your AWS Key Management Service (AWS KMS) customer master key (CMK). You can supply the Amazon Resource Name (ARN) of your CMK, the ID of your CMK, or an alias for your CMK. The key is used to encrypt training and test images copied into the service for model training. Your source images are unaffected. The key is also used to encrypt training results and manifest files written to the output Amazon S3 bucket ( OutputConfig).

If you don't specify a value for KmsKeyId, images copied into the service are encrypted using a key that AWS owns and manages.

rtype:

dict

returns:

Response Syntax

{
    'ProjectVersionArn': 'string'
}

Response Structure

  • (dict) --

    • ProjectVersionArn (string) --

      The ARN of the model version that was created. Use DescribeProjectVersion to get the current status of the training operation.

DescribeProjectVersions (updated) Link ¶
Changes (response)
{'ProjectVersionDescriptions': {'KmsKeyId': 'string'}}

Lists and describes the models in an Amazon Rekognition Custom Labels project. You can specify up to 10 model versions in ProjectVersionArns. If you don't specify a value, descriptions for all models are returned.

This operation requires permissions to perform the rekognition:DescribeProjectVersions action.

See also: AWS API Documentation

Request Syntax

client.describe_project_versions(
    ProjectArn='string',
    VersionNames=[
        'string',
    ],
    NextToken='string',
    MaxResults=123
)
type ProjectArn:

string

param ProjectArn:

[REQUIRED]

The Amazon Resource Name (ARN) of the project that contains the models you want to describe.

type VersionNames:

list

param VersionNames:

A list of model version names that you want to describe. You can add up to 10 model version names to the list. If you don't specify a value, all model descriptions are returned. A version name is part of a model (ProjectVersion) ARN. For example, my-model.2020-01-21T09.10.15 is the version name in the following ARN. arn:aws:rekognition:us-east-1:123456789012:project/getting-started/version/my-model.2020-01-21T09.10.15/1234567890123.

  • (string) --

type NextToken:

string

param NextToken:

If the previous response was incomplete (because there is more results to retrieve), Amazon Rekognition Custom Labels returns a pagination token in the response. You can use this pagination token to retrieve the next set of results.

type MaxResults:

integer

param MaxResults:

The maximum number of results to return per paginated call. The largest value you can specify is 100. If you specify a value greater than 100, a ValidationException error occurs. The default value is 100.

rtype:

dict

returns:

Response Syntax

{
    'ProjectVersionDescriptions': [
        {
            'ProjectVersionArn': 'string',
            'CreationTimestamp': datetime(2015, 1, 1),
            'MinInferenceUnits': 123,
            'Status': 'TRAINING_IN_PROGRESS'|'TRAINING_COMPLETED'|'TRAINING_FAILED'|'STARTING'|'RUNNING'|'FAILED'|'STOPPING'|'STOPPED'|'DELETING',
            'StatusMessage': 'string',
            'BillableTrainingTimeInSeconds': 123,
            'TrainingEndTimestamp': datetime(2015, 1, 1),
            'OutputConfig': {
                'S3Bucket': 'string',
                'S3KeyPrefix': 'string'
            },
            'TrainingDataResult': {
                'Input': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ]
                },
                'Output': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ]
                },
                'Validation': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ]
                }
            },
            'TestingDataResult': {
                'Input': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ],
                    'AutoCreate': True|False
                },
                'Output': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ],
                    'AutoCreate': True|False
                },
                'Validation': {
                    'Assets': [
                        {
                            'GroundTruthManifest': {
                                'S3Object': {
                                    'Bucket': 'string',
                                    'Name': 'string',
                                    'Version': 'string'
                                }
                            }
                        },
                    ]
                }
            },
            'EvaluationResult': {
                'F1Score': ...,
                'Summary': {
                    'S3Object': {
                        'Bucket': 'string',
                        'Name': 'string',
                        'Version': 'string'
                    }
                }
            },
            'ManifestSummary': {
                'S3Object': {
                    'Bucket': 'string',
                    'Name': 'string',
                    'Version': 'string'
                }
            },
            'KmsKeyId': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ProjectVersionDescriptions (list) --

      A list of model descriptions. The list is sorted by the creation date and time of the model versions, latest to earliest.

      • (dict) --

        The description of a version of a model.

        • ProjectVersionArn (string) --

          The Amazon Resource Name (ARN) of the model version.

        • CreationTimestamp (datetime) --

          The Unix datetime for the date and time that training started.

        • MinInferenceUnits (integer) --

          The minimum number of inference units used by the model. For more information, see StartProjectVersion.

        • Status (string) --

          The current status of the model version.

        • StatusMessage (string) --

          A descriptive message for an error or warning that occurred.

        • BillableTrainingTimeInSeconds (integer) --

          The duration, in seconds, that the model version has been billed for training. This value is only returned if the model version has been successfully trained.

        • TrainingEndTimestamp (datetime) --

          The Unix date and time that training of the model ended.

        • OutputConfig (dict) --

          The location where training results are saved.

          • S3Bucket (string) --

            The S3 bucket where training output is placed.

          • S3KeyPrefix (string) --

            The prefix applied to the training output files.

        • TrainingDataResult (dict) --

          Contains information about the training results.

          • Input (dict) --

            The training assets that you supplied for training.

            • Assets (list) --

              A Sagemaker GroundTruth manifest file that contains the training images (assets).

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

          • Output (dict) --

            The images (assets) that were actually trained by Amazon Rekognition Custom Labels.

            • Assets (list) --

              A Sagemaker GroundTruth manifest file that contains the training images (assets).

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

          • Validation (dict) --

            The location of the data validation manifest. The data validation manifest is created for the training dataset during model training.

            • Assets (list) --

              The assets that comprise the validation data.

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

        • TestingDataResult (dict) --

          Contains information about the testing results.

          • Input (dict) --

            The testing dataset that was supplied for training.

            • Assets (list) --

              The assets used for testing.

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

            • AutoCreate (boolean) --

              If specified, Amazon Rekognition Custom Labels creates a testing dataset with an 80/20 split of the training dataset.

          • Output (dict) --

            The subset of the dataset that was actually tested. Some images (assets) might not be tested due to file formatting and other issues.

            • Assets (list) --

              The assets used for testing.

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

            • AutoCreate (boolean) --

              If specified, Amazon Rekognition Custom Labels creates a testing dataset with an 80/20 split of the training dataset.

          • Validation (dict) --

            The location of the data validation manifest. The data validation manifest is created for the test dataset during model training.

            • Assets (list) --

              The assets that comprise the validation data.

              • (dict) --

                Assets are the images that you use to train and evaluate a model version. Assets can also contain validation information that you use to debug a failed model training.

                • GroundTruthManifest (dict) --

                  The S3 bucket that contains an Amazon Sagemaker Ground Truth format manifest file.

                  • S3Object (dict) --

                    Provides the S3 bucket name and object name.

                    The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

                    For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

                    • Bucket (string) --

                      Name of the S3 bucket.

                    • Name (string) --

                      S3 object key name.

                    • Version (string) --

                      If the bucket is versioning enabled, you can specify the object version.

        • EvaluationResult (dict) --

          The training results. EvaluationResult is only returned if training is successful.

          • F1Score (float) --

            The F1 score for the evaluation of all labels. The F1 score metric evaluates the overall precision and recall performance of the model as a single value. A higher value indicates better precision and recall performance. A lower score indicates that precision, recall, or both are performing poorly.

          • Summary (dict) --

            The S3 bucket that contains the training summary.

            • S3Object (dict) --

              Provides the S3 bucket name and object name.

              The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

              For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

              • Bucket (string) --

                Name of the S3 bucket.

              • Name (string) --

                S3 object key name.

              • Version (string) --

                If the bucket is versioning enabled, you can specify the object version.

        • ManifestSummary (dict) --

          The location of the summary manifest. The summary manifest provides aggregate data validation results for the training and test datasets.

          • S3Object (dict) --

            Provides the S3 bucket name and object name.

            The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

            For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide.

            • Bucket (string) --

              Name of the S3 bucket.

            • Name (string) --

              S3 object key name.

            • Version (string) --

              If the bucket is versioning enabled, you can specify the object version.

        • KmsKeyId (string) --

          The identifer for the AWS Key Management Service (AWS KMS) customer master key that was used to encrypt the model during training.

    • NextToken (string) --

      If the previous response was incomplete (because there is more results to retrieve), Amazon Rekognition Custom Labels returns a pagination token in the response. You can use this pagination token to retrieve the next set of results.