Image Moderation 2.0 of Alibaba Cloud Content Moderation provides an image detection service for scenarios involving AI-generated content (AIGC) and forgeries. This service lets you determine if an image is generated by AIGC. This topic describes the AIGC and forgery detection features of the Image Moderation service.
1. Use case
Content Moderation provides the following custom detection services for AIGC scenarios, such as text-to-image and image-to-image generation:
AIGC image detection: As technology advances, AI-generated images are becoming increasingly difficult to distinguish from user-generated images. In some business scenarios, you may need to identify which images are AI-generated. To meet this requirement, Content Moderation provides a feature that determines whether an image is AI-generated.
2. Service description
The AIGC and forgery detection capabilities of Image Moderation 2.0 support the following services:
Service | Detection content | Scenario |
Service name: AIGC image detection Service: aigcDetector_global | This service checks an input image to determine if it was likely generated by AIGC. | This service determines if an image is generated by AIGC. Use this service when you need to identify the source of an image. |
3. Detection capabilities
The AIGC image detection service determines whether an image is generated by AI. An AIGC or user-generated content (UGC) label is returned.
4. Billing
The AIGC and forgery detection service of Image Moderation 2.0 supports the pay-as-you-go billing methods.
Pay-as-you-go
After you activate the Image Moderation V2.0 service, the default billing method is pay-as-you-go. You are billed daily based on your actual usage. If you do not call the service, you are not charged.
Moderation type | Supported business scenarios (services) | Unit price |
General image moderation (image_standard) |
| USD 0.60 per 1,000 calls Note Each call to the AIGC-Generated Image Identification service is counted as one call. You are charged based on the actual number of calls. For example, if you call the AIGC-Generated Image Identification service 100 times, you are charged USD 0.06. |
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 field. For more information, see Bill Details.
5. Integration guide
Step 1: Activate the service
Go to 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. Fees are settled daily based on your actual usage. You are not charged if you do not call the service. After you call the API, the system automatically generates bills based on your usage. For more information, see Billing details.
Step 2: Grant permissions to a RAM user
Before you call API operations or use SDKs, you must grant permissions to a RAM user. You must create an AccessKey pair for your Alibaba Cloud account or the RAM user. When you call API operations, you must use the AccessKey pair to complete identity verification. To obtain an AccessKey pair, see Obtain an AccessKey pair.
Log on to the RAM console using your Alibaba Cloud account or as a RAM administrator.
Create a RAM user. For more information, see Create a RAM user.
Grant the AliyunYundunGreenWebFullAccess system policy to the RAM user. For more information, see Grant permissions to a RAM user. After you complete these configurations, you can call the Content Moderation API as the RAM user.
Step 3: Install and integrate an SDK
For more information, see Image Moderation 2.0 SDKs and usage guide. The following table lists the supported regions.
Region | Public endpoint | VPC endpoint | Supported services |
Singapore | https://green-cip.ap-southeast-1.aliyuncs.com | https://green-cip-vpc.ap-southeast-1.aliyuncs.com | aigcDetector_global |
US (Virginia) | green-cip.us-east-1.aliyuncs.com | green-cip-vpc.us-east-1.aliyuncs.com | |
US (Silicon Valley) | green-cip.us-west-1.aliyuncs.com | None | |
London | green-cip.eu-west-1.aliyuncs.com | None |
Step 4: Adjust image moderation rules (Optional)
In the Content Moderation console, you can adjust the detection rules for the image moderation service. You can toggle detection scopes, copy a service, configure custom image libraries and vocabularies, and query detection records and usage. For more information, see the Console Operation Guide.
6. API operations
Usage notes
You can call this API to create an image moderation task. For more information about how to construct an HTTP request, see the Access Guide. You can also use a pre-constructed HTTP request. For more information, see the Access Guide.
API operation: ImageModeration
Billing information: This is a paid operation. You are billed only for requests that return an HTTP status code of 200. Requests that return other error codes are not billed. For more information about billing methods, see the Billing overview.
Image requirements:
The following image formats are supported: PNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, HEIC (the longest side must be less than 8,192 pixels), GIF (only the first frame is processed), and ICO (only the last image is processed).
The image size cannot exceed 20 MB. The height or width cannot exceed 16,384 pixels, and the total number of pixels cannot exceed 250 million. We recommend that you use images with a resolution of at least 200 × 200 pixels to ensure the effectiveness of the detection algorithm.
The image download time is limited to 3 seconds. If the download takes longer than 3 seconds, a timeout error is returned.
QPS limits
The queries per second (QPS) limit for this API operation is 100 for each user. If you exceed this limit, API calls are throttled. This may affect your business. Call the operation at a reasonable rate. If you have a high workload, need to scale up urgently, and require a higher QPS limit, contact your business manager.
Debug
Before you start, you can use Alibaba Cloud OpenAPI Explorer to test the or Image Moderation 2.0 API online. You can also view sample code and SDK dependencies to understand how to use the API and its parameters.
The online debugging feature calls the Content Moderation API operation using the currently logged-on account. Therefore, the calls are included in your billable usage.
Request parameters
For information about the common parameters required in a request, see the Access Guide.
The request body is a JSON struct that contains the following fields:
Name | Type | Required | Example | Description |
Service | String | Yes | aigcDetector | The detection service. Valid values:
|
ServiceParameters | JSONString | Yes | A set of parameters for the content moderation object, provided as a JSON string. For a description of each string, see Table 1. ServiceParameters. |
Table 1. ServiceParameters
Name | Type | Required | Example | Description |
imageUrl | String | Yes. Image Moderation 2.0 supports three methods for uploading images:
| https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png | The URL of the object to detect. Make sure the URL is accessible over the public network and is no more than 2,048 characters long. Note The URL cannot contain Chinese characters. Make sure you submit only one URL per request. |
ossBucketName | String | bucket_01 | The name of the authorized OSS bucket. Note To use the internal URL of an OSS image, you must first use your Alibaba Cloud account to grant authorization on the Cloud Resource Access Authorization page. | |
ossObjectName | String | 2022023/04/24/test.jpg | The name of the file in the authorized OSS bucket. | |
ossRegionId | String | cn-beijing | The region where the OSS bucket is located. | |
dataId | String | No | img123**** | The data ID of the detection object. The ID can contain uppercase letters, lowercase letters, digits, underscores (_), hyphens (-), and periods (.). It can be up to 64 characters long and can be used to uniquely identify your business data. |
referer | String | No | www.aliyun.com | The referer request header, used for scenarios such as hotlink protection. The length cannot exceed 256 characters. |
Response parameters
Name | Type | Example | Description |
RequestId | String | 70ED13B0-BC22-576D-9CCF-1CC12FEAC477 | The ID of the current request. This is a unique identifier generated by Alibaba Cloud for the request and can be used for troubleshooting. |
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 response message for the current request. |
Table 2. Data
Name | Type | Example | Description |
Result | Array | The parameter results of image moderation, such as risk labels and confidence scores. For more information, see Table 3. result. | |
RiskLevel | String | high | The risk level, which is returned based on the configured high and low risk scores. Valid values:
Note It is recommended to handle high-risk content directly. Medium-risk content should be manually reviewed. Low-risk content should be handled only when high recall is required. Otherwise, treat it the same as content with no detected risk. You can configure risk scores in the Content Moderation console. |
DataId | String | img123****** | The data ID of the detection object. Note If you passed a dataId in the request parameters, the same dataId is returned here. |
Table 3. result
Name | Type | Example | Description |
Label | String | tm_auto | The label returned after image content detection. Multiple labels and scores may be returned for a single image. For supported labels, see: |
Confidence | Float | 81.22 | The confidence score ranges from 0 to 100 and is accurate to two decimal places. Some labels do not have a confidence score. For more information, see Descriptions of risk labels. |
Description | String | Fireworks and pyrotechnics | A description of the Label field. Important This field explains the Label field and is subject to change. It is recommended to handle results based on the Label field, not this field. |
Examples
Sample request
{
"Service": "aigcDetector_global",
"ServiceParameters": {
"imageUrl": "https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png",
"dataId": "img123****"
}
}Sample responses
{
"Msg": "OK",
"Code": 200,
"Data": {
"DataId": "img123****",
"Result": [
{
"Label": "aigc",
"Confidence": 81.88,
"Description": "Suspected to be generated by AIGC"
}
]
},
"RequestId": "ABCD1234-1234-1234-1234-1234XYZ"
}The sample requests and responses in this topic are formatted for readability. Actual responses are not formatted with line breaks or indentation.
Risk label descriptions
The following table lists the risk labels, their corresponding confidence scores, and their definitions. You can enable or disable each risk label in the Content Moderation console. For some risk labels, you can also configure more specific detection scopes. For more information, see the Console User Guide.
We recommend that you store the risk labels and confidence scores returned by the system for a certain period. This data can be used as a reference for future content governance. You can set priorities for manual review or annotation and implement tiered content governance measures based on the risk labels.
Table 6.Labels supported by AIGC-generated Image Identification (aigcDetector_global)
Label (label) | Confidence score range (confidence) | Meaning |
aigc | 0 to 100. A higher score indicates a higher confidence level. | The image is suspected to be generated by AIGC. |
ugc | 0 to 100. A higher score indicates a higher confidence level. | The image is not generated by AIGC. |
The ugc label is disabled by default. To enable it, you can configure the settings in the Content Moderation console. If no risk label is detected, the nonLabel label is returned.
Code descriptions
The following table describes the meanings of the returned codes. The system charges only for requests that return a code of 200. No fees are charged for other codes.
Code | Description |
200 | The request is successful. |
400 | A request parameter is empty. |
401 | A request parameter is invalid. |
402 | The length of a request parameter does not meet the requirements. Check and modify the parameter. |
403 | The number of requests exceeds the QPS limit. Check and adjust the concurrency. |
404 | An error occurred while downloading the specified image. Check the image or retry. |
405 | The download of the specified image timed out. This may be because the image is inaccessible. Check the image and retry. |
406 | The specified image is too large. Check and adjust the image size, then retry. |
407 | The format of the specified image is not supported. Check and adjust the image format, then retry. |
408 | The account does not have permission to call this API operation. This may be because the service is not activated, the account has an overdue payment, or the account is not authorized. |
500 | A system error occurred. |