tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Image Moderation

PDF
Focus Mode
Font Size
Last updated: 2024-02-04 17:20:25

Overview

This document describes how to use the content moderation feature provided by Cloud Infinite (CI). CI fully integrates the processing capabilities with the COS SDK.
Note:
To use the content moderation service, you need to have the permission to use CI:
For root accounts, click here for role authorization.
This document provides an overview of APIs and SDK code samples for image moderation.
Note:
The COS Mini Program SDK version should be or later than v1.1.1.
API
Description
Scans existing data stored in COS for pornographic, illegal, and advertising images.
Moderates multiple images in batches.

Single Image Moderation

Feature description

The existing data scan feature of image moderation leverages CI's persistent processing API to scan existing data stored in COS for pornographic, illegal, and advertising images.

Sample code

var config = {
// Replace with your own bucket information
Bucket: 'examplebucket-1250000000', /* Bucket. Required */
Region: 'COS_REGION', /* Bucket region. Required */
};
function getImageAuditing() {
cos.request({
Bucket: config.Bucket,
Region: config.Region,
Method: 'GET',
Key: '1.png', /* Image file in the bucket (required) */
Query: {
'ci-process': 'sensitive-content-recognition', /** Fixed value (required) */
'biz-type': '', /** Moderation type (optional) */
'detect-type': 'porn,ads', /** Moderation policy (optional). If this parameter is not specified, the default policy will be used. */
'detect-url': '', /** URL of any image accessible over the public network (optional) */
'interval': 5, /** Frame capturing interval for GIF image moderation (optional) */
'max-frames': 5, /** Maximum number of frames to be captured for GIF image moderation (optional) */
'large-image-detect': '0', /** Whether to compress the image first before moderation (optional) */
'dataid': '123', /** Custom image ID (optional) */
},
},
function(err, data){
console.log(err || data);
});
}

Parameter description

Query has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
biz-type
Query
Moderation policy. If this parameter is not specified, the default policy will be used. The policy can be configured in the console. For more information, see Setting Moderation Policy.
String
No
detect-type
Query
Moderation type. Valid values: porn, ads. You can specify multiple types and separate them by comma.
String
No
object-key
Query
Location of the image in the bucket.
String
Yes
detect-url
Query
You can enter a detect-url value to moderate an image accessible over the public network.
If detect-url is not specified, the backend will moderate by ObjectKey by default.
If detect-url is specified, the backend will moderate by detect-url, and there is no need to enter ObjectKey. Sample detect-url: http://www.example.com/abc.jpg.
String
No
interval
Query
For GIF image moderation, you can use this parameter to configure the frame capturing interval. The default value is 5, indicating to capture a frame every five frames starting from the first frame (included).
Int
No
max-frames
Query
The maximum number of frames to be captured for GIF image moderation, which must be greater than 0. The default value is 5, indicating to capture five frames at most.
Int
No
large-image-detect
Query
Whether to compress the image that exceeds the size limit before moderation. Valid values: 0 (no), 1 (yes). Default value: 0.
Note: Images up to 32 MB in size can be compressed, and compression fees will be charged.
String
No
dataid
Query
Image ID. This field will return the original content in the result, which can contain up to 512 bytes.
String
No

Response description

For more information, see Single Image Moderation.

Batch Image Moderation

Feature description

The batch image moderation API adopts a sync POST request method. You can use this API to perform content moderation on multiple image files.

Sample request

var config = {
// Replace with your own bucket information
Bucket: 'examplebucket-1250000000', /* Bucket. Required */
Region: 'COS_REGION', /* Bucket region. Required */
};
function postImagesAuditing() {
var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
var url = 'https://' + host + '/image/auditing';
var body = COS.util.json2xml({
Request: {
Input: [{
Object: '1.png', /* Path of the image to be moderated in the bucket */
}, {
Object: 'a/6.png', /* Path of the image to be moderated in the bucket */
}],
Conf: {
BizType: '', /* If this parameter is not specified, the default policy will be used. */
DetectType: 'Porn' /* Checks for pornographic information only */
}
}
});
cos.request({
Bucket: config.Bucket,
Region: config.Region,
Method: 'POST',
Url: url,
Key: '/image/auditing', /** Fixed value (required) */
ContentType: 'application/xml', /** Fixed value (required) */
Body: body
},
function(err, data){
console.log(err || data);
});
}

Parameter description

request has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Request
None
Batch image moderation configuration.
Container
Yes
Request has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Input
Request
Content to be moderated. If there are multiple images, pass in multiple Input structures.
Container Array
Yes
Conf
Request
Moderation rule configuration.
Container
Yes
Input has the following sub-nodes, and you need to use only one of these sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Object
Request.Input
Name of the image file stored in the COS bucket; for example, if the file is image.jpg in the test directory, then the filename is test/image.jpg. Either Object or Url can be selected at a time.
String
No
Url
Request.Input
Full URL of the image file, such as http://a-1250000.cos.ap-shanghai.myqcloud.com/image.jpg. Either Object or Url can be selected at a time.
String
No
Interval
Request.Input
Frame capturing frequency, which takes effect for GIF images only. The default value is 5, indicating to capture a frame every five frames starting from the first frame (included).
Int
No
MaxFrames
Request.Input
The maximum number of frames to be captured, which takes effect for GIF images only. The default value is 5, indicating to capture only five frames of the GIF image for moderation. The parameter value must be greater than 0.
Int
No
DataId
Request.Input
Image ID. This field will return the original content in the result, which can contain up to 512 bytes.
String
No
Conf has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
DetectType
Request.Conf
The scene to be moderated, such as Porn (pornography) and Ads (advertising). You can pass in multiple types and separate them by comma, such as Porn,Ads.
String
Yes
BizType
Request.Conf
Moderation policy. If this parameter is not specified, the default policy will be used. The policy can be configured in the console. For more information, see Setting Moderation Policy.
String
No
Note:
Moderation through Object is a private network operation and will not generate public network traffic.
Moderation through Url will generate public network traffic with regard to the origin where the image resides.

Response description

For more information, see Batch Image Moderation.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback