Spaces:
Running
on
Zero
Running
on
Zero
amirgame197
commited on
Commit
•
a3504d6
1
Parent(s):
db092bf
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import spaces
|
2 |
import gradio as gr
|
3 |
import cv2
|
4 |
import numpy as np
|
@@ -7,12 +7,12 @@ import time
|
|
7 |
from PIL import Image
|
8 |
from transparent_background import Remover
|
9 |
|
10 |
-
|
11 |
def doo(video, mode):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
cap = cv2.VideoCapture(video)
|
17 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
18 |
|
@@ -20,7 +20,7 @@ def doo(video, mode):
|
|
20 |
|
21 |
processed_frames = 0
|
22 |
start_time = time.time()
|
23 |
-
print(
|
24 |
|
25 |
while cap.isOpened():
|
26 |
ret, frame = cap.read()
|
@@ -48,5 +48,9 @@ def doo(video, mode):
|
|
48 |
writer.release()
|
49 |
return 'output.mp4'
|
50 |
|
51 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
52 |
iface.launch()
|
|
|
1 |
+
#import spaces
|
2 |
import gradio as gr
|
3 |
import cv2
|
4 |
import numpy as np
|
|
|
7 |
from PIL import Image
|
8 |
from transparent_background import Remover
|
9 |
|
10 |
+
#@spaces.GPU
|
11 |
def doo(video, mode):
|
12 |
+
if(mode == 'Normal'):
|
13 |
+
remover = Remover()
|
14 |
+
if(mode == 'Fast'):
|
15 |
+
remover = Remover(mode='fast')
|
16 |
cap = cv2.VideoCapture(video)
|
17 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
18 |
|
|
|
20 |
|
21 |
processed_frames = 0
|
22 |
start_time = time.time()
|
23 |
+
print('Starting on mode: ' + mode)
|
24 |
|
25 |
while cap.isOpened():
|
26 |
ret, frame = cap.read()
|
|
|
48 |
writer.release()
|
49 |
return 'output.mp4'
|
50 |
|
51 |
+
iface = gr.Interface(
|
52 |
+
fn=doo,
|
53 |
+
inputs=["video", gr.components.Radio(['Normal', 'Fast'], label='Select mode', value='Normal', info= 'Normal is more accurate, but takes longer. | Fast has lower accuracy so the process will be faster')],
|
54 |
+
outputs="video"
|
55 |
+
)
|
56 |
iface.launch()
|