هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Scalable File Service Turbo
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Image Moderation (V2)

Updated on 2024-11-04 GMT+08:00

Function

This API analyzes and identifies whether the uploaded images contain pornographic elements or terrorism-related content, and returns the result to you.

NOTE:
  1. By default, the maximum number of concurrent API calls is 10. To increase concurrency, contact Huawei technical support.
  2. You can configure moderation rules to detect pornographic content in different scenarios. For details, see Configuring Moderation Rules.

URI

POST /v2/{project_id}/moderation/image

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.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

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.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

url

No

String

Configure either this parameter or image.

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:

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.

image

No

String

Configure either this parameter or url.

Indicates the Base64 character string converted from the image. The size cannot exceed 10 MB.

The supported image formats include JPEG, PNG, BMP, WEBP, and GIF.

moderation_rule

No

String

Indicates the name of the moderation rule. The default rule is used by default.

NOTE:

For details about how to create and use moderation rules, see Configuring Moderation Rules.

categories

No

Array of strings

Indicates the detection scenario. The following scenarios are supported:

  • porn: pornographic elements

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

Float

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:
  1. If the maximum confidence score of a specific detection scenario is smaller than the value of threshold, the detail list is empty. If the value of threshold is too small, too many results are displayed in the detail list.
  2. The threshold parameter does not support filtering of the porn scenario.
  3. The threshold parameter does not affect the suggestion in the response.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

result

ImageDetectionResultBody object

Indicates the calling result of a successful API call.

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

Table 5 ImageDetectionResultBody parameters

Parameter

Type

Description

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 detail list is empty.

suggestion

String

Indicates whether the check is passed.

  • 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.
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 included. 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 calling results (such as historical block information). You are advised to retain the logs of API calling results.

category_suggestions

Map<String,String>

Indicates the check result of each scenario. Available 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.
NOTE:

This service does not save your API calling results.

Table 6 ImageDetectionResultDetail parameters

Parameter

Type

Description

porn

Array of ImageDetectionResultSimpleDetail objects

Indicates that pornographic content was detected.

Table 7 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:

In the porn scenario, label indicates pornographic elements (porn information or suggestive content).

  • The porn scenario supports the following labels:
    • normal: The uploaded image does not contain pornography.
    • porn: The image contains porn information.
    • sexy: The image contains suggestive content.

Status code: 400

Table 8 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

NOTE:

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, and project_id is the project ID. For details, see Obtaining a Project ID and Name.

  • Method 1: Use the Base64 code of an uploaded image to check whether the image contains pornographic content. Use the default moderation rule.
    POST https://{endpoint}/v2/{project_id}/moderation/image
    
    {
      "categories" : [ "porn" ],
      "moderation_rule" : "default",
      "url" : "",
      "image" : "/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA...",
      "threshold" : ""
    }
  • Method 2: Use the URL of an uploaded image to check whether the image contains pornographic content. Use the default moderation rule.
    POST https://{endpoint}/v2/{project_id}/moderation/image
    
    {
      "categories" : [ "porn"],
      "moderation_rule" : "default",
      "url" : "https://BucketName.obs.myhuaweicloud.com/ObjectName",
      "image" : "",
      "threshold" : ""
    }

Example Responses

Status code: 200

Example of a successful response

{
    "result": {
        "detail": {
            "porn": [
                {
                    "confidence": 0.7315528178215026,
                    "label": "xxx"
                },
                {
                    "confidence": 0.26844718217849733,
                    "label": "yyy"
                }
            ]
        },
        "suggestion": "block",
        "category_suggestions": {
            "porn": "review"
        }
    }
}

Status code: 400

Example of a 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

Error Codes

For details, see Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback