Help Center > > API Reference> Image Recognition APIs> Image Tagging

Image Tagging

Updated at: Sep 29, 2019 GMT+08:00

Function

Natural images have extensive semantic meanings because one image contains a wide variety of tags. This API can recognize hundreds of scenes and thousands of objects and their properties in natural images, making intelligent album management, picture retrieval and classification, and scene- or object-based advertising more intuitive. After you upload the image to be processed, Image Tagging returns tags and confidence scores to you.

URI

URI format

POST /v1.0/image/tagging

Request Message

Table 1 describes the request parameters.
Table 1 Parameter description

Parameter

Mandatory

Type

Description

image

Configure either this parameter or url.

String

Indicates the Base64 character string converted from the image. The size cannot exceed 10 MB. The image resolution of the narrow sides must be greater than 15 pixels, and that of the wide sides cannot exceed 4096 pixels. The supported image formats include JPG, PNG, and BMP.

url

Configure either this parameter or image.

String

Indicates the URL of an image. The options are as follows:

  • HTTP/HTTPS URLs on the public network
  • HUAWEI CLOUD OBS URLs. To use OBS data, authorization is required, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.
NOTE:

The API response time depends on the image download time. If the image download takes a long time, the API call will fail.

Ensure that the storage service where the image to be detected is stored is stable and reliable. You are advised to use HUAWEI CLOUD OBS.

language

No

String

zh: indicates that the language of the returned tag is Chinese.

en: indicates that the language of the returned tag is English.

The default value is zh.

limit

No

Integer

Indicates the maximum number of tags that can be returned. The default value is -1, indicating that all tags are returned.

threshold

No

Float

Indicates the threshold (0 to 100) of the confidence score. The tags whose confidence score is lower than the threshold will not be returned.

The default value is 0.

Response Message

Table 2 describes the response parameters.
Table 2 Parameter description

Parameter

Type

Description

result

JSON

Indicates the content of the image tag when the API is successfully called.

This parameter is not included when the API fails to be called.

tags

List

Indicates the list of tags.

confidence

Float

Indicates the confidence score. The value ranges from 0 to 100.

tag

String

Indicates the tag name.

error_code

String

Indicates the error code when the API fails to be called. For details, see Error Code.

This parameter is not included when the API is successfully called.

error_msg

String

Indicates the error message when the API fails to be called.

This parameter is not included when the API is successfully called.

Examples

  • Example request (Method 1: Use a Base64-encoded image.)
    POST https://image.ap-southeast-1.myhuaweicloud.com/v1.0/image/tagging
    
    Request Header:  
    Content-Type:application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    
    Request Body:
    {
     "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...",
      "url": "",
      "language": "en",
      "limit": 5,
      "threshold": 60.0
    }  
  • Example request (Method 2: Use the URL redirecting to an image file.)
    POST https://image.ap-southeast-1.myhuaweicloud.com/v1.0/image/tagging
    Request Header:  
    Content-Type:application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    
    Request Body:
    {
      "image":"",
      "url":"https://BucketName.obs.myhuaweicloud.com/ObjectName",
      "language": "zh",
      "limit": 5,
      "threshold": 60.0
    } 
  • Example successful response
    {
      "result":{
          "tags":[
            {
                "confidence": 38.51,
                "tag":"sky"
            },
            {
                "confidence": 25.75,
                "tag":"landscape"
            }
            ]
        }
    }
  • Example failed response
    {
        "error_code": "AIS.0005",
        "error_msg": "The service does not exist."
    }

Return Value

  • Normal

    200

  • Abnormal

    Return Value

    Description

    400

    • The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
    • The request parameter is incorrect.

    401

    The request requires user authentication.

    403

    No operation permission.

    404

    The server has not found anything matching the Request-URI.

    500

    The server encountered an unexpected condition which prevented it from fulfilling the request.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel