This repository contains fixed-shape ONNX exports of MatAnyone2 inference subgraphs.
The models are intended for projects that want to run MatAnyone2 with ONNX Runtime without importing PyTorch at runtime. They are especially useful for offline video matting, VR180/SBS workflows, and first-frame-mask propagation.
step_update fuses image feature extraction, propagation, and memory update for following frames. If it is missing, callers can run image_key, propagate, and mask_memory separately.
First-frame mask input to matanyone2_mask_memory.onnx:
text
1shape: [batch, 1, height, width]
2dtype: same as image input
3range: 0.0 background, 1.0 foreground
The exported height and width are fixed. Read them from manifest.json.
Runtime Dependencies
GPU:
pip install onnxruntime-gpu opencv-python numpy
CPU smoke tests:
pip install onnxruntime opencv-python numpy
Standalone Video Example
This repository includes matanyone2_onnx_video_infer.py, a complete example that loads all exported ONNX graphs, propagates a first-frame mask through a video, and writes a preview video.