Help Center > > API Reference> Moderation (Image)> Image Moderation (Batch)

Image Moderation (Batch)

Updated at: Mar 09, 2020 GMT+08:00

Function

This API analyzes and identifies whether the uploaded images contain political figures, pornographic elements, 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).

URI

URI format

POST /v1.0/moderation/image/batch

Request Message

Table 1 describes the request parameters.
Table 1 Request parameters

Parameter

Mandatory

Type

Description

urls

Yes

Array

Indicates the URL of an image. The options are as follows:

  • HTTP/HTTPS URLs on the public network
  • HUAWEI CLOUD OBS URLs. To use OBS data, authorization is required, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.
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 in Table 1.

threshold

No

Number

For details, see the threshold parameter in Table 1.

Response Message

Table 2 describes the response parameters.

Table 2 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 when the API fails to be called. For details, see Error Code.

This parameter is not included when the API is successfully called.

error_msg

String

Indicates the error message when the API fails to be called.

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.ap-southeast-1.myhuaweicloud.com/v1.0/moderation/image/batch
        
    Request Header:      
    Content-Type:application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    Request Body:
    {  
       "urls": ["https://bucketname.obs.myhwclouds.com/ObjectName1",
    "https://bucketname.obs.myhwclouds.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"
                  }]
            }
         }
         ]
      }

Status Code

  • Normal

    200

  • 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.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel