Amazon Rekognition

2023/10/12 - Amazon Rekognition - 8 updated api methods

Changes  Amazon Rekognition introduces support for Custom Moderation. This allows the enhancement of accuracy for detect moderation labels operations by creating custom adapters tuned on customer data.

CreateProject (updated) Link ¶
Changes (request)
{'AutoUpdate': 'ENABLED | DISABLED',
 'Feature': 'CONTENT_MODERATION | CUSTOM_LABELS'}

Creates a new Amazon Rekognition project. A project is a group of resources (datasets, model versions) that you use to create and manage a Amazon Rekognition Custom Labels Model or custom adapter. You can specify a feature to create the project with, if no feature is specified then Custom Labels is used by default. For adapters, you can also choose whether or not to have the project auto update by using the AutoUpdate argument. This operation requires permissions to perform the rekognition:CreateProject action.

See also: AWS API Documentation

Request Syntax

client.create_project(
    ProjectName='string',
    Feature='CONTENT_MODERATION'|'CUSTOM_LABELS',
    AutoUpdate='ENABLED'|'DISABLED'
)
type ProjectName

string

param ProjectName

[REQUIRED]

The name of the project to create.

type Feature

string

param Feature

Specifies feature that is being customized. If no value is provided CUSTOM_LABELS is used as a default.

type AutoUpdate

string

param AutoUpdate

Specifies whether automatic retraining should be attempted for the versions of the project. Automatic retraining is done as a best effort. Required argument for Content Moderation. Applicable only to adapters.

rtype

dict

returns

Response Syntax

{
    'ProjectArn': 'string'
}

Response Structure

  • (dict) --

    • ProjectArn (string) --

      The Amazon Resource Name (ARN) of the new project. You can use the ARN to configure IAM access to the project.

CreateProjectVersion (updated) Link ¶
Changes (request)
{'FeatureConfig': {'ContentModeration': {'ConfidenceThreshold': 'float'}},
 'VersionDescription': 'string'}

Creates a new version of Amazon Rekognition project (like a Custom Labels model or a custom adapter) and begins training. Models and adapters are managed as part of a Rekognition project. The response from CreateProjectVersion is an Amazon Resource Name (ARN) for the project version.

The FeatureConfig operation argument allows you to configure specific model or adapter settings. You can provide a description to the project version by using the VersionDescription argment. Training can take a while to complete. You can get the current status by calling DescribeProjectVersions . Training completed successfully if the value of the Status field is TRAINING_COMPLETED . Once training has successfully completed, call DescribeProjectVersions to get the training results and evaluate the model.

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

Note

The following applies only to projects with Amazon Rekognition Custom Labels as the chosen feature:

You can train a model in a project that doesn't have associated datasets by specifying manifest files in the TrainingData and TestingData fields.

If you open the console after training a model with manifest files, Amazon Rekognition Custom Labels creates the datasets for you using the most recent manifest files. You can no longer train a model version for the project by specifying manifest files.

Instead of training with a project without associated datasets, we recommend that you use the manifest files to create training and test datasets for the project.

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',
    VersionDescription='string',
    FeatureConfig={
        'ContentModeration': {
            'ConfidenceThreshold': ...
        }
    }
)
type ProjectArn

string

param ProjectArn

[REQUIRED]

The ARN of the Amazon Rekognition project that will manage the project version you want to train.

type VersionName

string

param VersionName

[REQUIRED]

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

type OutputConfig

dict

param OutputConfig

[REQUIRED]

The Amazon S3 bucket location to store the results of training. The bucket can be any S3 bucket in your AWS account. You need s3:PutObject permission on the bucket.

  • 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

