The image recognition feature uses AI to identify the tags and confidence levels of images.

Note To use the image recognition feature, you must activate Intelligent Media Management (IMM) and bind IMM to OSS. For more information, see Quick start.

Tags are arranged in a hierarchical structure under parent tags (primary tags). For example, the tag "man" has the parent tag "person". Currently, 25 parent tags and 2,131 tags are available for use.

Parameters

Operation: imm/tagimage

The following table describes the response parameters.

Parameter Type Description
TagId String The tag ID.
TagLevel String The tag level. The value of this parameter is an integer starting from 1. The value 1 indicates that the tag is a top-level tag, the value 2 indicates that the tag is the next tag level below, and so on.
TagName String The tag name.
ParentTagId String The ID of the parent tag. If the parent tag is a top-level tag, the ParentTagId value is 0.
ParentTagName String The name of the parent tag. If the parent tag is a top-level tag, the value of ParentTagName is null.
TagScore String The confidence score of the tag, which is a floating-point number less than or equal to 1.
Sample responses
{
    "ImageUri":"oss://image-demo/example.jpg",
    "RequestId":"5C3D858E530E23D52CA0ED09",
    "Tags":[
        {
            "TagConfidence":0.2999534606933594,
            "TagLevel":1,
            "TagName":"Landscape"
        },
        {
            "ParentTagName":"Landscape",
            "TagConfidence":0.2999534606933594,
            "TagLevel":2,
            "TagName":"Night"
        },
        {
            "TagConfidence":0.2677214741706848,
            "TagLevel":1,
            "TagName":"Outdoors"
        },
        {
            "ParentTagName":"Outdoors",
            "TagConfidence":0.2677214741706848,
            "TagLevel":2,
            "TagName":"City"
        }
    ],
    "httpStatusCode":200,
    "success":true
}

Examples

Assume that the requested bucket is named imm-demo and is located in the China (Hangzhou) region, the endpoint used to access the bucket is oss-cn-hangzhou.aliyuncs.com, and the requested image is named image.jpg. The unsigned URL of the requested image is as follows:
http://image-demo.oss-cn-hangzhou.aliyuncs.com/image.jpg?x-oss-process=imm/tagimage
The following code provides an example on how to perform the image recognition operation by using the OSS SDK for Python:
# Create a bucket. All object-related methods must be called through buckets.
bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)

# Recognize the image.
style = 'imm/tagimage'
resp = bucket.get_object(objectKey, process=style)
# Obtain the result of the operation.
data = resp.read(resp.content_length)
result = json.loads(data)
print "requestId: " + json.dumps(result["RequestId"], indent=4, sort_keys=True)
print "SuccessDetails: " + json.dumps(result["SuccessDetails"], indent=4, sort_keys=True)
print "FailDetails: " + json.dumps(result["FailDetails"], indent=4, sort_keys=True)