PAI-EasyVision提供图像物体检测的训练和预测能力,支持多机分布式训练和预测。本文介绍如何通过PAI-EasyVision使用训练好的模型进行离线物体检测。
数据格式
详情请参见输入数据格式。
图像物体检测
基于已有的文件列表,您可以通过PAI命令启动图像物体检测的预测任务,示例如下。您可以使用SQL脚本组件进行PAI命令调用,也可以使用MaxCompute客户端或DataWorks的开发节点进行PAI命令调用,详情请参见使用本地客户端(odpscmd)连接或开发ODPS SQL任务。
pai -name ev_predict_ext
             -Dmodel_path='您的模型路径'
             -Dmodel_type='detector'
             -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格式结果字符串的格式示例如下。
{
  "detection_boxes": [[243.5308074951172, 197.69570922851562, 385.59625244140625, 247.7247772216797], [292.1929931640625, 114.28043365478516, 571.2748413085938, 165.09771728515625]], 
  "detection_scores": [0.9942291975021362, 0.9940272569656372],
  "detection_classes": [1, 1],
  "detection_classe_names": ["text", "text"]
 }各字段的解释如下表所示。
参数  | 描述  | Shape  | Type  | 
detection_boxes  | 检测到的目标框,坐标顺序为[top, left, bottom, right]。  | [num_detections, 4]  | FLOAT  | 
detection_scores  | 目标检测概率。  | num_detections  | FLOAT  | 
detection_classes  | 目标区域类别ID。  | num_detections  | INT  | 
detection_class_names  | 目标区域类别名称。  | num_detections  | STRING  | 
该文章对您有帮助吗?