Image Tagging
Function
Image Tagging can accurately identify hundreds of scenes and thousands of common objects and their attributes in natural images. It makes intelligent album management, photo 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 Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
image |
false |
String |
Configure either this parameter or url. 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 JPEG, PNG, BMP, and WEBP. |
url |
false |
String |
Configure either this parameter or image. Indicates the URL of an image. The options are as follows:
NOTE:
|
language |
false |
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 |
false |
Integer |
Indicates the maximum number of tags that can be returned. The default value is 30. |
threshold |
false |
Float |
Indicates the threshold of the confidence score. The value ranges from 0 to 100. If you input a value beyond the value range, the default value is used. Default value: 0 |
Response Parameters
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. |
type |
String |
Indicates the tag type. Possible values are as follows:
|
i18n_tag |
JSON |
Indicates the internationalization field of the tag. (i18n is only an internationalization flag and has no special meaning.)
|
error_code |
String |
Indicates the error code of a failed API call. For details, see Error Codes. This parameter is not included when the API is successfully called. |
error_msg |
String |
Indicates the error message of a failed API call. 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.<region>.myhuaweicloud.com/<objectName>", "language": "en", "limit": 5, "threshold": 60.0 }
- Example of a successful response
{ "result":{ "tags":[ { "confidence": 38.51, "tag":"sky", "i18n_tag": { "en": "sky", "zh": "Chinese characters for sky" }, "type": "object" }, { "confidence": 25.75, "tag":"landscape", "i18n_tag": { "en": "landscape", "zh": "Chinese characters for landscape" }, "type": "scene" } ] } }
- Example of a failed response
{ "error_code": "AIS.0014", "error_msg": "The JSON format of the input data is incorrect." }
Return Values
- Normal
- 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.
Error Codes
For details about error codes, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot