Runs offline image classification predictions on images stored in Object Storage Service (OSS) using EasyVision, the distributed training and prediction component of Platform for AI (PAI). Each image is processed against a trained classification model and assigned a per-image category prediction.
Data format
For input data format requirements, see Input data formats.
Run a prediction task
Run the ev_predict_ext PAI command to start an image classification prediction task. Submit the command using any of the following methods:
SQL Script component in PAI
ODPS SQL node in DataWorks
Command syntax
pai -name ev_predict_ext
-Dmodel_path='<model-path>'
-Dmodel_type='classifier'
-Dinput_oss_file='oss://<bucket>/<path>/filelist.txt'
-Doutput_oss_file='oss://<bucket>/<path>/result.txt'
-Dimage_type='url'
-Dnum_worker=2
-DcpuRequired=800
-DgpuRequired=100
-Dbuckets='<oss-directory>'
-Darn='<role-arn>'
-DossHost='<oss-endpoint>'
Replace the placeholders with your values:
|
Placeholder |
Description |
Example |
|
|
OSS path to the trained model |
|
|
|
OSS bucket and path for input/output files |
|
|
|
OSS directory for data access |
|
|
|
Alibaba Cloud Resource Name (ARN) of the RAM role to assume |
|
|
|
OSS endpoint for your region |
|
For the complete parameter reference, see Introduction to offline prediction.
Output format
The output file contains one prediction result per line. Each line is an OSS image path followed by a comma and a JSON string:
oss://path/to/your/image1.jpg, {"class": 3, "class_name": "coho4", "class_probs": {...}}
oss://path/to/your/image2.jpg, {"class": 1, "class_name": "coho2", "class_probs": {...}}
oss://path/to/your/image3.jpg, {"class": 0, "class_name": "coho1", "class_probs": {...}}
JSON result fields
|
Field |
Description |
Shape |
Data type |
|
|
The ID of the predicted category. |
|
INT 32 |
|
|
The name of the predicted category. |
|
STRING |
|
|
The matching probabilities for all categories. |
|
Dict{Key: STRING, Value: FLOAT} |
Sample output
{
"class": 3,
"class_name": "coho4",
"class_probs": {
"coho1": 4.028851974258174e-10,
"coho2": 0.48115724325180054,
"coho3": 5.116515922054532e-07,
"coho4": 0.5188422446937221
}
}
In this example, the model assigns the image to category coho4 (category ID 3) with a matching probability of approximately 51.88%. The class_probs field lists the probability for every category, so you can inspect confidence across all classes—not just the top-1 result.