Image semantic segmentation
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:
| Placeholder | Description | Required |
|---|---|---|
<path-to-trained-model> | OSS path to the trained segmentation model | Yes |
<bucket>/<path>/filelist.txt | OSS path to the input file list | Yes |
<bucket>/<path>/result.txt | OSS path where prediction results are written | Yes |
<OSS-bucket-directory> | OSS bucket directory accessible to the job | Yes |
<RAM-role-ARN> | ARN of the RAM role that grants OSS access | Yes |
<OSS-endpoint> | OSS endpoint for your region | Yes |
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.
| Field | Description | Dimensions | Type |
|---|---|---|---|
probs | Per-pixel class probabilities. A 3D array where each pixel position stores a confidence score for every class. | [H, W, num_classes] | FLOAT |
preds | Predicted 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]]]
}