All Products
Search
Document Center

Platform For AI:Image classification

Last Updated:Jun 10, 2026

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:

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

<model-path>

OSS path to the trained model

oss://my-bucket/models/resnet50

<bucket>/<path>

OSS bucket and path for input/output files

my-bucket/data

<oss-directory>

OSS directory for data access

oss://my-bucket/

<role-arn>

Alibaba Cloud Resource Name (ARN) of the RAM role to assume

acs:ram::1234567890:role/pai-role

<oss-endpoint>

OSS endpoint for your region

oss-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 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

class

The ID of the predicted category.

[]

INT 32

class_name

The name of the predicted category.

[]

STRING

class_probs

The matching probabilities for 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%. The class_probs field lists the probability for every category, so you can inspect confidence across all classes—not just the top-1 result.