Domain name for API request: ims.intl.tencentcloudapi.com.
This API is used to submit an image for smart moderation. Before using it, you need to log in to the console with the Tencent Cloud root account to activate IMS and adjust the business configuration.
The version described on this page is 2020. The IMS APIs connected to before November 3, 2020 are on v2019, and you can directly access the following URL to perform maintenance operations: IMS APIs v2019
v2020 is an upgrade to v2019 to support more flexible multi-scenario business policy configuration and richer recognition callback information, meeting the recognition requirements of different businesses. We recommend you upgrade the APIs according to the v2020 connection guide. Meanwhile, we will continue to maintain v2019 until users no longer use it.
A maximum of 100 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: ImageModeration. |
Version | Yes | String | Common Params. The value used for this API: 2020-12-29. |
Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-mumbai, ap-singapore, eu-frankfurt. |
BizType | No | String | This field indicates the specific number of the policy, which is used for API scheduling and can be configured in the CMS console. If the Biztype parameter is passed in, a moderation policy will be used based on the business scenario; otherwise, the default moderation policy will be used.Note: Biztype can contain 3-32 digits, letters, and underscores; different Biztype values are associated with different business scenarios and moderation policies, so you need to verify the Biztype before calling this API. |
DataId | No | String | This field indicates the data ID assigned by you to the object to be detected for easier file identification and management. It can contain up to 64 letters, digits, and special symbols (_-@#). |
FileContent | No | String | This field indicates the Base64 encoding of the image to be detected. The image size cannot exceed 5 MB. A resolution of 256x256 or higher is recommended; otherwise, the recognition effect may be affected. Note: you must enter a value for either this field or FileUrl . |
FileUrl | No | String | URL of the image to moderate. It supports PNG, JPG, JPEG, BMP, GIF AND WEBP files. The file cannot exceed 5 MB and the resolution should not below 256*246. The default timeout period is 3 seconds. Note that redirection URLs may be blocked by security policies. In this case, an error message will return. For example, if an HTTP request gets the 302 code, the error ResourceUnavailable.ImageDownloadError is returned. **Either FileUrl or FileContent must be specified. |
Interval | No | Integer | For GIF/long image detection only. This field indicates the GIF frame capturing frequency (the image interval for capturing a frame for detection). For long images, you should round the width:height ratio as the total number of images to be split. The default value is 0, where only the first frame of the GIF image will be detected, and the long image will not be split. Note: the Interval and MaxFrames parameters need to be used in combination; for example, if Interval is 3 and MaxFrames is 400 , the GIF/long image will be detected once every two frames for up to 400 frames. |
MaxFrames | No | Integer | For GIF/long image detection only. This field indicates the maximum number of frames that can be captured. The default value is 1, where only the first frame of the input GIF image will be detected, and the long image will not be split (which may cause a processing timeout). Note: the Interval and MaxFrames parameters need to be used in combination; for example, if Interval is 3 and MaxFrames is 400 , the GIF/long image will be detected once every two frames for up to 400 frames. |
User | No | User | This field indicates the information of the user that corresponds to the object to be detected. It can be passed in to identify the user involved in the violation. |
Device | No | Device | This field indicates the information of the device that corresponds to the object to be detected. It can be passed in to identify the device involved in the violation. |
Parameter Name | Type | Description |
---|---|---|
Suggestion | String | This field is used to return the operation suggestion for the Label tag. When you get the determination result, the returned value indicates the operation suggested by the system. We recommend you handle different types of violations and suggestions according to your business needs. Returned values: Block, Review, Pass. |
Label | String | This field is used to return the maliciousness tag with the highest priority in the detection result (LabelResults), which represents the moderation result suggested by the model. We recommend you handle different types of violations and suggestions according to your business needs. Returned values: Normal: normal; Porn: pornographic; Abuse: abusive; Ad: advertising; Custom: custom type of non-compliant content and other offensive, unsafe, or inappropriate types of content. |
SubLabel | String | This field is used to return the subtag name under the maliciousness tag with the highest priority hit by the detection result, such as Porn-SexBehavior. If no subtag is hit, an empty string will be returned. |
Score | Integer | Confidence score of the under the current label. Value range: 0 (the lowest confidence) to 100 (the highest confidence). For example, Porn 99 indicates that the image is highly likely to be pornographic, while Porn 0 indicates that the image is not pornographic. |
LabelResults | Array of LabelResult | This field is used to return the detailed recognition result for the maliciousness tag hit by the categorization model, such as porn, advertising, or any other offensive, unsafe, or inappropriate type of content. Note: this field may return null, indicating that no valid values can be obtained. |
ObjectResults | Array of ObjectResult | This field is used to return the detailed detection result of the object detection model, including the tag name hit by the content such as object, advertising logo, or QR code, tag score, coordinate information, scenario recognition result, and operation suggestion. For more information on the returned value, see the description of the ObjectResults data structure.Note: this field may return null, indicating that no valid values can be obtained. |
OcrResults | Array of OcrResult | This field is used to return the detailed text OCR result, including the text coordinate information, text recognition result, and operation suggestion. For more information on the returned value, see the description of the OcrResults data structure.Note: this field may return null, indicating that no valid values can be obtained. |
LibResults | Array of LibResult | This field is used to return the result of recognition based on image risk libraries (blocklist and allowlist). For more information on the returned value, see the description of the LibResults data structure.Note: currently, you cannot customize image risk libraries. Note: this field may return null, indicating that no valid values can be obtained. |
DataId | String | This field is used to return the DataId in the request parameters that correspond to the detected object. |
BizType | String | This field is used to return the BizType in the request parameters that correspond to the detected object. |
Extra | String | This field is used to return the additional information (Extra) configured based on your needs. If it is not configured, an empty value will be returned by default. Note: the returned information varies by customer or Biztype . If you need to configure this field, submit a ticket or contact the aftersales service for assistance.Note: this field may return null, indicating that no valid values can be obtained. |
FileMD5 | String | This field is used to return the MD5 checksum of the detected object for easier verification of the file integrity. |
RecognitionResults | Array of RecognitionResult | Image recognition result, including the hit tags, confidence and location. Note: This field may return null , indicating that no valid values can be obtained. |
RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
POST / HTTP/1.1
Host: ims.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ImageModeration
<common request parameters>
{
"BizType": "182600012300002017",
"DataId": "a61237dd-c2a0-43e7-a3da-d27022d39ba7",
"FileUrl": "https://cmstest-123.cos.ap-guangzhou.myqcloud.com/image.jpg"
}
{
"Response": {
"RequestId": "a61237dd-c2a0-43e7-a3da-d27022d39ba7",
"DataId": "a61237dd-c2a0-43e7-a3da-d27022d39ba7",
"BizType": "182600012300002017",
"Suggestion": "Block",
"FileMD5": "",
"Label": "Porn",
"SubLabel": "SexyBehavior",
"Score": 90,
"LabelResults": [
{
"Scene": "Porn",
"Suggestion": "Block",
"Label": "Porn",
"SubLabel": "SexyBehavior",
"Score": 90,
"Details": []
}
],
"ObjectResults": [
{
"Scene": "QrCode",
"Suggestion": "Block",
"Label": "Ad",
"SubLabel": "",
"Score": 100,
"Names": [
"QRCODE"
],
"Details": [
{
"Id": 0,
"Name": "QRCODE",
"Value": "https://test.com/test",
"SubLabel": "QRCODE",
"Score": 100,
"Location": {
"X": 155.01746,
"Y": 396.01746,
"Width": 769.9824,
"Height": 769.98254,
"Rotate": 0
}
}
]
}
],
"OcrResults": [],
"LibResults": [],
"RecognitionResults": [],
"Extra": ""
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
DryRunOperation | DryRun Operation. It means that the request would have succeeded, but the DryRun parameter was used. |
FailedOperation | The operation failed. |
InternalError | An internal error occurred. |
InternalError.InternalError | An internal error occurred. |
InvalidParameter | The parameter is incorrect. |
InvalidParameter.ImageAspectRatioTooLarge | |
InvalidParameter.ImageDataTooSmall | |
InvalidParameter.ImageSizeTooSmall | The image resolution is too low. |
InvalidParameter.InvalidImageContent | The image content is incorrect. |
InvalidParameter.InvalidParameter | The parameter is invalid. |
InvalidParameterValue | The parameter value is incorrect. |
InvalidParameterValue.EmptyImageContent | The image content parameter is empty. |
InvalidParameterValue.ImageSizeTooSmall | The image resolution is too low. |
InvalidParameterValue.InvalidContent | FileContent and FileUrl are empty. |
InvalidParameterValue.InvalidDataId | The DataId format is incorrect. |
InvalidParameterValue.InvalidFileContentSize | The image file content size is exceptional. |
InvalidParameterValue.InvalidImageContent | The image content is incorrect. |
InvalidParameterValue.InvalidParameter | The parameter value is incorrect. |
LimitExceeded | The quota limit is exceeded. |
MissingParameter | The parameter is missing. |
OperationDenied | The operation was denied. |
RequestLimitExceeded | The number of requests exceeds the frequency limit. |
ResourceInUse | The resource is in use. |
ResourceInsufficient | The resource is insufficient. |
ResourceNotFound | The resource does not exist. |
ResourceUnavailable | The resource is unavailable. |
ResourceUnavailable.ImageDownloadError | Image file download failed. |
ResourceUnavailable.InvalidImageContent | The image resource is incorrect. |
ResourceUnavailable.ModelCallFailed | |
ResourcesSoldOut | The resources have been sold out. |
UnauthorizedOperation | The operation is unauthorized. |
UnauthorizedOperation.Unauthorized | Operation not authorized/No valid package/The account is overdue |
UnknownParameter | The parameter is unknown. |
UnsupportedOperation | The operation is not supported. |
Was this page helpful?