Spaces:
Runtime error
Runtime error
Commit
·
9b53e66
1
Parent(s):
b12f76d
:sparkles: use webcam
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gc
|
2 |
import math
|
3 |
-
import
|
4 |
-
from
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
@@ -10,6 +10,19 @@ from encoded_video import EncodedVideo, write_video
|
|
10 |
from PIL import Image
|
11 |
from torchvision.transforms.functional import center_crop, to_tensor
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
print("🧠 Loading Model...")
|
14 |
model = torch.hub.load(
|
15 |
"AK391/animegan2-pytorch:main",
|
@@ -140,7 +153,7 @@ article = """
|
|
140 |
gr.Interface(
|
141 |
predict_fn,
|
142 |
inputs=[
|
143 |
-
gr.inputs.Video(),
|
144 |
gr.inputs.Slider(minimum=0, maximum=300, step=1, default=0),
|
145 |
gr.inputs.Slider(minimum=1, maximum=4, step=1, default=2),
|
146 |
# gr.inputs.Slider(minimum=6, maximum=18, step=6, default=12), # Leaving manual fps out for now
|
|
|
1 |
import gc
|
2 |
import math
|
3 |
+
import sys
|
4 |
+
from subprocess import call
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
|
|
10 |
from PIL import Image
|
11 |
from torchvision.transforms.functional import center_crop, to_tensor
|
12 |
|
13 |
+
|
14 |
+
def run_cmd(command):
|
15 |
+
try:
|
16 |
+
print(command)
|
17 |
+
call(command, shell=True)
|
18 |
+
except KeyboardInterrupt:
|
19 |
+
print("Process interrupted")
|
20 |
+
sys.exit(1)
|
21 |
+
|
22 |
+
|
23 |
+
print("⬇️ Installing latest gradio==2.4.7b0")
|
24 |
+
run_cmd("pip install gradio==2.4.7b0")
|
25 |
+
|
26 |
print("🧠 Loading Model...")
|
27 |
model = torch.hub.load(
|
28 |
"AK391/animegan2-pytorch:main",
|
|
|
153 |
gr.Interface(
|
154 |
predict_fn,
|
155 |
inputs=[
|
156 |
+
gr.inputs.Video(source="webcam"),
|
157 |
gr.inputs.Slider(minimum=0, maximum=300, step=1, default=0),
|
158 |
gr.inputs.Slider(minimum=1, maximum=4, step=1, default=2),
|
159 |
# gr.inputs.Slider(minimum=6, maximum=18, step=6, default=12), # Leaving manual fps out for now
|