Image Moderation (Batch) (V2)
Function
This API analyzes and identifies whether the uploaded images contain pornographic elements, and returns the result to you.
URI
POST /v2/{project_id}/moderation/image/batch
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Indicates the user token. Used to obtain the permission to operate APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
urls |
Yes |
Array of strings |
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 of strings |
Indicates the detection scenario. Possible values are as follows:
You can set the parameter to the preceding values to check the corresponding elements.
NOTE:
The number of detection times in each scenario is calculated by category. |
threshold |
No |
Double |
Indicates the threshold for filtering the detection results. Only the results whose confidence score is greater than or equal to the threshold are displayed in the detail list. The value ranges from 0 to 1. If this parameter is left unspecified, the default values of different scenarios are used. If there is no special requirement, do not pass this parameter, or leave this parameter unspecified as shown in the example request.
NOTE:
|
moderation_rule |
No |
String |
Indicates the name of the moderation rule. The default value is default.
NOTE:
For details about how to create and use moderation rules, see Configuring Moderation Rules. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
result |
Array of ImageBatchModerationResultBody objects |
Indicates the calling result of a successful API call. This parameter is not included when the API fails to be called. |
Parameter |
Type |
Description |
---|---|---|
url |
String |
Indicates the URL of an image. |
suggestion |
String |
Indicates whether the images pass the check.
NOTE:
|
detail |
ImageDetectionResultDetail object |
Indicates a list of detection results of a specific scenario. porn lists the detection results of pornographic elements. If the maximum confidence score of a specific detection scenario is smaller than the value of threshold, the list of detection results is empty. |
category_suggestions |
Object |
Indicates the check result of each scenario. Possible values are as follows:
|
Parameter |
Type |
Description |
---|---|---|
porn |
Array of ImageDetectionResultSimpleDetail objects |
Indicates that pornographic content was detected. |
Parameter |
Type |
Description |
---|---|---|
confidence |
Float |
Indicates the confidence score. The value ranges from 0 to 1. |
label |
String |
Indicates the label of each detection result. The options are as follows: In the porn scenario, label indicates pornographic elements (porn information or suggestive content).
|
Status code: 400
Parameter |
Type |
Description |
---|---|---|
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. |
fail_category |
String |
Indicates the API calling failure scenario when there are multiple scenarios. |
Example Requests
endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.
For example, the endpoint of the service deployed in the CN-Hong Kong region is moderation.ap-southeast-1.myhuaweicloud.com, the request URL is https://moderation.ap-southeast-1.myhuaweicloud.com/v3/{project_id}/moderation/image/batch, and project_id is the project ID. For details, see Obtaining a Project ID and Name.
Check whether an uploaded image contains pornographic or terrorism-related content.
POST https://{endpoint}/v2/{project_id}/moderation/image/batch { "urls" : [ "https://bucketname.obs.myhwclouds.com/ObjectName1", "https://bucketname.obs.myhwclouds.com/ObjectName2" ], "categories" : [ "terrorism", "porn" ], "threshold" : "" }
Example Responses
Status code: 200
Example of a successful response
{ "result": [ { "url": "https://bucketname.obs.myhwclouds.com/ObjectName1", "suggestion": "block", "category_suggestions": { "porn": "block" }, "detail": { "porn": [ { "confidence": 0, "label": "normal" }, { "confidence": 1, "label": "xxx" } ] } } ] }
Status code: 400
Example of a failed response
{ "error_code" : "AIS.0005", "error_msg" : "The service does not exist." }
Status Codes
Status Code |
Description |
---|---|
200 |
Example of a successful response |
400 |
Example of a failed response |
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot