Spaces:
Running
on
Zero
Running
on
Zero
amirgame197
commited on
Commit
•
e6399c3
1
Parent(s):
ce6434e
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
|
|
4 |
from transparent_background import Remover
|
5 |
|
6 |
remover = Remover(mode='fast') # Custom setting
|
@@ -17,19 +18,17 @@ def doo(video):
|
|
17 |
if ret is False:
|
18 |
break
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
# Replace this placeholder code with actual model inference
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
_, mask = cv2.threshold(gray_frame, 200, 255, cv2.THRESH_BINARY)
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
|
31 |
-
# Append the processed frame to the
|
32 |
-
processed_frames.append(
|
33 |
|
34 |
cap.release()
|
35 |
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
from transparent_background import Remover
|
6 |
|
7 |
remover = Remover(mode='fast') # Custom setting
|
|
|
18 |
if ret is False:
|
19 |
break
|
20 |
|
21 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
22 |
+
img = Image.fromarray(frame).convert('RGB')
|
|
|
23 |
|
24 |
+
# Process the frame using the transparent-background model
|
25 |
+
out = remover.process(img, type='map') # Same as image, except for 'rgba'
|
|
|
26 |
|
27 |
+
# Convert the processed frame back to a NumPy array
|
28 |
+
processed_frame = np.array(out)
|
29 |
|
30 |
+
# Append the processed frame to the list
|
31 |
+
processed_frames.append(processed_frame)
|
32 |
|
33 |
cap.release()
|
34 |
|