All Products
Search
Document Center

Platform For AI:Introduction to offline prediction

Last Updated:Apr 01, 2026

EasyVision's prediction component runs offline prediction jobs on Platform for AI (PAI), processing large volumes of image and video data against trained models. The following sections describe the supported input data formats and PAI command parameters.

When to use offline prediction

Use offline prediction when you need to:

  • Run inference on large datasets in batch

  • Process images stored in MaxCompute tables or Object Storage Service (OSS) buckets in bulk

  • Apply video-level models or per-frame image models to video data

  • Use custom predictors or preprocessing logic with EasyVision's built-in I/O pipeline

How it works

Offline prediction runs as a distributed pipeline. Each atomic operation is processed asynchronously across multiple threads on every worker node.

Data flow:

  • Inputs: Images or videos from a MaxCompute table or an OSS file list

  • Processing: Each worker node reads its assigned data shard, decodes it (Base64 or URL), runs model inference, and writes results to the output shard — all concurrently across threads

  • Outputs: Prediction results written to a MaxCompute output table or an OSS file

For example, when reading images from a MaxCompute table, the system splits the table based on the number of worker nodes. Each worker independently reads its shard, decodes Base64 data, performs model prediction, and writes results to the corresponding output partition. Base64 decoding and inference run asynchronously in parallel threads to fully use both CPU and GPU capacity.

image

EasyVision provides video-level prediction models that you can use directly, or you can apply image-level models to individual video frames. The framework automatically decodes video data, runs per-frame inference, and aggregates the results.

Note

The default prediction code provided by EasyVision does not support loading trained models for offline prediction. Use the user_predictor_cls parameter to specify a custom predictor class and reuse EasyVision's built-in I/O pipeline (ev_predict). You can also insert a custom preprocessing step before the predictor receives input — see Custom input data.

Input data formats

Read data from MaxCompute tables

The input table must include at least one column containing Base64-encoded binary data or URLs for the images. That column must be of the string type. Sample schema:

+------------------------------------------------------------------------------------+
| Field           | Type       | Label | Comment                                     |
+------------------------------------------------------------------------------------+
| id              | string     |       |                                             |
| url             | string     |       |                                             |
+------------------------------------------------------------------------------------+

Read data from OSS files

Each line in the OSS input file is either an OSS path or an HTTP URL pointing to an image:

oss://your/path/to/image.jpg
http://your.path/to/image.jpg

Custom input data

By default, reading from a MaxCompute table retrieves only the URL or Base64-encoded image data, and reading from OSS retrieves only the image URL. Both methods produce NumPy arrays in the {"image": np.ndarray} format — a single-input format that cannot meet all use cases.

The custom format can be the original OSS file format or JSON string format. Each line in the input file is a JSON string with one or more key-value pairs:

{"image":"http://your/path/to/image.jpg", "prior":"oss://your/path/to/prior.txt", "config": {"key1":1, "key2":"value2"}}
{"image":"http://your/path/to/image.jpg", "prior":"oss://your/path/to/prior.txt", "config": {"key2":1, "key2":"value2"}}

All key-value pairs are collected into a dictionary and passed to your custom predictor and process classes. The system automatically handles downloads and decoding:

  • If a value is an OSS path or HTTP URL, the system downloads the file content using multiple threads and returns a file-like object. Call read() or readlines() to access the content.

  • If the URL points to a file with an image extension, the system automatically decodes it and returns a numpy.ndarray.

The input is delivered to your predictor as an input_data dictionary:

input_dict = {
    "image": np.ndarray,          # Decoded image data
    "prior": file_like_object,    # Downloaded file as a file-like object
    "config": {"key1": 1, "key2": "value2"}  # Raw JSON sub-dictionary
}
Important

All built-in EasyVision predictors use the image key to access input images. If you use a custom input format with built-in predictors, the image data must be stored under the image key.

Parameters

Required parameters

ParameterDescriptionTypeExample
model_pathOSS path of the model directorySTRINGoss://your_bucket/your_model_dir
model_typeType of the model. See Model types.STRINGclassifier
bucketsOSS bucket information for accessing the model and dataSTRINGoss://{bucket_name}.{oss_host}/{path}
arnAlibaba Cloud Resource Name (ARN) of the RAM role with OSS access permissions. For details, see the "I/O parameters" section of Parameters of PAI-TensorFlow tasks.STRING

Input and output

