Image Moderation (V3)
Function
This API analyzes and identifies whether the uploaded images contain pornographic elements or terrorism-related content, and returns the result to you.
URI
POST /v3/{project_id}/moderation/image
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 |
User token It is used to obtain the permission to call APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token. |
Enterprise-Project-Id |
No |
String |
Enterprise project ID. Moderation allows you to use Enterprise Project Management Service (EPS) to split fees for resources used by different user groups and users. To obtain the enterprise project ID, go to the Enterprise Project Management console, click the enterprise project name, and obtain the enterprise project ID on the enterprise project details page. For how to create an enterprise project, see Content Moderation User Guide. After an enterprise project is created, parameter transfer involves the following scenarios:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
event_type |
No |
String |
Event type. The options are as follows:
NOTE:
|
categories |
No |
Array of strings |
Detection scenario. The following scenarios are supported:
You can set the parameter to any of the preceding values to check for the corresponding elements.
NOTE:
The number of detection times in each scenario is calculated by category. |
url |
No |
String |
Configure either this parameter or image. Image URL. Internet HTTP and HTTPS URLs are supported. |
image |
No |
String |
Configure either this parameter or url. Base64-encoded string of the image file, which cannot be larger than 10 MB. The image cannot exceed 20 x 20 pixels. JPG, PNG, JPEG, WEBP, GIF, TIFF, TIF, and HEIF formats are supported. |
language |
No |
String |
Language of the text in the image, which can be Chinese (zh), English (en), or Arabic (ar). The default value is zh. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
request_id |
String |
Unique ID of the request, which is used for troubleshooting. You are advised to save the ID. Minimum length: 2 Maximum length: 64 |
result |
ImageDetectionResult object |
Calling result of a successful API call. This parameter is not included when the API fails to be called. |
Parameter |
Type |
Description |
---|---|---|
suggestion |
String |
Whether the image passes the check
|
category |
String |
Level-1 label of the detection result. The following categories are supported:
|
details |
Array of ImageDetectionResultDetail objects |
Detection details |
Parameter |
Type |
Description |
---|---|---|
suggestion |
String |
Whether the image passes the check
|
category |
String |
Level-1 label of the detection result. The following categories are supported:
|
confidence |
Float |
Confidence. The value ranges from 0 to 1. A larger value indicates a higher confidence. |
face_location |
FaceLocationDetail object |
Face location. It is an array that has four values, indicating the coordinates of the upper left corner and lower right corner, respectively. For example, in the value [207,522,340,567], 207 indicates the horizontal coordinate of the upper left corner, 522 indicates the vertical coordinate of the upper left corner, 340 indicates the horizontal coordinate of the lower right corner, and 567 indicates the vertical coordinate of the lower right corner. |
label |
String |
Detected label |
Parameter |
Type |
Description |
---|---|---|
top_left_x |
Integer |
Horizontal coordinate of the upper left corner of detected face |
top_left_y |
Integer |
Vertical coordinate of the upper left corner of detected face |
bottom_right_x |
Integer |
Horizontal coordinate of the lower right corner of detected face |
bottom_right_y |
Integer |
Vertical coordinate of the lower right corner of detected face |
Parameter |
Type |
Description |
---|---|---|
top_left_x |
Integer |
Horizontal coordinate of the upper left corner of the detected QR code |
top_left_y |
Integer |
Vertical coordinate of the upper left corner of the detected QR code |
bottom_right_x |
Integer |
Horizontal coordinate of the lower right corner of the detected QR code |
bottom_right_y |
Integer |
Vertical coordinate of the lower right corner of the detected QR code |
Parameter |
Type |
Description |
---|---|---|
segment |
String |
Hit risk segment |
glossary_name |
String |
Name of the hit custom word dictionary. This field is returned only when a custom word dictionary is hit. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code of a failed API call. For details, see Error Codes. This parameter is not included when the API is successfully called. Minimum length: 8 Maximum length: 36 |
error_msg |
String |
Error message of a failed API call. This parameter is not included when the API is successfully called. Minimum length: 2 Maximum length: 512 |
Example Request
endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.
For example, if the service is deployed in the CN North-Beijing4 region, the endpoint is moderation.cn-north-4.myhuaweicloud.com and the request URL is https://moderation.cn-north-4.myhuaweicloud.com/v3/{project_id}/moderation/image. For details about how to obtain the project ID, see Obtaining a Project ID.
- Use the Base64 code of an image to check whether the image contains sensitive information. Set event_type to head_image and categories to porn and terrorism.
POST https://{endpoint}/v3/{project_id}/moderation/image { "event_type" : "head_image", "image" : "/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA...", "categories" : [ "porn", "terrorism" ] }
- Use the URL an image to check whether the image contains sensitive information. Set event_type to head_image and categories to porn and terrorism.
POST https://{endpoint}/v3/{project_id}/moderation/image { "event_type" : "head_image", "url" : "https://bucketname.obs.myhwclouds.com/ObjectName1", "categories" : [ "porn", "terrorism" ] }
Example Response
Status code: 200
Example successful response
{ "request_id" : "53f9719c3730d1169e47403d5c8a9473", "result" : { "category" : "porn", "details" : [ { "category" : "porn", "confidence" : 0.9934315, "label" : "sexy_female", "suggestion" : "review" }, { "category" : "porn", "confidence" : 0.99798274, "label" : "intimacy", "suggestion" : "review" } ], "suggestion" : "review" } }
Status code: 400
Example failed response
{ "error_code" : "AIS.0402", "error_msg" : "The image format is not supported." }
Status Codes
Status Code |
Description |
---|---|
200 |
Example of a successful response |
400 |
Example of a failed response |
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