RobustVideoMatting
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!
An AI model from ByteDance that removes or replaces video backgrounds in real time without a green screen. It stays consistent across frames by remembering recent video context, and can handle 4K at 76 frames per second.
This project is an AI model that removes or replaces the background in videos, a task called video matting. Unlike older approaches that look at each video frame in isolation, this model keeps a running memory of recent frames so it can stay consistent as people move around. The result is clean, stable background removal without needing a green screen or any extra setup beyond the video itself.
The model was developed at ByteDance and published alongside a research paper accepted at a computer vision conference in 2022. It can process video at very high speeds: up to 4K resolution at 76 frames per second on a mid-range desktop GPU, or HD at over 100 frames per second. A browser-based webcam demo lets anyone test it without installing anything, and a free cloud notebook lets users try it on their own video files.
For developers who want to use it in a project, pretrained model files are available in several formats. PyTorch is the main format, with TensorFlow, ONNX, TensorFlow.js, and Apple CoreML versions also provided. This means the model can run on standard desktop machines, in web browsers, and on iOS devices. The repository includes code examples showing how to load the model and convert a video file with just a few lines of code.
The code is released under the GPL-3.0 license, which means it is free to use and modify but requires any distributed derivative work to share its source code under the same terms. Training code is also included for researchers who want to retrain or adapt the model.
Where it fits
- Remove the background from a video file and replace it with a custom image using just a few lines of Python.
- Run real-time background removal in a web browser using the TensorFlow.js version without any install.
- Deploy background removal on an iOS app using the provided CoreML model.
- Retrain or fine-tune the model on your own video dataset using the included training code.