Spaces:
Running
on
Zero
Running
on
Zero
amirgame197
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,16 +5,16 @@ import numpy as np
|
|
5 |
from PIL import Image
|
6 |
from transparent_background import Remover
|
7 |
|
8 |
-
remover = Remover(mode='fast')
|
9 |
|
10 |
def doo(video):
|
11 |
-
cap = cv2.VideoCapture(video)
|
12 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
13 |
|
14 |
writer = None
|
15 |
|
16 |
while cap.isOpened():
|
17 |
-
ret, frame = cap.read()
|
18 |
|
19 |
if ret is False:
|
20 |
break
|
@@ -23,14 +23,14 @@ def doo(video):
|
|
23 |
img = Image.fromarray(frame).convert('RGB')
|
24 |
|
25 |
if writer is None:
|
26 |
-
writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
|
27 |
|
28 |
-
out = remover.process(img, type='
|
29 |
writer.write(cv2.cvtColor(np.array(out), cv2.COLOR_BGR2RGB))
|
30 |
|
31 |
cap.release()
|
32 |
writer.release()
|
33 |
-
return 'output.mp4'
|
34 |
|
35 |
def display_video(output_video):
|
36 |
return output_video
|
|
|
5 |
from PIL import Image
|
6 |
from transparent_background import Remover
|
7 |
|
8 |
+
remover = Remover(mode='fast')
|
9 |
|
10 |
def doo(video):
|
11 |
+
cap = cv2.VideoCapture(video)
|
12 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
13 |
|
14 |
writer = None
|
15 |
|
16 |
while cap.isOpened():
|
17 |
+
ret, frame = cap.read()
|
18 |
|
19 |
if ret is False:
|
20 |
break
|
|
|
23 |
img = Image.fromarray(frame).convert('RGB')
|
24 |
|
25 |
if writer is None:
|
26 |
+
writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
|
27 |
|
28 |
+
out = remover.process(img, type='green')
|
29 |
writer.write(cv2.cvtColor(np.array(out), cv2.COLOR_BGR2RGB))
|
30 |
|
31 |
cap.release()
|
32 |
writer.release()
|
33 |
+
return 'output.mp4'
|
34 |
|
35 |
def display_video(output_video):
|
36 |
return output_video
|