DetectModerationLabels
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 Moderating content. For a list of moderation labels in Amazon Rekognition, see Using the image and video moderation APIs.
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.
Request Syntax
{
"HumanLoopConfig": {
"DataAttributes": {
"ContentClassifiers": [ "string
" ]
},
"FlowDefinitionArn": "string
",
"HumanLoopName": "string
"
},
"Image": {
"Bytes": blob
,
"S3Object": {
"Bucket": "string
",
"Name": "string
",
"Version": "string
"
}
},
"MinConfidence": number
,
"ProjectVersion": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- HumanLoopConfig
-
Sets up the configuration for human evaluation, including the FlowDefinition the image will be sent to.
Type: HumanLoopConfig object
Required: No
- 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.
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 Image specifications.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
- ProjectVersion
-
Identifier for the custom adapter. Expects the ProjectVersionArn as a value. Use the CreateProject or CreateProjectVersion APIs to create a custom adapter.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Pattern:
(^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA-Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
Required: No
Response Syntax
{
"ContentTypes": [
{
"Confidence": number,
"Name": "string"
}
],
"HumanLoopActivationOutput": {
"HumanLoopActivationConditionsEvaluationResults": "string",
"HumanLoopActivationReasons": [ "string" ],
"HumanLoopArn": "string"
},
"ModerationLabels": [
{
"Confidence": number,
"Name": "string",
"ParentName": "string",
"TaxonomyLevel": number
}
],
"ModerationModelVersion": "string",
"ProjectVersion": "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.
- ContentTypes
-
A list of predicted results for the type of content an image contains. For example, the image content might be from animation, sports, or a video game.
Type: Array of ContentType objects
Array Members: Minimum number of 0 items. Maximum number of 50 items.
- HumanLoopActivationOutput
-
Shows the results of the human in the loop evaluation.
Type: HumanLoopActivationOutput object
- ModerationLabels
-
Array of detected Moderation labels. For video operations, this includes the time, in milliseconds from the start of the video, they were detected.
Type: Array of ModerationLabel objects
- ModerationModelVersion
-
Version number of the base moderation detection model that was used to detect unsafe content.
Type: String
- ProjectVersion
-
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.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Pattern:
(^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA-Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
You are not authorized to perform the action.
HTTP Status Code: 400
- HumanLoopQuotaExceededException
-
The number of in-progress human reviews you have has exceeded the number allowed.
HTTP Status Code: 400
- ImageTooLargeException
-
The input image size exceeds the allowed limit. If you are calling DetectProtectiveEquipment, the image size or resolution exceeds the allowed limit. For more information, see Guidelines and quotas 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
- ResourceNotFoundException
-
The resource specified in the request cannot be found.
HTTP Status Code: 400
- ResourceNotReadyException
-
The requested resource isn't ready. For example, this exception occurs when you call
DetectCustomLabels
with a model version that isn't deployed.HTTP Status Code: 400
- ThrottlingException
-
Amazon Rekognition is temporarily unable to process the request. Try your call again.
HTTP Status Code: 500
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: