CreateImageModerationTask

Updated at:

Checks whether image content is compliant, including detection scenarios such as pornography, terrorism and political content, undesirable scenes, logos, and text and image violations.

Operation description

  • Before you call this operation, make sure that you fully understand the billing methods and pricing of Intelligent Media Management.
    Important Asynchronous tasks do not guarantee timeliness.
  • Image requirements:
    • Image URLs support the following protocols: HTTP and HTTPS.

    • Images support the following formats: PNG, JPG, JPEG, BMP, GIF, and WEBP.

    • The image size is limited to 20 MB (applicable to both synchronous and asynchronous calls). The height or width cannot exceed 30,000 pixels (px), and the total number of pixels cannot exceed 250 million (px). For GIF images, the total number of pixels cannot exceed 4,194,304 (px), and the height or width cannot exceed 30,000 pixels (px).

    • The image download time is limited to 3 seconds. If the download time exceeds 3 seconds, a download timeout error is returned.

    • We recommend that the image resolution be no less than 256 × 256 px. A low resolution may affect the recognition effect.

    • The response time of the image detection API operation depends on the image download time. Make sure that the storage service where the detected images are stored is stable and reliable. We recommend that you use Alibaba Cloud OSS or CDN caching.

  • This operation is asynchronous. After a task starts, the task information is retained for only 7 days. You cannot obtain the task information after 7 days. Call the GetTask or ListTasks operation to obtain the returned TaskId and view the task information. You can also set the Notification parameter to obtain the task information through message notifications.

Note

Detection results are returned through asynchronous message notifications. Valid values of the Suggestion field in asynchronous message notifications:

  • pass: The image passes the check. No non-compliant content is detected.

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

  • review: Manual review is required. After the manual review is completed, another asynchronous message notification is sent to inform you of the review result.>

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

imm:CreateImageModerationTask

create

*Project

acs:imm:{#regionId}:{#accountId}:project/{#ProjectName}

None None

Request parameters

Parameter

Type

Required

Description

Example

ProjectName

string

Yes

The name of the project. For more information about how to obtain the project name, see Create a project.

test-project

UserData

string

No

The custom user information. This information is returned in asynchronous message notifications to help you associate and process message notifications in your system. The maximum length is 2,048 bytes.

test-data

SourceURI

string

Yes

The OSS URL of the image.

The OSS URL format is oss://<Bucket>/<Object>, where <Bucket> is the name of the OSS bucket that resides in the same region as the current project, and <Object> is the full path of the file including the file name extension.

oss://test-bucket/test-object

Tags

object

No

The custom tags used to search and filter asynchronous tasks.

{ "User": "Jane" }

CredentialConfig CredentialConfig

No

The chained authorization configuration. This parameter is optional. For more information, see Use chained authorization to access resources of other entities.

Scenes

array

No

The image detection scenarios.

string

No

The specified image detection scenarios. Valid values:

  • porn: Pornography detection.

  • terrorism: Terrorism and political content detection.

  • live: Undesirable scene detection.

  • logo: Logo detection.

  • ad: Text and image violation detection.

Note

If you do not specify detection scenarios, the porn, terrorism, and ad scenarios are detected by default.

Valid values:

  • ad :

    Text and image violations.

  • terrorism :

    Terrorism and political content.

  • logo :

    Contains logos.

  • live :

    Undesirable scenes.

  • porn :

    Pornography.

porn

Interval

integer

No

The frame capture frequency. This parameter is dedicated to GIF and long image detection. Default value: 1.

2

MaxFrames

integer

No

The maximum number of captured frames. This parameter is dedicated to GIF and long image detection. Default value: 1.

10

Notification Notification

No

The message notification configuration. For more information, click Notification. For more information about the format of asynchronous notification messages, see Asynchronous notification message format.

Response elements

Element

Type

Description

Example

object

The response struct.

RequestId

string

The ID of the request.

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

TaskId

string

The ID of the task.

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

EventId

string

The ID of the event.

2E6-1I0FGn0zFnl5AflRfhzClma*****

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.