1.9 KiB
MODNet - WebCam-Based Portrait Video Matting Demo
This is a MODNet portrait video matting demo based on WebCam. It will call your local WebCam and display the matting results in real time.
Requirements
The basic requirements for this demo are:
- Ubuntu System
- WebCam
- Nvidia GPU with CUDA
- Python 3+
NOTE: If your device does not satisfy the above conditions, please try our online Colab demo.
Introduction
We use ~400 unlabeled video clips (divided into ~50,000 frames) downloaded from the internet to perform SOC to adapt MODNet to the video domain. Nonetheless, due to insufficient labeled training data (~3k labeled foregrounds), our model may still make errors in portrait semantics estimation under challenging scenes. Besides, this demo does not currently support the OFD trick, which will be provided soon.
For a better experience, please:
- make sure the portrait and background are distinguishable, i.e., are not similar
- run in soft and bright ambient lighting
- do not be too close or too far from the WebCam
- do not move too fast
Run Demo
We recommend creating a new conda virtual environment to run this demo, as follow:
-
Clone the MODNet repository:
git clone https://github.com/ZHKKKe/MODNet.git cd MODNet -
Download the pre-trained model from this link and put it into the folder
MODNet/pretrained/. -
Create a conda virtual environment named
modnet-webcamand activate it:conda create -n modnet-webcam python=3.6 source activate modnet-webcam -
Install the required python dependencies (here we use PyTorch==1.0.0):
pip install -r demo/video_matting/requirements.txt -
Execute the main code:
python -m demo.video_matting.webcam