Image Moderation
Image Moderation provides sensitive content moderation services such as pornography detection, political content detection, and violent and terrorist content detection, effectively identifying prohibited images and mitigating compliance risks.
Features
Moderation Type | Description |
---|---|
Pornography Detection | Detects pornographic and suggestive content, effectively reducing manual review costs, suitable for various social platforms and instant messaging applications, and helps platforms avoid pornography-related risks |
Violence and Terrorism Detection | Identifies terrorists, cult organizations, firearms and ammunition, bloody violence, and other terrorist content in images, helping platforms avoid legal risks |
Political Content Detection | Detects politically sensitive content in images through technologies like facial recognition and image generalization, helping platforms promptly comply with legal requirements and mitigate public opinion risks |
Ad Detection | Identifies ad-guiding images to help platforms block advertising information |
!You can use this extension capability not only in Cloud Functions but also on the client side. The file read-write permission policies are consistent with Cloud Storage, reducing your additional permission management efforts.
Prerequisites
CloudBase has been provisioned.
Extension Configuration Information
You can configure the following parameters:
- Environment ID: Select the environment to deploy to, specifying where it will be used.
Billing
This extension uses CloudBase or other Tencent Cloud services, which may incur relevant fees:
- Cloud Infinite (Product Pricing and Usage Details).
- Cloud Storage (Product Pricing and Usage Details).
- Cloud Function (Product Pricing and Usage Details).
When using CloudBase extensions, you only pay for the cloud resources you consume; CloudBase is billed separately from other cloud resources. You can view detailed information in the Billing Center.
Enabled APIs and Created Resources
- Type: Cloud Infinite Description: Provides developers with intelligent processing services for images, videos, and other types of data.
- Type: Cloud Storage Description: Storing images and improving their loading speed via CDN.
- Type: Cloud Function Description: Detects image processing parameters and generates signatures for image processing to ensure the legitimacy of operations.
Permission Granting
Primary Account
Role Name | Authorization Policy Name | Role Type | Description |
---|---|---|---|
CI_QCSRole | QcloudAccessForCIRole, QcloudCOSDataFullControl | Service Role | Cloud Infinite (CI) will access your Tencent Cloud resources, including reading, modifying, deleting, listing, etc. of COS data. |
TCB_QcsRole | QcloudCIFullAccess | Service Role | CloudBase (TCB) will operate on your Cloud Infinite (CI) resources to facilitate your use of this service in extension capabilities. |
Sub-account
If you want a sub-account to be able to use this extension, you need to grant the following permissions to the sub-account:
- Policy: QcloudTCBFullAccess Description: Full read-write access permissions for CloudBase.
- Policy: QcloudCIFullAccess Description: Full read-write access permissions for Cloud Infinite (CI).
Install Extension
You can install and manage extensions via the CloudBase Console.
Use Extension
! If you use this extension on a web website, first add the website domain as a security domain for the current environment in the CloudBase Console.
1. Install the extension SDK to your project
npm install --save @cloudbase/extension-ci@latest
2. Invoke the extension SDK
Invocation Parameters
Name | Type | Required | Description |
---|---|---|---|
action | String | Yes | Operation type, pass: DetectType |
cloudPath | String | Yes | Absolute path of the file, same as in tcb.uploadFile |
operations | Object | Yes | Processing parameters. |
operations node content
Name | Type | Required | Description |
---|---|---|---|
type | String | Yes | Audit types supported: porn (pornography detection), terrorist (terrorist content detection), politics (politically sensitive content detection), ads (advertising detection). Multiple detection types can be selected, e.g., porn, ads |
Response
Parameter Name | Type | Description |
---|---|---|
RecognitionResult | Object | Content recognition result |
RecognitionResult node content:
Parameter Name | Type | Description |
---|---|---|
PornInfo | Object | Pornography moderation information |
TerroristInfo | Object | Terrorist content moderation information |
PoliticsInfo | Object | Politically sensitive content moderation information |
AdsInfo | Object | Advertising moderation information |
The moderation information (PornInfo, TerroristInfo, PoliticsInfo, AdsInfo) contains the following content:
Parameter Name | Type | Description |
---|---|---|
Code | Int | Error code. 0 indicates success, other numbers correspond to specific errors. For details, see Error Codes |
HitFlag | Int | Hit status: 0 (not hit), 1 (hit), 2 (suspected) |
Score | Int | Moderation score: 0-60 (normal), 60-90 (suspected sensitive), 90-100 (confirmed sensitive) |
Label | String | Identified image labels |
Invoke Example
Client Usage:
const extCi = require("@cloudbase/extension-ci");
const tcb = require("@cloudbase/js-sdk");
Usage in Cloud Functions:
const extCi = require("@cloudbase/extension-ci");
const tcb = require("@cloudbase/node-sdk");
You can choose to use it in [client] or [cloud functions] as needed, and then invoke it with the following code:
const app = tcb.init({
env: "Your Environment ID"
});
app.registerExtension(extCi);
async function demo() {
try {
const opts = {
type: "porn"
};
const res = await app.invokeExtension("CloudInfinite", {
action: "DetectType",
cloudPath: "ab.png", // Absolute path of the image to be analyzed, same as in tcb.uploadFile
operations: opts
});
console.log(JSON.stringify(res.data, null, 4));
} catch (err) {
console.log(JSON.stringify(err, null, 4));
}
}