Image semantic segmentation

Updated at:

Run offline batch inference on images using a trained segmentation model. PAI-EasyVision distributes the workload across multiple workers and writes per-image prediction results to OSS when the job completes.

Data format

For input file format requirements, see Input data formats.

Run predictions

Submit a prediction job with the ev_predict_ext command:

pai -name ev_predict_ext
    -Dmodel_path='<path-to-trained-model>'
    -Dmodel_type='segmentor'
    -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-bucket-directory>'
    -Darn='<RAM-role-ARN>'
    -DossHost='<OSS-endpoint>'

Replace the placeholders with your actual values:

PlaceholderDescriptionRequired
<path-to-trained-model>OSS path to the trained segmentation modelYes
<bucket>/<path>/filelist.txtOSS path to the input file listYes
<bucket>/<path>/result.txtOSS path where prediction results are writtenYes
<OSS-bucket-directory>OSS bucket directory accessible to the jobYes
<RAM-role-ARN>ARN of the RAM role that grants OSS accessYes
<OSS-endpoint>OSS endpoint for your regionYes

For a full parameter reference, see Parameters.

Output

The output file contains one line per image. Each line is a comma-separated pair of the image path and a JSON prediction result:

oss://path/to/image1.jpg,  {"probs": ..., "preds": ...}
oss://path/to/image2.jpg,  {"probs": ..., "preds": ...}
oss://path/to/image3.jpg,  {"probs": ..., "preds": ...}

Each JSON result describes the segmentation output at the pixel level: preds gives the predicted class label for every pixel, and probs gives the confidence score for each class at every pixel position.

FieldDescriptionDimensionsType
probsPer-pixel class probabilities. A 3D array where each pixel position stores a confidence score for every class.[H, W, num_classes]FLOAT
predsPredicted class label for each pixel. A 2D array where each value is the class ID with the highest probability.[H, W]INT

Example JSON result:

{
  "probs": [[[0.8, 0.8], [0.6, 0.7]], [[0.8, 0.5], [0.4, 0.3]]],
  "preds": [[[1, 1], [0, 0]], [[0, 0], [1, 1]]]
}