Image Tag
Image Tagging identifies image tags for existing data in cloud storage, returns high-confidence topic tags in the images, and helps developers analyze images.
Features
Identify scenes, objects, people, and other information in images, such as natural landscapes (mountains, sea, sky, sunset, etc.), man-made environments (buildings, playgrounds, conference rooms, etc.), portraits (men, women, selfies, group photos, etc.), objects (food, clothing, daily necessities, etc.), and animals (cats, dogs, birds, mammals, marine life, and other pets or wild animals).
Applicable Scenarios
It can be used for various scenarios such as photo album categorization, content recommendation in feeds, advertising recommendations, categorized search in image libraries, video content understanding, and image recognition via camera.
!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: QcloudAccessForTCBRole Description: Access permissions for CloudBase (TCB) to cloud resources.
- 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: DetectLabel |
cloudPath | String | Yes | Absolute path of the file, same as in tcb.uploadFile |
Response
Parameter Name | Type | Description |
---|---|---|
RecognitionResult | Object | Image tag recognition result |
RecognitionResult node content:
Parameter Name | Type | Description |
---|---|---|
Labels | Object | Label information |
Label information contains the following:
Parameter Name | Type | Description |
---|---|---|
Confidence | Int | Confidence score of the label; higher scores indicate higher accuracy. |
Name | String | Identified image labels |
Invoke Example
Usage in Client:
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 res = await app.invokeExtension("CloudInfinite", {
action: "DetectLabel",
cloudPath: "demo.png" // Absolute path of the image to be analyzed, same as in tcb.uploadFile
});
console.log(JSON.stringify(res.data, null, 4));
} catch (err) {
console.log(JSON.stringify(err, null, 4));
}
}