Image object detection

Updated at:

Run offline object detection on images with trained PAI-EasyVision models.

Input data format

Prepare your data according to the Input data format specification.

Run a prediction task

Run the following PAI command to start object detection with an existing file list of image paths. Run the PAI command from a SQL Script component, the MaxCompute client, or an ODPS SQL node in DataWorks. For more information, see Connect using the local client (odpscmd) or Develop an ODPS SQL task.

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=''
             -Darn=''
             -DossHost=''

Each parameter is described in the Parameters reference.

Output format

Each line contains the image path followed by a JSON prediction result:

oss://path/to/your/image1.jpg,  JSON string
oss://path/to/your/image1.jpg,  JSON string
oss://path/to/your/image1.jpg,  JSON string

Sample output:

{
  "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_class_names": ["text", "text"]
 }

JSON output fields:

Field

Description

Shape

Type

detection_boxes

Bounding box coordinates: [top, left, bottom, right]

[num_detections, 4]

FLOAT

detection_scores

Confidence score for each detection

num_detections

FLOAT

detection_classes

Class ID for each detected object

num_detections

INT

detection_class_names

Class name for each detected object

num_detections

STRING