Menu
Amazon Rekognition
Developer Guide

DetectModerationLabels

Detects explicit or suggestive adult 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 Moderating Images.

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 Amazon CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.

Request Syntax

Copy
{ "Image": { "Bytes": blob, "S3Object": { "Bucket": "string", "Name": "string", "Version": "string" } }, "MinConfidence": number }

Request Parameters

The request accepts the following data in JSON format.

Image

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.

Type: Image object

Required: Yes

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: Float

Valid Range: Minimum value of 0. Maximum value of 100.

Required: No

Response Syntax

Copy
{ "ModerationLabels": [ { "Confidence": number, "Name": "string", "ParentName": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ModerationLabels

An array of labels for explicit or suggestive adult content found in the image. The list includes the top-level label and each second-level label detected in the image. This is useful for filtering specific categories of content.

Type: Array of ModerationLabel objects

Errors

AccessDeniedException

You are not authorized to perform the action.

HTTP Status Code: 400

ImageTooLargeException

The input image size exceeds the allowed limit. For more information, see Limits in Amazon Rekognition.

HTTP Status Code: 400

InternalServerError

Amazon Rekognition experienced a service issue. Try your call again.

HTTP Status Code: 500

InvalidImageFormatException

The provided image format is not supported.

HTTP Status Code: 400

InvalidParameterException

Input parameter violated a constraint. Validate your parameter before calling the API operation again.

HTTP Status Code: 400

InvalidS3ObjectException

Amazon Rekognition is unable to access the S3 object specified in the request.

HTTP Status Code: 400

ProvisionedThroughputExceededException

The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.

HTTP Status Code: 400

ThrottlingException

Amazon Rekognition is temporarily unable to process the request. Try your call again.

HTTP Status Code: 500

Examples

Example Request

The following example shows the request for a DetectModerationLabels API operation.

Sample Request

Copy
POST / HTTP/1.1 Host: rekognition.us-west-2.amazonaws.com Accept-Encoding: identity Content-Length: 77 X-Amz-Target: RekognitionService.DetectModerationLabels X-Amz-Date: 20170424T195840Z User-Agent: aws-cli/1.11.44 Python/2.7.6 Linux/4.2.0-42-generic botocore/1.5.7 Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256 Credential=XXXXXXXXXXXXXXXXXXXXXXXXX/20170424/us-west-2/rekognition/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=XXXXXXXXXXXXXXXXXXXXXXXXX { "Image":{ "S3Object":{ "Bucket":"example-photos", "Name":"input.jpg" } } }

Example Response

The following example shows the response of a call to DetectmoderationLabels.

Sample Response

Copy
{ "ModerationLabels": [ { "Confidence": 79.03318786621094, "ParentName": "", "Name": "Explicit Nudity" }, { "Confidence": 79.03318786621094, "ParentName": "Explicit Nudity", "Name": "Graphic Male Nudity" }, { "Confidence": 68.99967956542969, "ParentName": "Explicit Nudity", "Name": "Sexual Activity" } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: