Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import rembg
|
|
6 |
import cv2
|
7 |
import uuid
|
8 |
uid=uuid.uuid4()
|
9 |
-
|
10 |
load_js = """
|
11 |
function(text_input, url_params) {
|
12 |
console.log(text_input, url_params);
|
@@ -50,14 +50,14 @@ def capture_function(vid=None,frame_count=None):
|
|
50 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
51 |
ret, frame_f = capture.read(i)
|
52 |
frame_ff = cv2.cvtColor(frame_f, cv2.COLOR_BGR2RGB)
|
53 |
-
cv2.imwrite(f'{uid}
|
54 |
-
fbox.append(f'{uid}
|
55 |
|
56 |
capture.set(cv2.CAP_PROP_POS_FRAMES, int(frame_count)-1)
|
57 |
ret, frame_f = capture.read()
|
58 |
frame_ff = cv2.cvtColor(frame_f, cv2.COLOR_BGR2RGB)
|
59 |
-
cv2.imwrite(f'{uid}
|
60 |
-
fbox.append(f'{uid}
|
61 |
capture.release()
|
62 |
return fbox,fbox
|
63 |
|
@@ -118,9 +118,12 @@ with gr.Blocks() as app:
|
|
118 |
frame_count=gr.Textbox()
|
119 |
outp_file=gr.Files()
|
120 |
with gr.Tab("Frames"):
|
121 |
-
frame_btn = gr.Button("Get Frames")
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
124 |
|
125 |
with gr.Tab("Rem BG"):
|
126 |
with gr.Row():
|
|
|
6 |
import cv2
|
7 |
import uuid
|
8 |
uid=uuid.uuid4()
|
9 |
+
if not os.path.exists(uid): os.makedirs(uid)
|
10 |
load_js = """
|
11 |
function(text_input, url_params) {
|
12 |
console.log(text_input, url_params);
|
|
|
50 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
51 |
ret, frame_f = capture.read(i)
|
52 |
frame_ff = cv2.cvtColor(frame_f, cv2.COLOR_BGR2RGB)
|
53 |
+
cv2.imwrite(f'{uid}/{i}.png',frame_ff)
|
54 |
+
fbox.append(f'{uid}/{i}.png')
|
55 |
|
56 |
capture.set(cv2.CAP_PROP_POS_FRAMES, int(frame_count)-1)
|
57 |
ret, frame_f = capture.read()
|
58 |
frame_ff = cv2.cvtColor(frame_f, cv2.COLOR_BGR2RGB)
|
59 |
+
cv2.imwrite(f'{uid}/{int(frame_count)-1}.png',frame_ff)
|
60 |
+
fbox.append(f'{uid}/{int(frame_count)-1}.png')
|
61 |
capture.release()
|
62 |
return fbox,fbox
|
63 |
|
|
|
118 |
frame_count=gr.Textbox()
|
119 |
outp_file=gr.Files()
|
120 |
with gr.Tab("Frames"):
|
121 |
+
frame_btn = gr.Button("Get Frames")
|
122 |
+
with gr.Row():
|
123 |
+
with gr.Column():
|
124 |
+
frame_gal = gr.Gallery(columns=6,show_label=True)
|
125 |
+
with gr.Column():
|
126 |
+
frame_file = gr.Files()
|
127 |
|
128 |
with gr.Tab("Rem BG"):
|
129 |
with gr.Row():
|