Snapshot của PeterL1n/RobustVideoMatting: 9.6k★ · Python · AI Tools. Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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.
News
[Nov 03 2021] Fixed a bug in train.py.
[Sep 16 2021] Code is re-released under GPL-3.0 license.
[Aug 25 2021] Source code and pretrained models are published.
[Jul 27 2021] Paper is accepted by WACV 2022.
Showreel
Watch the showreel video (YouTube, Bilibili) to see the model's performance.
All footage in the video are available in Google Drive.
Demo
Webcam Demo: Run the model live in your browser. Visualize recurrent states.
Colab Demo: Test our model on your own videos with free GPU.
Download
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.
Framework
Download
Notes
PyTorch
rvm_mobilenetv3.pth
rvm_resnet50.pth
Official weights for PyTorch. Doc
TorchHub
Nothing to Download.
Easiest way to use our model in your PyTorch project. Doc
CoreML does not support dynamic resolution. Other resolutions can be exported yourself. Models require iOS 13+. s denotes downsample_ratio. Doc, Exporter
All models are available in Google Drive and Baidu Pan (code: gym7).
PyTorch Example
Install dependencies:
pip install -r requirements_inference.txt
Load the model:
import torch
from model import MattingNetwork
model = MattingNetwork('mobilenetv3').eval().cuda() # or "resnet50"
model.load_state_dict(torch.load('rvm_mobilenetv3.pth'))
To convert videos, we provide a simple conversion API:
from inference import convert_video
convert_video(
model, # The model, can be on any device (cpu or cuda).
input_source='input.mp4', # A video file or an image sequence directory.
output_type='video', # Choose "video" or "png_sequence"
output_composition='com.mp4', # File path if video; directory path if png sequence.
output_alpha="pha.mp4", # [Optional] Output the raw alpha prediction.
output_foreground="fgr.mp4", # [Optional] Output the raw foreground prediction.
output_video_mbps=4, # Output video mbps. Not needed for png sequence.
downsample_ratio=None, # A hyperparameter to adjust or use None for auto.
seq_chunk=12, # Process n frames at once for better parallelism.
)
Or write your own inference code:
from torch.utils.data import DataLoader
from torchvision.transforms import ToTensor
from inference_utils import VideoReader, VideoWriter
reader = VideoReader('input.mp4', transform=ToTensor())
writer = VideoWriter('output.mp4', frame_rate=30)
bgr = torch.tensor([.47, 1, .6]).view(3, 1, 1).cuda() # Green background.
rec = [None] * 4 # Initial recurrent states.
downsample_ratio = 0.25 # Adjust based on your video.
with torch.no_grad():
for src in DataLoader(reader): # RGB tensor normalized to 0 ~ 1.
fgr, pha, *rec = model(src.cuda(), *rec, downsample_ratio) # Cycle the recurrent states.
com = fgr * pha + bgr * (1 - pha) # Composite to green background.
writer.write(com) # Write frame.
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
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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/PeterL1n/RobustVideoMatting là nguồn chính thức.
PeterL1n/RobustVideoMatting có bao nhiêu sao?
PeterL1n/RobustVideoMatting có 9.6k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/PeterL1n/RobustVideoMatting. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
PeterL1n/RobustVideoMatting có phải mã nguồn mở không?
Có — PeterL1n/RobustVideoMatting phát hành theo license GPL-3.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/PeterL1n/RobustVideoMatting.
PeterL1n/RobustVideoMatting còn đang phát triển không?
Commit gần nhất trên PeterL1n/RobustVideoMatting là 2.6 năm trước (theo timestamp GitHub). Repo có 1.2k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
PeterL1n/RobustVideoMatting là gì?
PeterL1n/RobustVideoMatting (PeterL1n/RobustVideoMatting) là dự án Python trên GitHub. Theo mô tả gốc: Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!
PeterL1n/RobustVideoMatting so với các dự án AI Tools khác thế nào?
PeterL1n/RobustVideoMatting được TopGit xếp vào nhóm AI Tools, với 9.6k sao GitHub và viết bằng Python. Xem trang chủ đề AI Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về RobustVideoMatting?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về RobustVideoMatting.