ParameterDescriptionTypeDefaultExample
input_tableName of the input MaxCompute table. Supports non-partitioned and partitioned tables.STRING""odps://prj_name/tables/table_name/pt=xxx
image_colName of the column that contains image dataSTRING"image""url"
image_typeFormat of image data in the table. base64: Base64-encoded binary. url: URL or OSS path.STRING"base64""url"
reserved_columnsNames of additional columns to carry through to the output. Separate multiple names with commas.STRING"""col1,col2,col3"
result_columnName of the output column for prediction resultsSTRING"prediction_result"
output_tableOutput MaxCompute table. Uses the same format as input_table. If the table does not exist, the system creates it automatically with the required partitions.STRING""odps://prj_name/tables/output_table
lifecycleLifecycle (in days) of the output tableINT1030
input_oss_filePath of the OSS input file. Each line is either an image path/URL or a JSON string (for custom input).STRING""oss://your_bucket/filelist.txt
output_oss_filePath of the output OSS file. The system generates one result file per worker node, then merges them into this file. Result files are prefixed with this filename.STRING""oss://your_bucket/results.txt
output_dirOSS folder for output files when using a custom output formatSTRING""oss://your_bucket/dir

Compute and concurrency

ParameterDescriptionTypeDefaultWhen to adjust
num_workerNumber of prediction worker nodesINT2Increase for larger datasets to speed up processing
cpuRequiredNumber of CPUs per worker node. A value of 100 equals one CPU.INT1600Increase for CPU-heavy preprocessing
gpuRequiredNumber of GPUs per worker node. A value of 100 equals one GPU. A value of 0 uses a CPU-only cluster. Maximum: 100.INT100Set to 0 for CPU-only workloads
queue_sizeLength of the inter-stage buffer queueINT1024Reduce if memory is constrained
batch_sizeBatch size for model inferenceINT1Increase for GPU workloads to improve throughput
preprocess_thread_numNumber of concurrent preprocessing threads (image decoding and download)INT4Increase for URL-based inputs with high download latency
predict_thread_numNumber of concurrent inference threadsINT2Increase for lightweight models with fast inference

Video parameters

ParameterDescriptionTypeDefault
is_input_videoSet to true when the input is video dataBOOLfalse
use_image_predictorSet to true if the predictor accepts only image frames (not raw video)BOOLtrue
decode_typeVideo decode mode. 1: intra frames only. 2: keyframes only. 3: exclude bidirectional frames. 4: decode all frames.INT4
sample_fpsNumber of frames extracted per second for samplingFLOAT5
reshape_sizeOutput frame size in pixels. Set to -1 to keep the original size.INT-1
decode_batch_sizeNumber of frames decoded in each batchINT10
decode_keep_sizeNumber of overlapping frames between consecutive decode batchesINT0

Custom predictor and process

ParameterDescriptionTypeDefaultExample
feature_nameName of the feature layer to extract. Required only when model_type is feature_extractor.STRING""resnet_v1_50/logits
user_resourcePath of a resource package (TAR.GZ, ZIP, or Python file) uploaded with the job. OSS paths and HTTP URLs are supported.STRING""oss://xxx/a.tar.gz
user_predictor_clsModule path of the custom predictor class.STRING""module.MyPredictor
user_process_configJSON configuration for a custom process class. Fields: job_name, num_threads, batch_size, user_process_cls.JSON""'[{"job_name":"myprocess","user_process_cls":"module.ClassA","num_threads":2,"batch_size":1}]'

Reliability

ParameterDescriptionTypeDefault
enableDynamicClusterSet to true to allow single worker node failover. Enable this if task exceptions occur frequently.BOOLfalse
useSparseClusterSchemaMust be set to true when enableDynamicCluster is true.BOOLfalse

Model types

The model_type parameter specifies which built-in model pipeline to load:

ValueTaskWhen to use
feature_extractorFeature extractionExtract intermediate layer representations from images. Set feature_name to specify the layer.
classifierImage classificationAssign a single label to each image
multilabel_classifierMulti-label classificationAssign multiple labels to each image
detectorObject detectionLocate and classify objects in images
text_detectorText detectionLocate text regions in images
text_recognizerText line recognitionTranscribe text from detected regions
text_detection_recognitionText detection and recognitionDetect and transcribe text in a single pass
text_spotterEnd-to-end text recognitionLocate and recognize arbitrary text end-to-end
segmentorSemantic image segmentationAssign a class label to each pixel
self_defineCustom predictionLoad the predictor class specified by user_predictor_cls