All Products
Search
Document Center

Content Moderation:AI-generated image identification service of Image Moderation 2.0

Last Updated:Aug 05, 2024

Image Moderation 2.0 of Alibaba Cloud Content Moderation provides the AI-generated image identification service for AI-generated content (AIGC) scenarios. This service allows you to determine whether images are generated by AI. This topic describes this service in detail.

1. Scenarios

Alibaba Cloud Content Moderation provides the following custom moderation service for AIGC scenarios, such as text-to-image generation and image-to-image generation:

  • AI-generated image identification: As technology advances, AI-generated images are becoming increasingly similar to those produced by users. You may want to identify and label images that are generated by AI. This is where the AI-generated image identification service of Alibaba Cloud Content Moderation comes in.

2. Service description

Image Moderation 2.0 provides the following service for AIGC scenarios.

Service

Content to be moderated

Use scenario

Service name: AI-generated image identification

(aigcDetector_global)

When this service is called, this service checks whether the specified image is generated by AI.

To check whether images are generated by AI in various scenarios. We recommend that you use this service when you need to identify sources of images.

3. Moderation capability

AI-generated image identification allows you to determine whether an image is generated by AI. An AIGC or user-generated content (UGC) label is returned.

4. Billing

The AI-generated image identification service of Image Moderation 2.0 supports the pay-as-you-go billing method.

Pay-as-you-go

After you activate the Image Moderation 2.0 service, the default billing method is pay-as-you-go. Daily fees are settled based on the actual usage. If the service is not called, no charge is made.

Moderation type

Supported business scenario (service)

Unit price

Common image moderation (image_standard)

  • AI-generated image identification (aigcDetector_global)

USD 0.6 per thousand calls

Note

You are charged every time you call the AI-generated image identification service. You are charged based on the number of service calls. For example, you are charged USD 0.06 if you call the AI-generated image identification service 100 times.

Note

Bills for Content Moderation 2.0 in pay-as-you-go mode are generated every 24 hours. In the billing details, moderationType corresponds to the moderation type column in the preceding table. For more information, visit the Bill Details page.

5. Usage guide

Step 1: Activate the service

Open the service activation page to activate the Image Moderation 2.0 service.

After you activate the Image Moderation 2.0 service, the default billing method is pay-as-you-go. Daily fees are settled based on the actual usage. If the service is not called, no charge is made. After you call the API, the billing system automatically charges you based on your usage. For more information, see Billing method.

Step 2: Grant permissions to a RAM user

Before you call API operations or use SDKs as a Resource Access Management (RAM) user, you must grant permissions to the RAM user. You can create an AccessKey pair for your Alibaba Cloud account and the RAM user. When you call API operations, you must use the AccessKey pair to complete identity verification. For information about how to obtain the AccessKey pair, see Obtain an AccessKey pair.

  1. Log on to the RAM console by using your Alibaba Cloud account or as a RAM user that has administrative permissions.

  2. Create a RAM user. For more information, see Create a RAM user.

  3. Grant the AliyunYundunGreenWebFullAccess system policy to the RAM user. For more information, see Grant permissions to a RAM user. After you complete the preceding configurations, you can call the Content Moderation API as the RAM user.

Step 3: Install and use SDKs

For more information, see Image Moderation 2.0 SDKs and usage guide. The following table lists the supported regions.

Region

Public endpoint

Internal endpoint

Supported service

Singapore

https://green-cip.ap-southeast-1.aliyuncs.com

https://green-cip-vpc.ap-southeast-1.aliyuncs.com

aigcDetector_global

6. API

Usage notes

You can call the Image Moderation 2.0 API to create a task for image moderation. For more information about how to construct an HTTP request, see Image Moderation 2.0 SDKs and usage guide. You can also select an existing HTTP request. For more information, see Image Moderation 2.0 SDKs and usage guide.

  • Operation: ImageModeration

  • Billing: You are charged for calling this operation. You are charged by using the pay-as-you-go billing method only for requests whose HTTP status code is 200. For more information about the billing method, see Billing method.

  • Limits on images

    • The images must be in PNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, HEIC (the longest side is less than 8192 pixels), GIF (extract the first frame), or ICO (extract the last layer) format.

    • The maximum size of an image is limited to 20 MB, the height or width cannot exceed 16,384 pixels, and the total pixels must not exceed 250 million pixels. We recommend that you submit images with a minimum resolution of 200 × 200 pixels to ensure that the results of Content Moderation detection algorithms are not affected.

    • The maximum download duration for an image is 3 seconds. If an image fails to be downloaded within 3 seconds, a timeout error is returned.

QPS limit

You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. If you require a higher queries per second (QPS) to meet business requirements or urgent scaling requirements, contact your customer business manager (CBM).

Debugging

Before you deploy SDKs, you can use Alibaba Cloud OpenAPI Explorer to debug the Image Moderation 2.0 API online and view the sample code for the call and SDK dependencies. This way, you can understand how to call the API and how to set related parameters.

Important

Before you call the Content Moderation API, you must log on to the Content Moderation console by using your Alibaba Cloud account. Therefore, the fees incurred by calling the operations are billed to the account.

Request parameters

For more information about the common request parameters that must be included in all Content Moderation API requests, see Image Moderation 2.0 SDKs and usage guide.

The request body is a JSON structure. The following table describes the parameters that are contained in the request body.

Parameter

Type

Required

Example

Description

Service

String

Yes

aigcDetector

The moderation service. Valid values:

  • aigcDetector_global: AI-generated image identification

ServiceParameters

JSONString

Yes

