Updated on 2024-03-27 GMT+08:00

Result Query

Function

This API queries the result of a batch image moderation job. If the batch job is executed successfully, the detailed moderation result of each image is returned. The batch job will not fail upon the failure of a single image.

The jobs will be stored on the cloud for a maximum of 30 minutes. You are advised to perform a periodic query every 30 seconds after the batch job is submitted.

URI

GET /v2/{project_id}/moderation/image/batch

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

job_id

Yes

String

Indicates the job ID.

Request Parameters

Table 3 Request header 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.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

result

CheckResultResultBody object

Indicates the calling result of a successful API call.

This parameter is not included when the API fails to be called.

Table 5 CheckResultResultBody parameters

Parameter

Type

Description

job_id

String

Indicates the job ID.

status

String

Indicates the job status. Possible values are as follows:

  • created: indicates that a job is created.
  • running: indicates that a job is being processed.
  • finish: indicates that a job is completed.
  • failed: indicates that a job fails to be processed.

create_time

String

Indicates the time when a job is created, for example, 2018-01-02T15:03:04Z.

update_time

String

Indicates the time when a job is updated, for example, 2018-01-02T15:03:04Z.

items

Array of CheckResultItemsBody objects

Indicates the list of image moderation results.

Table 6 CheckResultItemsBody parameters

Parameter

Type

Description

url

String

Indicates the URL of an image.

suggestion

String

Indicates whether the images pass the check.

  • block: The images contain sensitive information and fail to pass the check.
  • pass: indicates that no sensitive information is detected and the information passes the check.
  • review: The images need to be manually reviewed.
NOTE:
  1. When multiple scenarios are detected at the same time, the value of suggestion is subject to the scenario where sensitive information is most likely to be contained. That is, if a block occurs in any scenario, the value of suggestion is block. If all scenarios pass the check, the value of suggestion is pass. In addition, if manual review is required in any scenario, the value of suggestion is review.
  2. This service does not save your API call results (such as historical block information). You are advised to retain the logs of API call results.

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

Map<String,String>

Indicates the check result of each scenario. Possible values are as follows:

  • block: indicates that sensitive information is detected and the information fails to pass the check.
  • pass: indicates that no sensitive information is detected and the information passes the check.
  • review: indicates that the image needs to be manually reviewed.

ocr_text

String

OCR recognition result

Table 7 ImageDetectionResultDetail parameters

Parameter

Type

Description

porn

Array of ImageDetectionResultSimpleDetail objects

Indicates that pornographic content was detected.

Table 8 ImageDetectionResultSimpleDetail parameters

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:

porn: The image contains porn information. label classifies pornographic elements (porn information or sexy information).

  • The porn scenario supports the following labels:
    • normal: The image does not contain pornographic elements.
    • porn: The image contains pornographic elements.
    • sexy: The image contains suggestive content.

Status code: 400

Table 9 Response body parameters

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/v2/{project_id}/moderation/image/batch?job_id={job_id}, project_id is the project ID, and job_id is the job ID returned by the API. For details, see Obtaining a Project ID.

GET https://{endpoint}/v2/{project_id}/moderation/image/batch?job_id={job_id}

Example Responses

Status code: 200

Example of a successful response

{
  "result" : {
    "job_id" : "44d93b70-db01-4f96-a618-2a79c964c4b2",
    "status" : "finish",
    "create_time" : "2018-01-02T15:03:04Z",
    "update_time" : "2018-01-02T15:03:04Z",
    "items" : [ {
      "url" : "https://obs-test-llg.obs.myhuaweicloud.com/terrorism",
      "suggestion" : "pass",
      "detail" : {
      }
    }, {
      "url" : "https://obs-test-llg.obs.myhuaweicloud.com/clarity-detect",
      "suggestion" : "pass",
      "detail" : {
      },
      "ocr_text" : "fdfefdfdfdfd"
    } ]
  }
}

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.