Pangu-CV-ImageClassification-2.1.0
Function
Quantitatively analyzes an image based on different image features and classifies the image into several categories. It is applicable to tasks such as animal and plant classification, vehicle type classification, license plate classification, scrap grading, and component classification.
Service API calling method:
- Image inference is supported.
- Image inference services can be deployed as real-time services or edge services.
Authorization Information
An account has required permissions to call all APIs by default. To call this API as an IAM user, the IAM user must be granted the required permissions. For details, see Permissions and Supported Actions.
URI
POST /v1/{project_id}/infer-api/proxy/service/{deployment_id}/
For details about how to obtain the URI, see Request URI.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition: Project ID. For details about how to obtain a project ID, see Obtaining the Project ID. Constraints: N/A Value range: N/A Default value: N/A |
| deployment_id | Yes | String | Definition: Model deployment ID. For details about how to obtain the deployment ID, see Obtaining the Model Deployment ID. Constraints: N/A Value range: N/A Default value: N/A |
Request Parameters
Table 2 lists the request header parameters for token-based authentication.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition: User token. Used to obtain the permission required to call APIs. The token is the value of X-Subject-Token in the response header in Figure 4. Constraints: N/A Value range: N/A Default value: N/A |
| Content-Type | Yes | String | Definition: MIME type of the body in the request. Constraints: N/A Value range: N/A Default value: application/json |
Table 3 lists the request header parameters for API key authentication.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Apig-AppCode | Yes | String | Definition: API key. Used to obtain the permission required to call APIs. The API key is the value of X-Apig-AppCode in the response header in API key authentication. Constraints: N/A Value range: N/A Default value: N/A |
| Content-Type | Yes | String | Definition: MIME type of the body in the request. Constraints: N/A Value range: N/A Default value: application/json |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| images | Yes | String/List[String] | Definition: Base64-encoded image. Constraints:
Value range: N/A Default value: N/A |
| mode | No | String | Definition: The value can be "single" or "multiple", indicating single-label classification or multi-label classification, respectively. The default value is the mode corresponding to the trained model. Constraints: N/A Value range:
Default value: N/A |
| threshold | No | dict | Definition: Prediction score threshold of each label in multi-label classification. Predictions whose scores are less than the threshold will be filtered out. Constraints: This parameter is available only in multi-label classification mode. Value range: N/A Default value: N/A |
| top | No | int | Definition: Predictions whose scores rank top N in single-label classification. Constraints: This parameter is available only in single-label classification mode. Value range: N/A Default value: N/A |
Response Parameters
Status code: 200
If the response is successful, the returned structure is a dict, which consists of the predictions of multiple input images in the current request. The images are distinguished by numbers (keys).
| Parameter | Type | Description |
|---|---|---|
| Key | String | Definition: Sequence numbers of the input images. The value starts from 0 and cannot exceed 23. Constraints: N/A Value range: 0-23 Default value: N/A |
| Value | List[Dict] | Definition: Prediction result corresponding to the image with the current number. Constraints: N/A Value range: N/A Default value: N/A |
| dataset_id | String | Definition: Training dataset ID Constraints: N/A Value range: N/A Default value: N/A |
The prediction result parameter type of each image is List[Dict], indicating that one or more classes have been predicted. For details about the parameter content of each dict, see Table 6.
| Parameter | Type | Description |
|---|---|---|
| label | String | Definition: Predicted label, which is the same as the label defined in the training data Constraints: N/A Value range: N/A Default value: N/A |
| score | String | Definition: Confidence of the prediction. The prediction score of each label is provided. The score ranges from 0 to 1. Constraints: N/A Value range: 0-1 Default value: N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code |
| error_msg | String | Error message |
Example Request
Example of a single-image classification request:
{
"images": "/9j/4Vr2RXhpZgAASUkqAAgAAA.....",
} Example of a multi-image classification request (maximum number of images that can be contained in a request: 24):
{
"images": ["/9j/4Vr2RXhpZgAASUkqAAgAAA.....", "/9j/4RIrRXhpZgAATU......"]
} Example of a single-label classification request with advanced parameters:
{
"images": ["/9j/4Vr2RXhpZgAASUkqAAgAAA.....", "/9j/4RIrRXhpZgAATU......"],
"top": 3
} Example of a multi-label classification request with advanced parameters:
{
"images": ["/9j/4Vr2RXhpZgAASUkqAAgAAA.....", "/9j/4RIrRXhpZgAATU......"],
"threshold":
{
"bird": 0.33,
"blackbird": 0.44
}
} Example Response
A dictionary is returned in the response. The Key is the numbers of the input images of the current request. The input images are numbered from 0 in sequence. The Value is a list, which contains the prediction results of the images. Each image may have multiple prediction results (for example, in multi-label classification mode).
{
"0": [
{
"label": "bird",
"score": "0.95511043"
},
{
"label": "blackbird",
"score": "0.75241840"
},
],
"1": [
{
"label": "bird",
"score": "0.36211243"
}
],
"dataset_id": "1341002014632579072"
} Status Codes
For details, see Status Codes.
Error Codes
For details, 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