Amazon Rekognition

2023/10/23 - Amazon Rekognition - 3 new api methods

Changes  Amazon Rekognition introduces StartMediaAnalysisJob, GetMediaAnalysisJob, and ListMediaAnalysisJobs operations to run a bulk analysis of images with a Detect Moderation model.

ListMediaAnalysisJobs (new) Link ¶

Returns a list of media analysis jobs. Results are sorted by CreationTimestamp in descending order.

See also: AWS API Documentation

Request Syntax

client.list_media_analysis_jobs(
    NextToken='string',
    MaxResults=123
)
type NextToken

string

param NextToken

Pagination token, if the previous response was incomplete.

type MaxResults

integer

param MaxResults

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

rtype

dict

returns

Response Syntax

{
    'NextToken': 'string',
    'MediaAnalysisJobs': [
        {
            'JobId': 'string',
            'JobName': 'string',
            'OperationsConfig': {
                'DetectModerationLabels': {
                    'MinConfidence': ...,
                    'ProjectVersion': 'string'
                }
            },
            'Status': 'CREATED'|'QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED',
            'FailureDetails': {
                'Code': 'INTERNAL_ERROR'|'INVALID_S3_OBJECT'|'INVALID_MANIFEST'|'INVALID_OUTPUT_CONFIG'|'INVALID_KMS_KEY'|'ACCESS_DENIED'|'RESOURCE_NOT_FOUND'|'RESOURCE_NOT_READY'|'THROTTLED',
                'Message': 'string'
            },
            'CreationTimestamp': datetime(2015, 1, 1),
            'CompletionTimestamp': datetime(2015, 1, 1),
            'Input': {
                'S3Object': {
                    'Bucket': 'string',
                    'Name': 'string',
                    'Version': 'string'
                }
            },
            'OutputConfig': {
                'S3Bucket': 'string',
                'S3KeyPrefix': 'string'
            },
            'KmsKeyId': 'string',
            'Results': {
                'S3Object': {
                    'Bucket': 'string',
                    'Name': 'string',
                    'Version': 'string'
                }
            },
            'ManifestSummary': {
                'S3Object': {
                    'Bucket': 'string',
                    'Name': 'string',
                    'Version': 'string'
                }
            }
        },
    ]
}

Response Structure

  • (dict) --

    • NextToken (string) --

      Pagination token, if the previous response was incomplete.

    • MediaAnalysisJobs (list) --

      Contains a list of all media analysis jobs.

      • (dict) --

        Description for a media analysis job.

        • JobId (string) --

          The identifier for a media analysis job.

        • JobName (string) --

          The name of a media analysis job.

        • OperationsConfig (dict) --

          Operation configurations that were provided during job creation.

          • DetectModerationLabels (dict) --

            Contains configuration options for a DetectModerationLabels job.

            • MinConfidence (float) --

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

            • ProjectVersion (string) --

              Specifies the custom moderation model to be used during the label detection job. If not provided the pre-trained model is used.

        • Status (string) --

          The status of the media analysis job being retrieved.

        • FailureDetails (dict) --

          Details about the error that resulted in failure of the job.

          • Code (string) --

            Error code for the failed job.

          • Message (string) --

            Human readable error message.

        • CreationTimestamp (datetime) --

          The Unix date and time when the job was started.

        • CompletionTimestamp (datetime) --

          The Unix date and time when the job finished.

        • Input (dict) --

          Reference to the input manifest that was provided in the job creation request.

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

        • OutputConfig (dict) --

          Output configuration that was provided in the creation request.

          • S3Bucket (string) --

            Specifies the Amazon S3 bucket to contain the output of the media analysis job.

          • S3KeyPrefix (string) --

            Specifies the Amazon S3 key prefix that comes after the name of the bucket you have designated for storage.

        • KmsKeyId (string) --

          KMS Key that was provided in the creation request.

        • Results (dict) --

          Output manifest that contains prediction results.

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

          Provides statistics on input manifest and errors identified in the input manifest.

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

StartMediaAnalysisJob (new) Link ¶

Initiates a new media analysis job. Accepts a manifest file in an Amazon S3 bucket. The output is a manifest file and a summary of the manifest stored in the Amazon S3 bucket.

See also: AWS API Documentation

Request Syntax

