All Products
Search
Document Center

Intelligent Media Management:CreateImageModerationTask

Last Updated:Dec 11, 2024

Creates an image moderation task to ensure image content compliance. You can call this operation to identify inappropriate content, such as pornography, violence, terrorism, politically sensitive content, undesirable scenes, unauthorized logos, and non-compliant ads.

Operation description

  • Before you call this operation, make sure that you are familiar with the billing of Intelligent Media Management (IMM).****

    **

    Note Asynchronous processing does not guarantee timely task completion.

  • The image for which you want to create a content moderation task must meet the following requirements:

    • The image URL supports the HTTP and HTTPS protocols.
    • The image is in one of the following formats: PNG, JPG, JPEG, BMP, GIF, and WebP
    • The image size is limited to 20 MB for synchronous and asynchronous calls, with a maximum height or width of 30,000 pixels. The total number of pixels cannot exceed 250 million. GIF images are limited to 4,194,304 pixels, with a maximum height or width of 30,000 pixels.
    • The image download time is limited to 3 seconds. If the download takes longer, a timeout error occurs.
    • To ensure effective moderation, we recommend that you submit an image with dimensions of at least 256 × 256 pixels.
    • The response time of the CreateImageModerationTask operation varies based on the duration of the image download. Make sure that the image is stored in a stable and reliable service. We recommend that you store images on Alibaba Cloud Object Storage Service (OSS) or cache them on Alibaba Cloud CDN.
  • This operation is an asynchronous operation. After a task is executed, the task information is retained only for seven days and cannot be retrieved when the retention period elapses. You can call the GetTask or ListTasks operation to query information about the task.`` If you specify Notification , you can also obtain information about the task based on notifications.

Note The detection result is sent as an asynchronous notification. The Suggestion field of the notification can have one of the following values:
  • pass: No non-compliant content is found.

  • block: Non-compliant content is detected. The Categories field value indicates the non-compliance categories. For more information, see Content moderation results.

  • review: A manual review is needed. After the manual review is finished, another asynchronous notification is sent to inform you about the review result. >

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
imm:CreateImageModerationTaskcreate
*Project
acs:imm:{#regionId}:{#accountId}:project/{#ProjectName}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ProjectNamestringYes

The name of the project. You can obtain the name of the project from the response of the CreateProject operation.

immtest
UserDatastringNo

The user data, which is returned in an asynchronous notification and facilitates notification management. The maximum length of the user data is 2,048 bytes.

{"ID": "user1","Name": "test-user1","Avatar": "http://example.com?id=user1"}
SourceURIstringYes

The URI of the Object Storage Service (OSS) bucket in which you store the image.

Specify the value in the oss://<Bucket>/<Object> format. <Bucket> specifies the name of the OSS bucket that resides in the same region as the current project. <Object> specifies the complete path to the image file that has an extension.

oss://test-bucket/test-object
TagsobjectNo

The custom tags. You can search for or filter asynchronous tasks by custom tag.

{"test": "val1"}
CredentialConfigCredentialConfigNo

The authorization chain. For more information, see Use authorization chains to access resources of other entities.

ScenesarrayNo

The scenarios in which you want to apply the image moderation task.

stringNo

The scenario in which you want to apply the image moderation task.

  • porn: detects pornography.
  • terrorism: detects terrorism or politically sensitive content.
  • live: detects undesirable scenes.
  • logo: detects unauthorized logos.
  • ad: detects non-compliant ads.
Note If you do not specify this parameter, porn, terrorism, and ad are automatically used.
porn
IntervallongNo

The time interval between two consecutive frames in a GIF or long image. Default value: 1.

2
MaxFrameslongNo

The maximum number of frames that can be captured in a GIF or long image. Default value: 1.

10
NotificationNotificationNo

The notification settings. For more information, click Notification. For information about the asynchronous notification format, see Asynchronous notification format.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

1B3D5E0A-D8B8-4DA0-8127-ED32C851****
TaskIdstring

The task ID.

ImageModeration-179ef4f8-d583-4f0c-a293-7c0889c*****
EventIdstring

The event ID.

2E6-1I0FGn0zFnl5AflRfhzClma*****

Examples

Sample success responses

JSONformat

{
  "RequestId": "1B3D5E0A-D8B8-4DA0-8127-ED32C851****",
  "TaskId": "ImageModeration-179ef4f8-d583-4f0c-a293-7c0889c*****",
  "EventId": "2E6-1I0FGn0zFnl5AflRfhzClma*****"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-04-19The API operation is not deprecated.. The Error code has changedView Change Details
2023-08-21The Error code has changed. The request parameters of the API has changedView Change Details
2023-04-03The Error code has changed. The request parameters of the API has changedView Change Details
2023-03-09The Error code has changed. The request parameters of the API has changedView Change Details
2022-08-16The Error code has changed. The request parameters of the API has changedView Change Details
2022-08-16The Error code has changed. The request parameters of the API has changedView Change Details