All Products
Search
Document Center

Platform For AI:Image classification

Last Updated:Feb 27, 2026

Run offline image classification predictions with EasyVision, a distributed training and prediction component in Platform for AI (PAI). Use a trained classification model to process images stored in Object Storage Service (OSS) and output per-image category predictions.

Data format

For input data format requirements, see Input data formats.

Run a prediction task

Execute the ev_predict_ext PAI command to start an image classification prediction task. Run the command through any of the following methods:

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:

PlaceholderDescriptionExample
<model-path>OSS path to the trained modeloss://my-bucket/models/resnet50
<bucket>/<path>OSS bucket and path for input/output filesmy-bucket/data
<oss-directory>OSS directory for data accessoss://my-bucket/
<role-arn>Alibaba Cloud Resource Name (ARN) of the RAM role to assumeacs:ram::1234567890:role/pai-role
<oss-endpoint>OSS endpoint for your regionoss-cn-hangzhou-internal.aliyuncs.com

For the complete parameter reference, see Introduction to offline prediction.

Output format

The output file contains one prediction result per line. Each line consists of 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

FieldDescriptionShapeData type
classThe ID of the category.[]INT 32
class_nameThe name of the category.[]STRING
class_probsThe matching probabilities of all categories.[num_classes]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%.