Spaces:
Sleeping
Sleeping
change requirements
Browse files- .gitattributes +1 -0
- app.py +24 -26
- pexels-darina-belonogova-7539228.mp4 +0 -3
- requirements.txt +5 -4
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
pexels-darina-belonogova-7539228.mp4 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
pexels-darina-belonogova-7539228.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -1,43 +1,41 @@
|
|
| 1 |
-
import os
|
| 2 |
-
os.system('pip install gradio --upgrade')
|
| 3 |
-
os.system('pip install torch')
|
| 4 |
-
os.system('pip freeze')
|
| 5 |
import torch
|
| 6 |
import gradio as gr
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
| 10 |
|
|
|
|
| 11 |
def inference(video):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
title = "Robust Video Matting"
|
| 29 |
description = "Gradio demo for Robust Video Matting. To use it, simply upload your video, or click one of the examples to load them. Read more at the links below."
|
| 30 |
|
| 31 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2108.11515'>Robust High-Resolution Video Matting with Temporal Guidance</a> | <a href='https://github.com/PeterL1n/RobustVideoMatting'>Github Repo</a></p>"
|
| 32 |
|
| 33 |
-
examples = [[
|
| 34 |
gr.Interface(
|
| 35 |
-
inference,
|
| 36 |
-
gr.inputs.Video(label="Input"),
|
| 37 |
gr.outputs.Video(label="Output"),
|
| 38 |
title=title,
|
| 39 |
description=description,
|
| 40 |
article=article,
|
| 41 |
enable_queue=True,
|
| 42 |
-
examples=examples
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
| 3 |
+
|
| 4 |
+
model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3").cuda() # or "resnet50"
|
| 5 |
|
| 6 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
| 7 |
|
| 8 |
+
|
| 9 |
def inference(video):
|
| 10 |
+
convert_video(
|
| 11 |
+
model, # The loaded model, can be on any device (cpu or cuda).
|
| 12 |
+
input_source=video, # A video file or an image sequence directory.
|
| 13 |
+
downsample_ratio=0.25, # [Optional] If None, make downsampled max size be 512px.
|
| 14 |
+
output_type='video', # Choose "video" or "png_sequence"
|
| 15 |
+
output_composition='com.mp4', # File path if video; directory path if png sequence.
|
| 16 |
+
output_alpha=None, # [Optional] Output the raw alpha prediction.
|
| 17 |
+
output_foreground=None, # [Optional] Output the raw foreground prediction.
|
| 18 |
+
output_video_mbps=4, # Output video mbps. Not needed for png sequence.
|
| 19 |
+
seq_chunk=12, # Process n frames at once for better parallelism.
|
| 20 |
+
num_workers=1, # Only for image sequence input. Reader threads.
|
| 21 |
+
progress=True # Print conversion progress.
|
| 22 |
+
)
|
| 23 |
+
return "com.mp4"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
title = "Robust Video Matting"
|
| 27 |
description = "Gradio demo for Robust Video Matting. To use it, simply upload your video, or click one of the examples to load them. Read more at the links below."
|
| 28 |
|
| 29 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2108.11515'>Robust High-Resolution Video Matting with Temporal Guidance</a> | <a href='https://github.com/PeterL1n/RobustVideoMatting'>Github Repo</a></p>"
|
| 30 |
|
| 31 |
+
examples = [["example.mp4"]]
|
| 32 |
gr.Interface(
|
| 33 |
+
inference,
|
| 34 |
+
gr.inputs.Video(label="Input"),
|
| 35 |
gr.outputs.Video(label="Output"),
|
| 36 |
title=title,
|
| 37 |
description=description,
|
| 38 |
article=article,
|
| 39 |
enable_queue=True,
|
| 40 |
+
examples=examples,
|
| 41 |
+
).launch(debug=True)
|
pexels-darina-belonogova-7539228.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:54f4e572fa04e6c792d8dcdea9979c11265246ee0149c255d2d9a63b43642c48
|
| 3 |
-
size 5885930
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
-
av
|
| 2 |
-
torch==1.
|
| 3 |
-
|
|
|
|
| 4 |
tqdm==4.61.1
|
| 5 |
-
pims
|
| 6 |
gradio
|
|
|
|
| 1 |
+
av
|
| 2 |
+
torch==2.1.0
|
| 3 |
+
torchaudio==2.1.0
|
| 4 |
+
torchvision==0.16.0
|
| 5 |
tqdm==4.61.1
|
| 6 |
+
pims
|
| 7 |
gradio
|