All Products
Search
Document Center

Platform For AI:Multi-label image classification

Last Updated:Mar 12, 2024

EasyVision of Machine Learning Platform for AI allows you to perform model training and prediction in multi-label image classification. In addition, you can use EasyVision to perform distributed training and prediction on multiple servers. This topic describes how to use EasyVision to achieve offline prediction in multi-label image classification based on existing training models.

Data format

For more information, see Input data formats.

Offline prediction in multi-label image classification

You can run the following Machine Learning Platform for AI command to start offline image labeling 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='OSS path of your model'
             -Dmodel_type='multilabel_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 are assuming'
             -DossHost='Your OSS domain'

For more information, see Parameters.

Output

Prediction results are written to an output file. Each entry in the file consists of an Object Storage Service (OSS) path and a prediction result. The OSS path indicates the path of the original image. For example, the output file contains the following information:

oss://path/to/your/image1.jpg,  { "class_probs":{ "Sketch":0.0008051558979786932, "Life moment":0.7316102385520935 "Accessory":0.0008112151990644634, "Dancing":0.0008053297060541809 }, "classes":[ 1 ], "predictions":[ false, true, false, false ], "class_names":[ "Life moment" ], "probs":[ 0.00054657127475366, 0.7316212648051790893, 0.0005365353426896036, 0.0007256706594489515 ] }
oss://path/to/your/image1.jpg,  { "class_probs":{ "Sketch":0.0008051558979786932, "Life moment":0.7316102385520935 "Accessory":0.0008112151990644634, "Dancing":0.0008053297060541809 }, "classes":[ 1 ], "predictions":[ false, true, false, false ], "class_names":[ "Life moment" ], "probs":[ 0.00054657127475366, 0.7316212648051790893, 0.0005365353426896036, 0.0007256706594489515 ] }
oss://path/to/your/image1.jpg,  { "class_probs":{ "Sketch":0.0008051558979786932, "Life moment":0.7316102385520935 "Accessory":0.0008112151990644634, "Dancing":0.0008053297060541809 }, "classes":[ 1 ], "predictions":[ false, true, false, false ], "class_names":[ "Life moment" ], "probs":[ 0.00054657127475366, 0.7316212648051790893, 0.0005365353426896036, 0.0007256706594489515 ] }

The prediction result is presented in a JSON string. The following table describes parameters in the JSON string.

Parameter

Description

Shape

Data type

classes

The ID of the label.

[num_labels]

INT Array

class_names

The name of the label.

[num_labels]

STRING Array

class_probs

The probabilities for all labels.

[total_labels]

Dict{Key:STRING,Value:FLOAT}