Image Moderation (Batch)
Function
This API analyzes and identifies whether the uploaded images contain pornographic elements, political figures, or terrorism-related content, and returns the result to you.
Prerequisites
- Before using Text Moderation, you need to apply for the service and complete authentication. For details, see Getting Started with Moderation (Image).
- By default, the maximum number of concurrent API calls is 10. To increase concurrency, contact Huawei technical support.
URI
URI format
POST /v1.0/moderation/image/batch
Request Message
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| urls | Yes | Array | Indicates the URL of an image. The options are as follows:
NOTE: You can configure a maximum of 10 URLs. The API response time depends on the image download time. If the image download takes a long time, the API call will fail. Ensure that the storage service where the image to be detected resides is stable and reliable. You are advised to use HUAWEI CLOUD OBS. |
| categories | No | Array | For details, see the categories parameter description. |
| threshold | No | Number | For details, see the threshold parameter description. |
Response Message
Table 2 describes the response parameters.
| Parameter | Type | Description |
|---|---|---|
| result | Object | Indicates the calling result when the API is successfully called. This parameter is not included when the API fails to be called. |
| url | String | Indicates the URL of an image. |
| suggestion | String | For details, see the suggestion parameter in Table 2. |
| detail | Object | For details, see the detail parameter in Table 2. |
| confidence | Number | For details, see the confidence parameter in Table 2. |
| face_detail | List | For details, see the face_detail parameter in Table 2. |
| label | String | For details, see the label parameter in Table 2. |
| error_code | String | Indicates the error code of a failed API call. For details, see Error Codes. This parameter is not included when the API is successfully called. |
| error_msg | String | Indicates the error message of a failed API call. This parameter is not included when the API is successfully called. |
Examples
- Example request (Use the URLs redirecting to the image files.)
POST https://moderation.cn-north-1.myhuaweicloud.com/v1.0/moderation/image/batch Request Header: Content-Type:application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "urls": ["https://bucketname.obs.myhuaweicloud.com/ObjectName1", "https://bucketname.obs.myhuaweicloud.com/ObjectName2"], "categories":[ "politics", "terrorism", "porn"], "threshold" : "" }
- Example successful response
{ "result":[{ "url": "https://BucketName.obs.myhuaweicloud.com/ObjectName1", "suggestion": "block", "detail":{ "politics":[ { "confidence": 0.87563462432654422, "face_detail":{ "h": 131, "w": 203, "x": 423, "y": 109 }, "label": "yyy" }], "terrorism":[ { "confidence": 0.26844718217849736, "label": "yyy" }], "porn": [{ "confidence": 1, "label": "normal" }, { "confidence": 0, "label": "porn" }, { "confidence": 0, "label": "sexy" }] } }, { "url": "https://BucketName.obs.myhuaweicloud.com/ObjectName2", "suggestion": "review", "detail":{ "politics":[ { "confidence": 0.57563462432654422, "face_detail":{ "h": 131, "w": 203, "x": 423, "y": 109 }, "label": "xxx" }], "terrorism":[ { "confidence": 0.16844718217849736, "label": "xxx" }], "porn": [{ "confidence": 1, "label": "normal" }, { "confidence": 0, "label": "porn" }, { "confidence": 0, "label": "sexy" }] } } ] } - Example failed response
- Response upon a request failure
{ "error_code": "AIS.0005", "error_msg": "The service does not exist." } - Response upon the request failures of several URLs
{ "result":[{ "url": "https://BucketName.obs.myhuaweicloud.com/ObjectNotExist", "error_code": "AIS.0024", "error_msg": "Obtaining the file from the OBS failed. Forbidden" }, { "url": "https://BucketName.obs.myhuaweicloud.com/ObjectName2", "suggestion": "review", "detail":{ "politics":[ { "confidence": 0.57563462432654422, "face_detail":{ "h": 131, "w": 203, "x": 423, "y": 109 }, "label": "xxx" }], "terrorism":[ { "confidence": 0.16844718217849736, "label": "xxx" }], "porn": [{ "confidence": 1, "label": "normal" }, { "confidence": 0, "label": "porn" }, { "confidence": 0, "label": "sexy" }] } } ] }
- Response upon a request failure
- Abnormal
Return Value
Description
400
- The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
- The request parameter is incorrect.
401
The request requires user authentication.
403
No operation permission.
404
The server has not found anything matching the Request-URI.
500
The server encountered an unexpected condition which prevented it from fulfilling the request.
Last Article: Image Moderation
Next Article: Image Moderation (Asynchronous Batch)
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.