EasyVision of Platform for AI (PAI) allows you to perform distributed model training and prediction on multiple servers to implement image classification. This topic describes how to use EasyVision to perform offline image classification prediction by using trained models.
Data format
For more information, see Input data formats.
Image classification prediction
You can run the following PAI command to start the image classification prediction task based on existing files: You can call the PAI command by using the SQL Script component, the MaxCompute client, or an ODPS SQL node of DataWorks. For more information, see MaxCompute client (odpscmd) or Develop a MaxCompute SQL task.
pai -name ev_predict_ext
-Dmodel_path='your model path'
-Dmodel_type='classifier'
-Dinput_oss_file='oss://path/to/your/filelist.txt'
-Doutput_oss_file='oss://path/to/your/result.txt'
-Dimage_type='url'
-Dnum_worker=2
-DcpuRequired=800
-DgpuRequired=100
-Dbuckets='Your OSS directory'
-Darn='Alibaba Cloud Resource Name (ARN) of the role that you assume'
-DossHost='Your OSS domain'
For more information about the parameters, see the "Parameters" section in the Introduction to offline prediction topic.
Output
Prediction results are written to an output file. Each entry in the file consists of an Object Storage Service (OSS) path and a JSON string. The OSS path indicates the path of the original image, and the JSON string indicates the prediction result. For example, the output file contains the following information:
oss://path/to/your/image1.jpg, JSON string
oss://path/to/your/image1.jpg, JSON string
oss://path/to/your/image1.jpg, JSON string
The JSON string is in the following format:
{
"class": 3,
"class_name": "coho4",
"class_probs": {"coho1": 4.028851974258174e-10,
"coho2": 0.48115724325180054,
"coho3": 5.116515922054532e-07,
"coho4": 0.5188422446937221}
}
The following table describes the parameters in the JSON string.
Parameter | Description | Shape | Data type |
class | The ID of the category. | [] | INT 32 |
class_name | The name of the category. | [] | STRING |
class_probs | The matching probabilities of all categories. | [num_classes] | Dict{Key:STRING,Value:FLOAT} |