The parameters related to the content moderation object. The values are JSON strings. For more information about the description of each string, see Table 1. ServiceParameters.

Table 1. ServiceParameters

Parameter

Type

Required

Example

Description

imageUrl

String

Yes. Image Moderation 2.0 supports three image upload methods:

  • Submit the URL of an image, imageUrl, for image moderation.

  • Obtain Object Storage Service (OSS) authorization and submit the ossBucketName, ossObjectName, and ossRegionId of an image for image moderation.

  • Submit a local image file for image moderation. This method does not occupy your OSS storage space. The image file is stored only for 30 minutes. SDKs are integrated with the feature of uploading local images. For more information about the sample code, see Image Moderation 2.0 SDKs and usage guide.

https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png

The URL of the object that you want to moderate. Make sure that the URL can be accessed over the Internet and that the URL cannot exceed 2,048 characters in length.

Note The URL cannot contain Chinese characters. Make sure that you specify only one URL in each request.

ossBucketName

String

bucket_01

The name of the OSS bucket that has been authorized.

Note

Before you submit the internal endpoint of an image in an OSS bucket, you must use your Alibaba Cloud account to access the Cloud Resource Access Authorization page to grant the permissions to access the OSS bucket.

ossObjectName

String

2022023/04/24/test.jpg

The name of the object in the authorized OSS bucket.

ossRegionId

String

cn-beijing

The region of the OSS bucket.

dataId

String

No

img123****

The ID of the object that you want to moderate.

The ID can contain uppercase letters, lowercase letters, digits, underscores (_), hyphens (-), and periods (.). The ID can be up to 64 characters in length and uniquely identifies your business data.

referer

String

No

www.aliyun.com

The referer request header, which is used in scenarios such as hotlink protection. The value can be up to 256 characters in length.

Response parameters

Parameter

Type

Example

Description

RequestId

String

70ED13B0-BC22-576D-9CCF-1CC12FEAC477

The request ID, which is used to locate and troubleshoot issues.

Data

Object

The result of image moderation. For more information, see Table 2. Data.

Code

Integer

200

The returned HTTP status code. For more information, see Response codes.

Msg

String

OK

The message that is returned in the response.

Table 2. Data

Parameter

Type

Example

Description

Result

Array

The results of image moderation parameters such as the label parameter and the confidence parameter. For more information, see Table 3. Result.

RiskLevel

String

high

The risk level, which is returned based on the configured risk scores. Valid values:

  • high

  • medium

  • low

  • none

Note

The following handling suggestions are recommended: Customers handle high-risk content directly. Manual review should be performed on medium-risk content. Low-risk content can be handled when more risky content is detected. Customers can handle the content on which no risk is detected based on their business requirements. Risk scores can be configured in the Content Moderation console.

DataId

String

img123******

The ID of the moderated object.

Note

If you specify the dataId parameter in the request, the value of the dataId parameter is returned in the response.

Table 3. Result

Parameter

Type

Example

Description

Label

String

tm_auto

The labels returned after the image moderation. Multiple risk labels and the corresponding scores of confidence levels may be returned for an image. For more information about supported labels, see:

Confidence

Float

81.22

The score of the confidence level. Valid values: 0 to 100. The value is accurate to two decimal places. Some labels do not have scores of confidence levels. For more information, see Descriptions of risk labels.

Examples

Sample requests

{
    "Service": "aigcDetector_global",
    "ServiceParameters": {
        "imageUrl": "https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png",
        "dataId": "img123****"
    }
}

Sample output

{
    "Msg": "OK",
    "Code": 200,
    "Data": {
        "DataId": "img123****",
        "Result": [
            {
                "Label": "aigc",
                "Confidence": 81.88
            }
        ]
    },
    "RequestId": "ABCD1234-1234-1234-1234-1234XYZ"
}
Note

The sample requests and responses in this topic are formatted to improve readability. Actual responses are not formatted with line breaks or indentation.

Descriptions of risk labels

The following table describes the values of risk labels, the corresponding scores of confidence levels, and the definitions of the risk labels. You can configure each risk label in the Content Moderation console. You can also configure more specific moderation scopes for some risk labels. For more information, see Console guide.

Note

We recommend that you store risk labels and scores of confidence levels returned by the system within a specified period of time. You can use the stored data as a reference for subsequent content governance. You can set the priority of manual review, the priority of annotations, or content governance measures of hierarchical classification based on the risk labels.

Table 4. Labels supported by AI-generated image identification (aigcDetector_global)

Label value

Score of the confidence level

Definition

aigc

Valid values: 0 to 100. A higher score indicates a higher confidence level.

The image is suspected to be generated by AI.

ugc

Valid values: 0 to 100. A higher score indicates a higher confidence level.

The image is not generated by AI.

Response codes

The following table describes the response codes. You are charged by using the pay-as-you-go billing method only for requests whose response code is 200.

Code

Description

200

The request is successful.

400

Not all request parameters are configured.

401

The values specified for one or more request parameters are invalid.

402

Invalid request parameters. Check and modify them and try again.

403

The QPS of requests exceeds the upper limit. Check and modify the number of requests that are sent at a time.

404

The specified image failed to be downloaded. Check the URL of the image or try again.

405

Downloading the specified image timed out. The possible cause is that the image cannot be accessed. Check and adjust the image and try again.

406

The specified image is excessively large. Check and change the image size and try again.

407

The format of the specified image is not supported. Check and change the image format and try again.

408

You do not have the required permissions. The possible cause is that this account is not activated, has overdue payments, or is not authorized to call this API operation.

500

A system exception occurred.