client.start_media_analysis_job(
    ClientRequestToken='string',
    JobName='string',
    OperationsConfig={
        'DetectModerationLabels': {
            'MinConfidence': ...,
            'ProjectVersion': 'string'
        }
    },
    Input={
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    OutputConfig={
        'S3Bucket': 'string',
        'S3KeyPrefix': 'string'
    },
    KmsKeyId='string'
)
type ClientRequestToken

string

param ClientRequestToken

Idempotency token used to prevent the accidental creation of duplicate versions. If you use the same token with multiple StartMediaAnalysisJobRequest requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.

This field is autopopulated if not provided.

type JobName

string

param JobName

The name of the job. Does not have to be unique.

type OperationsConfig

dict

param OperationsConfig

[REQUIRED]

Configuration options for the media analysis job to be created.

  • DetectModerationLabels (dict) --

    Contains configuration options for a DetectModerationLabels job.

    • MinConfidence (float) --

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

    • ProjectVersion (string) --

      Specifies the custom moderation model to be used during the label detection job. If not provided the pre-trained model is used.

type Input

dict

param Input

[REQUIRED]

Input data to be analyzed by the job.

  • S3Object (dict) -- [REQUIRED]

    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 OutputConfig

dict

param OutputConfig

[REQUIRED]

The Amazon S3 bucket location to store the results.

  • S3Bucket (string) -- [REQUIRED]

    Specifies the Amazon S3 bucket to contain the output of the media analysis job.

  • S3KeyPrefix (string) --

    Specifies the Amazon S3 key prefix that comes after the name of the bucket you have designated for storage.

type KmsKeyId

string

param KmsKeyId

The identifier of customer managed AWS KMS key (name or ARN). The key is used to encrypt images copied into the service. The key is also used to encrypt results and manifest files written to the output Amazon S3 bucket.

rtype

dict

returns

Response Syntax

{
    'JobId': 'string'
}

Response Structure

  • (dict) --

    • JobId (string) --

      Identifier for the created job.

GetMediaAnalysisJob (new) Link ¶

Retrieves the results for a given media analysis job. Takes a JobId returned by StartMediaAnalysisJob.

See also: AWS API Documentation

Request Syntax

client.get_media_analysis_job(
    JobId='string'
)
type JobId

string

param JobId

[REQUIRED]

Unique identifier for the media analysis job for which you want to retrieve results.

rtype

dict

returns

Response Syntax

{
    'JobId': 'string',
    'JobName': 'string',
    'OperationsConfig': {
        'DetectModerationLabels': {
            'MinConfidence': ...,
            'ProjectVersion': 'string'
        }
    },
    'Status': 'CREATED'|'QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED',
    'FailureDetails': {
        'Code': 'INTERNAL_ERROR'|'INVALID_S3_OBJECT'|'INVALID_MANIFEST'|'INVALID_OUTPUT_CONFIG'|'INVALID_KMS_KEY'|'ACCESS_DENIED'|'RESOURCE_NOT_FOUND'|'RESOURCE_NOT_READY'|'THROTTLED',
        'Message': 'string'
    },
    'CreationTimestamp': datetime(2015, 1, 1),
    'CompletionTimestamp': datetime(2015, 1, 1),
    'Input': {
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    'OutputConfig': {
        'S3Bucket': 'string',
        'S3KeyPrefix': 'string'
    },
    'KmsKeyId': 'string',
    'Results': {
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    'ManifestSummary': {
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    }
}

Response Structure

  • (dict) --

    • JobId (string) --

      The identifier for the media analysis job.

    • JobName (string) --

      The name of the media analysis job.

    • OperationsConfig (dict) --

      Operation configurations that were provided during job creation.

      • DetectModerationLabels (dict) --

        Contains configuration options for a DetectModerationLabels job.

        • MinConfidence (float) --

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

        • ProjectVersion (string) --

          Specifies the custom moderation model to be used during the label detection job. If not provided the pre-trained model is used.

    • Status (string) --

      The current status of the media analysis job.

    • FailureDetails (dict) --

      Details about the error that resulted in failure of the job.

      • Code (string) --

        Error code for the failed job.

      • Message (string) --

        Human readable error message.

    • CreationTimestamp (datetime) --

      The Unix date and time when the job was started.

    • CompletionTimestamp (datetime) --

      The Unix date and time when the job finished.

    • Input (dict) --

      Reference to the input manifest that was provided in the job creation request.

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

    • OutputConfig (dict) --

      Output configuration that was provided in the creation request.

      • S3Bucket (string) --

        Specifies the Amazon S3 bucket to contain the output of the media analysis job.

      • S3KeyPrefix (string) --

        Specifies the Amazon S3 key prefix that comes after the name of the bucket you have designated for storage.

    • KmsKeyId (string) --

      KMS Key that was provided in the creation request.

    • Results (dict) --

      Output manifest that contains prediction results.

      • 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 summary manifest provides statistics on input manifest and errors identified in the input manifest.

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