PAI-EasyVision提供图像分类的训练和预测能力,支持多机分布式训练和预测。本文为您介绍如何通过PAI-EasyVision使用已有的训练模型完成图像分类离线任务。

数据格式

请参见输入数据格式

图像分类预测

基于已有的文件列表,您可以通过PAI命令启动图像分类预测任务,示例如下。
pai -name ev_predict_ext
             -Dmodel_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='您的OSS目录'
             -Darn='您的rolearn'
             -DossHost='您的OSS域名'
详细的参数解释请参见参数说明

输出结果

结果文件的每行表示原始图片路径及模型预测结果(格式为JSON的字符串),示例如下。
oss://path/to/your/image1.jpg,  JSON格式结果字符串
oss://path/to/your/image1.jpg,  JSON格式结果字符串
oss://path/to/your/image1.jpg,  JSON格式结果字符串
JSON格式结果字符串的示例如下。
{
"class": 3,
"class_name": "coho4",
"class_probs": {"coho1": 4.028851974258174e-10,
          "coho2": 0.48115724325180054,
          "coho3": 5.116515922054532e-07,
          "coho4": 0.5188422446937221}
}
其中的参数解释如下表所示。
参数 描述 Shape 数据类型
class 类别ID [] INT 32
class_name 类别名称 [] STRING
class_probs 所有类别概率 [num_classes] Dict{Key:STRING,Value:FLOAT}