Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
aef8896
1
Parent(s):
9a0bace
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,18 @@ os.system('pip install gradio --upgrade')
|
|
| 3 |
os.system('pip freeze')
|
| 4 |
import torch
|
| 5 |
import gradio as gr
|
|
|
|
|
|
|
| 6 |
model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3") # or "resnet50"
|
| 7 |
|
| 8 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
| 9 |
|
| 10 |
def inference(video):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
convert_video(
|
| 14 |
model, # The loaded model, can be on any device (cpu or cuda).
|
| 15 |
input_source='output.mp4', # A video file or an image sequence directory.
|
|
|
|
| 3 |
os.system('pip freeze')
|
| 4 |
import torch
|
| 5 |
import gradio as gr
|
| 6 |
+
from moviepy.editor import *
|
| 7 |
+
|
| 8 |
model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3") # or "resnet50"
|
| 9 |
|
| 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('rm output.mp4')
|
| 17 |
+
# os.system('ffmpeg -ss 00:00:00 -i '+ video +' -to 00:00:05 -c copy output.mp4')
|
| 18 |
convert_video(
|
| 19 |
model, # The loaded model, can be on any device (cpu or cuda).
|
| 20 |
input_source='output.mp4', # A video file or an image sequence directory.
|