Skip to main content

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:

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 NameAuthorization Policy NameRole TypeDescription
CI_QCSRoleQcloudAccessForCIRole, QcloudCOSDataFullControlService RoleCloud Infinite (CI) will access your Tencent Cloud resources, including reading, modifying, deleting, listing, etc. of COS data.
TCB_QcsRoleQcloudCIFullAccessService RoleCloudBase (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

NameTypeRequiredDescription
actionStringYesOperation type, pass: DetectLabel
cloudPathStringYesAbsolute path of the file, same as in tcb.uploadFile

Response

Parameter NameTypeDescription
RecognitionResultObjectImage tag recognition result

RecognitionResult node content:

Parameter NameTypeDescription
LabelsObjectLabel information

Label information contains the following:

Parameter NameTypeDescription
ConfidenceIntConfidence score of the label; higher scores indicate higher accuracy.
NameStringIdentified 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));
}
}