Robust Video Matting (RVM)
Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specifically designed for robust human video matting. Unlike existing neural models that process frames as independent images, RVM uses a recurrent neural network to process videos with temporal memory. RVM can perform matting in real-time on any videos without additional inputs. It achieves 4K 76FPS and HD 104FPS on an Nvidia GTX 1080 Ti GPU. The project was developed at ByteDance Inc.
- [Aug 25 2021] Source code and pretrained models are published.
- [Jul 27 2021] Paper is accepted by WACV 2022.
- Webcam Demo: Run the model live in your browser. Visualize recurrent states.
- Colab Demo: Test our model on your own videos with free GPU.
We recommend MobileNetv3 models for most use cases. ResNet50 models are the larger variant with small performance improvements. Our model is available on various inference frameworks. See inference documentation for more instructions.
|Official weights for PyTorch. Doc|
|TorchHub||Nothing to Download.||Easiest way to use our model in your PyTorch project. Doc|
|If inference on mobile, consider export int8 quantized models yourself. Doc|
|Tested on ONNX Runtime with CPU and CUDA backends. Provided models use opset 12. Doc, Exporter.|
|TensorFlow 2 SavedModel. Doc|
||Run the model on the web. Demo, Starter Code|
| CoreML does not support dynamic resolution. Other resolutions can be exported yourself. Models require iOS 13+.
- Install dependencies:
pip install -r requirements_inference.txt
- Load the model:
- To convert videos, we provide a simple conversion API:
- Or write your own inference code:
- The models and converter API are also available through TorchHub.
# Load the model. model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3") # or "resnet50"
# Converter API.
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
Please see inference documentation for details on
downsample_ratio hyperparameter, more converter arguments, and more advanced usage.
Training and Evaluation
Please refer to the training documentation to train and evaluate your own model.
Speed is measured with
inference_speed_test.py for reference.
|GPU||dType||HD (1920x1080)||4K (3840x2160)|
|RTX 3090||FP16||172 FPS||154 FPS|
|RTX 2060 Super||FP16||134 FPS||108 FPS|
|GTX 1080 Ti||FP32||104 FPS||74 FPS|
- Note 1: HD uses
downsample_ratio=0.25, 4K uses
downsample_ratio=0.125. All tests use batch size 1 and frame chunk 1.
- Note 2: GPUs before Turing architecture does not support FP16 inference, so GTX 1080 Ti uses FP32.
- Note 3: We only measure tensor throughput. The provided video conversion script in this repo is expected to be much slower, because it does not utilize hardware video encoding/decoding and does not have the tensor transfer done on parallel threads. If you are interested in implementing hardware video encoding/decoding in Python, please refer to PyNvCodec.