Specifies an external manifest that the services uses to train the project version. If you specify TrainingData you must also specify TestingData . The project must not have any associated datasets.

  • Assets (list) --

    A manifest file that contains references to the training images and ground-truth annotations.

    • (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 How Amazon Rekognition works with IAM 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

Specifies an external manifest that the service uses to test the project version. If you specify TestingData you must also specify TrainingData . The project must not have any associated datasets.

  • 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 How Amazon Rekognition works with IAM 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, Rekognition splits training dataset to create a test dataset for the training job.

type Tags

dict

param Tags

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

  • (string) --

    • (string) --

type KmsKeyId

string

param KmsKeyId

The identifier for your AWS Key Management Service key (AWS KMS key). You can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your KMS key, an alias for your KMS key, or an alias ARN. The key is used to encrypt training images, test images, and manifest files copied into the service for the project version. 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 choose to use your own KMS key, you need the following permissions on the KMS key.

  • kms:CreateGrant

  • kms:DescribeKey

  • kms:GenerateDataKey

  • kms:Decrypt

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

type VersionDescription

string

param VersionDescription

A description applied to the project version being created.

type FeatureConfig

dict

param FeatureConfig

Feature-specific configuration of the training job. If the job configuration does not match the feature type associated with the project, an InvalidParameterException is returned.

  • ContentModeration (dict) --

    Configuration options for Custom Moderation training.

    • ConfidenceThreshold (float) --

      The confidence level you plan to use to identify if unsafe content is present during inference.

rtype

dict

returns

Response Syntax

{
    'ProjectVersionArn': 'string'
}

Response Structure

  • (dict) --

    • ProjectVersionArn (string) --

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

DeleteProjectVersion (updated) Link ¶
Changes (response)
{'Status': {'DEPRECATED', 'EXPIRED'}}

Deletes a Rekognition project model or project version, like a Amazon Rekognition Custom Labels model or a custom adapter.

You can't delete a project version if it is running or if it is training. To check the status of a project version, use the Status field returned from DescribeProjectVersions . To stop a project version call StopProjectVersion . If the project version is training, wait until it finishes.

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

See also: AWS API Documentation

Request Syntax

client.delete_project_version(
    ProjectVersionArn='string'
)
type ProjectVersionArn

string

param ProjectVersionArn

[REQUIRED]

The Amazon Resource Name (ARN) of the project version that you want to delete.

rtype

dict

returns

Response Syntax

{
    'Status': 'TRAINING_IN_PROGRESS'|'TRAINING_COMPLETED'|'TRAINING_FAILED'|'STARTING'|'RUNNING'|'FAILED'|'STOPPING'|'STOPPED'|'DELETING'|'COPYING_IN_PROGRESS'|'COPYING_COMPLETED'|'COPYING_FAILED'|'DEPRECATED'|'EXPIRED'
}

Response Structure

  • (dict) --

    • Status (string) --

      The status of the deletion operation.

DescribeProjectVersions (updated) Link ¶
Changes (response)
{'ProjectVersionDescriptions': {'BaseModelVersion': 'string',
                                'Feature': 'CONTENT_MODERATION | CUSTOM_LABELS',
                                'FeatureConfig': {'ContentModeration': {'ConfidenceThreshold': 'float'}},
                                'Status': {'DEPRECATED', 'EXPIRED'},
                                'VersionDescription': 'string'}}

Lists and describes the versions of an Amazon Rekognition project. You can specify up to 10 model or adapter versions in ProjectVersionArns . If you don't specify a value, descriptions for all model/adapter versions in the project 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 model/adapter you want to describe.

type VersionNames

list

param VersionNames

A list of model or project version names that you want to describe. You can add up to 10 model or project version names to the list. If you don't specify a value, all project version descriptions are returned. A version name is part of a project version 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 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'|'COPYING_IN_PROGRESS'|'COPYING_COMPLETED'|'COPYING_FAILED'|'DEPRECATED'|'EXPIRED',
            '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',
            'MaxInferenceUnits': 123,
            'SourceProjectVersionArn': 'string',
            'VersionDescription': 'string',
            'Feature': 'CONTENT_MODERATION'|'CUSTOM_LABELS',
            'BaseModelVersion': 'string',
            'FeatureConfig': {
                'ContentModeration': {
                    'ConfidenceThreshold': ...
                }
            }
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ProjectVersionDescriptions (list) --

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

      • (dict) --

        A description of a version of a Amazon Rekognition project version.

        • ProjectVersionArn (string) --

          The Amazon Resource Name (ARN) of the project 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. Applies only to Custom Labels projects. 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 you were billed for a successful training of the model version. 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 data that you supplied.

            • Assets (list) --

              A manifest file that contains references to the training images and ground-truth annotations.

              • (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 How Amazon Rekognition works with IAM 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) --

            Reference to images (assets) that were actually used during training with trained model predictions.

            • Assets (list) --

              A manifest file that contains references to the training images and ground-truth annotations.

              • (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 How Amazon Rekognition works with IAM 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) --

            A manifest that you supplied for training, with validation results for each line.

            • 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 How Amazon Rekognition works with IAM 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 How Amazon Rekognition works with IAM 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, Rekognition splits training dataset to create a test dataset for the training job.

          • 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 How Amazon Rekognition works with IAM 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, Rekognition splits training dataset to create a test dataset for the training job.

          • 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 How Amazon Rekognition works with IAM 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 How Amazon Rekognition works with IAM 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 How Amazon Rekognition works with IAM 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 key (AWS KMS key) that was used to encrypt the model during training.

        • MaxInferenceUnits (integer) --

          The maximum number of inference units Amazon Rekognition uses to auto-scale the model. Applies only to Custom Labels projects. For more information, see StartProjectVersion .

        • SourceProjectVersionArn (string) --

          If the model version was copied from a different project, SourceProjectVersionArn contains the ARN of the source model version.

        • VersionDescription (string) --

          A user-provided description of the project version.

        • Feature (string) --

          The feature that was customized.

        • BaseModelVersion (string) --

          The base detection model version used to create the project version.

        • FeatureConfig (dict) --

          Feature specific configuration that was applied during training.

          • ContentModeration (dict) --

            Configuration options for Custom Moderation training.

            • ConfidenceThreshold (float) --

              The confidence level you plan to use to identify if unsafe content is present during inference.

    • NextToken (string) --

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

DescribeProjects (updated) Link ¶
Changes (request, response)
Request
{'Features': ['CONTENT_MODERATION | CUSTOM_LABELS']}
Response
{'ProjectDescriptions': {'AutoUpdate': 'ENABLED | DISABLED',
                         'Feature': 'CONTENT_MODERATION | CUSTOM_LABELS'}}

Gets information about your Rekognition projects.

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

See also: AWS API Documentation

Request Syntax

client.describe_projects(
    NextToken='string',
    MaxResults=123,
    ProjectNames=[
        'string',
    ],
    Features=[
        'CONTENT_MODERATION'|'CUSTOM_LABELS',
    ]
)
type NextToken

string

param NextToken

If the previous response was incomplete (because there is more results to retrieve), Rekognition 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.

type ProjectNames

list

param ProjectNames

A list of the projects that you want Rekognition to describe. If you don't specify a value, the response includes descriptions for all the projects in your AWS account.

  • (string) --

type Features

list

param Features

Specifies the type of customization to filter projects by. If no value is specified, CUSTOM_LABELS is used as a default.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'ProjectDescriptions': [
        {
            'ProjectArn': 'string',
            'CreationTimestamp': datetime(2015, 1, 1),
            'Status': 'CREATING'|'CREATED'|'DELETING',
            'Datasets': [
                {
                    'CreationTimestamp': datetime(2015, 1, 1),
                    'DatasetType': 'TRAIN'|'TEST',
                    'DatasetArn': 'string',
                    'Status': 'CREATE_IN_PROGRESS'|'CREATE_COMPLETE'|'CREATE_FAILED'|'UPDATE_IN_PROGRESS'|'UPDATE_COMPLETE'|'UPDATE_FAILED'|'DELETE_IN_PROGRESS',
                    'StatusMessage': 'string',
                    'StatusMessageCode': 'SUCCESS'|'SERVICE_ERROR'|'CLIENT_ERROR'
                },
            ],
            'Feature': 'CONTENT_MODERATION'|'CUSTOM_LABELS',
            'AutoUpdate': 'ENABLED'|'DISABLED'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ProjectDescriptions (list) --

      A list of project descriptions. The list is sorted by the date and time the projects are created.

      • (dict) --

        A description of an Amazon Rekognition Custom Labels project. For more information, see DescribeProjects .

        • ProjectArn (string) --

          The Amazon Resource Name (ARN) of the project.

        • CreationTimestamp (datetime) --

          The Unix timestamp for the date and time that the project was created.

        • Status (string) --

          The current status of the project.

        • Datasets (list) --

          Information about the training and test datasets in the project.

          • (dict) --

            Summary information for an Amazon Rekognition Custom Labels dataset. For more information, see ProjectDescription .

            • CreationTimestamp (datetime) --

              The Unix timestamp for the date and time that the dataset was created.

            • DatasetType (string) --

              The type of the dataset.

            • DatasetArn (string) --

              The Amazon Resource Name (ARN) for the dataset.

            • Status (string) --

              The status for the dataset.

            • StatusMessage (string) --

              The status message for the dataset.

            • StatusMessageCode (string) --

              The status message code for the dataset operation. If a service error occurs, try the API call again later. If a client error occurs, check the input parameters to the dataset API call that failed.

        • Feature (string) --

          Specifies the project that is being customized.

        • AutoUpdate (string) --

          Indicates whether automatic retraining will be attempted for the versions of the project. Applies only to adapters.

    • NextToken (string) --

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

DetectModerationLabels (updated) Link ¶
Changes (both)
{'ProjectVersion': 'string'}

Detects unsafe content in a specified JPEG or PNG format image. Use DetectModerationLabels to moderate images depending on your requirements. For example, you might want to filter images that contain nudity, but not images containing suggestive content.

To filter images, use the labels returned by DetectModerationLabels to determine which types of content are appropriate.

For information about moderation labels, see Detecting Unsafe Content in the Amazon Rekognition Developer Guide.

You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.

You can specify an adapter to use when retrieving label predictions by providing a ProjectVersionArn to the ProjectVersion argument.

See also: AWS API Documentation

Request Syntax

client.detect_moderation_labels(
    Image={
        'Bytes': b'bytes',
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    MinConfidence=...,
    HumanLoopConfig={
        'HumanLoopName': 'string',
        'FlowDefinitionArn': 'string',
        'DataAttributes': {
            'ContentClassifiers': [
                'FreeOfPersonallyIdentifiableInformation'|'FreeOfAdultContent',
            ]
        }
    },
    ProjectVersion='string'
)
type Image

dict

param Image

[REQUIRED]

The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.

If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.

  • Bytes (bytes) --

    Blob of image bytes up to 5 MBs. Note that the maximum image size you can pass to DetectCustomLabels is 4MB.

  • S3Object (dict) --

    Identifies an S3 object as the image source.

    • 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 MinConfidence

float

param MinConfidence

Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with a confidence level lower than this specified value.

If you don't specify MinConfidence , the operation returns labels with confidence values greater than or equal to 50 percent.

type HumanLoopConfig

dict

param HumanLoopConfig

Sets up the configuration for human evaluation, including the FlowDefinition the image will be sent to.

  • HumanLoopName (string) -- [REQUIRED]

    The name of the human review used for this image. This should be kept unique within a region.

  • FlowDefinitionArn (string) -- [REQUIRED]

    The Amazon Resource Name (ARN) of the flow definition. You can create a flow definition by using the Amazon Sagemaker CreateFlowDefinition Operation.

  • DataAttributes (dict) --

    Sets attributes of the input data.

    • ContentClassifiers (list) --

      Sets whether the input image is free of personally identifiable information.

      • (string) --

type ProjectVersion

string

param ProjectVersion

Identifier for the custom adapter. Expects the ProjectVersionArn as a value. Use the CreateProject or CreateProjectVersion APIs to create a custom adapter.

rtype

dict

returns

Response Syntax

{
    'ModerationLabels': [
        {
            'Confidence': ...,
            'Name': 'string',
            'ParentName': 'string'
        },
    ],
    'ModerationModelVersion': 'string',
    'HumanLoopActivationOutput': {
        'HumanLoopArn': 'string',
        'HumanLoopActivationReasons': [
            'string',
        ],
        'HumanLoopActivationConditionsEvaluationResults': 'string'
    },
    'ProjectVersion': 'string'
}

Response Structure

  • (dict) --

    • ModerationLabels (list) --

      Array of detected Moderation labels and the time, in milliseconds from the start of the video, they were detected.

      • (dict) --

        Provides information about a single type of inappropriate, unwanted, or offensive content found in an image or video. Each type of moderated content has a label within a hierarchical taxonomy. For more information, see Content moderation in the Amazon Rekognition Developer Guide.

        • Confidence (float) --

          Specifies the confidence that Amazon Rekognition has that the label has been correctly identified.

          If you don't specify the MinConfidence parameter in the call to DetectModerationLabels , the operation returns labels with a confidence value greater than or equal to 50 percent.

        • Name (string) --

          The label name for the type of unsafe content detected in the image.

        • ParentName (string) --

          The name for the parent label. Labels at the top level of the hierarchy have the parent label "" .

    • ModerationModelVersion (string) --

      Version number of the base moderation detection model that was used to detect unsafe content.

    • HumanLoopActivationOutput (dict) --

      Shows the results of the human in the loop evaluation.

      • HumanLoopArn (string) --

        The Amazon Resource Name (ARN) of the HumanLoop created.

      • HumanLoopActivationReasons (list) --

        Shows if and why human review was needed.

        • (string) --

      • HumanLoopActivationConditionsEvaluationResults (string) --

        Shows the result of condition evaluations, including those conditions which activated a human review.

    • ProjectVersion (string) --

      Identifier of the custom adapter that was used during inference. If during inference the adapter was EXPIRED, then the parameter will not be returned, indicating that a base moderation detection project version was used.

StartProjectVersion (updated) Link ¶
Changes (response)
{'Status': {'DEPRECATED', 'EXPIRED'}}

Note

This operation applies only to Amazon Rekognition Custom Labels.

Starts the running of the version of a model. Starting a model takes a while to complete. To check the current state of the model, use DescribeProjectVersions .

Once the model is running, you can detect custom labels in new images by calling DetectCustomLabels .

Note

You are charged for the amount of time that the model is running. To stop a running model, call StopProjectVersion .

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

See also: AWS API Documentation

Request Syntax

client.start_project_version(
    ProjectVersionArn='string',
    MinInferenceUnits=123,
    MaxInferenceUnits=123
)
type ProjectVersionArn

string

param ProjectVersionArn

[REQUIRED]

The Amazon Resource Name(ARN) of the model version that you want to start.

type MinInferenceUnits

integer

param MinInferenceUnits

[REQUIRED]

The minimum number of inference units to use. A single inference unit represents 1 hour of processing.

Use a higher number to increase the TPS throughput of your model. You are charged for the number of inference units that you use.

type MaxInferenceUnits

integer

param MaxInferenceUnits

The maximum number of inference units to use for auto-scaling the model. If you don't specify a value, Amazon Rekognition Custom Labels doesn't auto-scale the model.

rtype

dict

returns

Response Syntax

{
    'Status': 'TRAINING_IN_PROGRESS'|'TRAINING_COMPLETED'|'TRAINING_FAILED'|'STARTING'|'RUNNING'|'FAILED'|'STOPPING'|'STOPPED'|'DELETING'|'COPYING_IN_PROGRESS'|'COPYING_COMPLETED'|'COPYING_FAILED'|'DEPRECATED'|'EXPIRED'
}

Response Structure

  • (dict) --

    • Status (string) --

      The current running status of the model.

StopProjectVersion (updated) Link ¶
Changes (response)
{'Status': {'DEPRECATED', 'EXPIRED'}}

Note

This operation applies only to Amazon Rekognition Custom Labels.

Stops a running model. The operation might take a while to complete. To check the current status, call DescribeProjectVersions . Only applies to Custom Labels projects.

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

See also: AWS API Documentation

Request Syntax

client.stop_project_version(
    ProjectVersionArn='string'
)
type ProjectVersionArn

string

param ProjectVersionArn

[REQUIRED]

The Amazon Resource Name (ARN) of the model version that you want to stop.

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

rtype

dict

returns

Response Syntax

{
    'Status': 'TRAINING_IN_PROGRESS'|'TRAINING_COMPLETED'|'TRAINING_FAILED'|'STARTING'|'RUNNING'|'FAILED'|'STOPPING'|'STOPPED'|'DELETING'|'COPYING_IN_PROGRESS'|'COPYING_COMPLETED'|'COPYING_FAILED'|'DEPRECATED'|'EXPIRED'
}

Response Structure

  • (dict) --

    • Status (string) --

      The current status of the stop operation.