Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
6443cc4
1
Parent(s):
e3258c1
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,21 +10,21 @@ model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3") # or "resne
|
|
| 10 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
| 11 |
|
| 12 |
def inference(video):
|
| 13 |
-
|
| 14 |
#clip = VideoFileClip(video).subclip(0, 5)
|
| 15 |
#clip.write_videofile("output.mp4")
|
| 16 |
os.system('ffmpeg -ss 00:00:00 -i '+ video +' -to 00:00:05 -c copy -y output.mp4')
|
| 17 |
convert_video(
|
| 18 |
model, # The loaded model, can be on any device (cpu or cuda).
|
| 19 |
input_source='output.mp4', # A video file or an image sequence directory.
|
| 20 |
-
input_resize=(
|
| 21 |
downsample_ratio=0.25, # [Optional] If None, make downsampled max size be 512px.
|
| 22 |
output_type='video', # Choose "video" or "png_sequence"
|
| 23 |
output_composition='com.mp4', # File path if video; directory path if png sequence.
|
| 24 |
output_alpha="pha.mp4", # [Optional] Output the raw alpha prediction.
|
| 25 |
output_foreground="fgr.mp4", # [Optional] Output the raw foreground prediction.
|
| 26 |
output_video_mbps=4, # Output video mbps. Not needed for png sequence.
|
| 27 |
-
seq_chunk=
|
| 28 |
num_workers=1, # Only for image sequence input. Reader threads.
|
| 29 |
progress=True # Print conversion progress.
|
| 30 |
)
|
|
|
|
| 10 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
| 11 |
|
| 12 |
def inference(video):
|
| 13 |
+
os.system('rm output.mp4')
|
| 14 |
#clip = VideoFileClip(video).subclip(0, 5)
|
| 15 |
#clip.write_videofile("output.mp4")
|
| 16 |
os.system('ffmpeg -ss 00:00:00 -i '+ video +' -to 00:00:05 -c copy -y output.mp4')
|
| 17 |
convert_video(
|
| 18 |
model, # The loaded model, can be on any device (cpu or cuda).
|
| 19 |
input_source='output.mp4', # A video file or an image sequence directory.
|
| 20 |
+
input_resize=(500, 500), # [Optional] Resize the input (also the output).
|
| 21 |
downsample_ratio=0.25, # [Optional] If None, make downsampled max size be 512px.
|
| 22 |
output_type='video', # Choose "video" or "png_sequence"
|
| 23 |
output_composition='com.mp4', # File path if video; directory path if png sequence.
|
| 24 |
output_alpha="pha.mp4", # [Optional] Output the raw alpha prediction.
|
| 25 |
output_foreground="fgr.mp4", # [Optional] Output the raw foreground prediction.
|
| 26 |
output_video_mbps=4, # Output video mbps. Not needed for png sequence.
|
| 27 |
+
seq_chunk=7, # Process n frames at once for better parallelism.
|
| 28 |
num_workers=1, # Only for image sequence input. Reader threads.
|
| 29 |
progress=True # Print conversion progress.
|
| 30 |
)
|