himisir
commited on
Commit
·
7139752
1
Parent(s):
0508e39
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from ultralytics import YOLO
|
|
5 |
|
6 |
|
7 |
def load_yolo_model():
|
8 |
-
return YOLO()
|
9 |
|
10 |
|
11 |
def process_video(model, cap):
|
@@ -39,12 +39,15 @@ def segment_webcam():
|
|
39 |
process_video(model, cap)
|
40 |
|
41 |
|
42 |
-
def
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
iface = gr.Interface(
|
47 |
-
fn=
|
48 |
inputs=[gr.inputs.Checkbox(label="Segment Video"),
|
49 |
gr.inputs.Checkbox(label="Segment Webcam"),
|
50 |
gr.inputs.File(label="Upload Video")],
|
@@ -52,17 +55,4 @@ iface = gr.Interface(
|
|
52 |
live=True
|
53 |
)
|
54 |
|
55 |
-
|
56 |
-
def update_fn(segment_video_checkbox, segment_webcam_checkbox, uploaded_video):
|
57 |
-
if segment_video_checkbox and uploaded_video:
|
58 |
-
iface.fn = wrapper_for_segment_video
|
59 |
-
iface.args = [uploaded_video]
|
60 |
-
elif segment_webcam_checkbox:
|
61 |
-
iface.fn = segment_webcam
|
62 |
-
iface.args = []
|
63 |
-
else:
|
64 |
-
iface.fn = None
|
65 |
-
|
66 |
-
|
67 |
-
iface.update(update_fn)
|
68 |
iface.launch()
|
|
|
5 |
|
6 |
|
7 |
def load_yolo_model():
|
8 |
+
return YOLO('yolov8n-seg.pt')
|
9 |
|
10 |
|
11 |
def process_video(model, cap):
|
|
|
39 |
process_video(model, cap)
|
40 |
|
41 |
|
42 |
+
def process_inputs(segment_video_checkbox, segment_webcam_checkbox, uploaded_video):
|
43 |
+
if segment_video_checkbox and uploaded_video:
|
44 |
+
segment_video(uploaded_video)
|
45 |
+
elif segment_webcam_checkbox:
|
46 |
+
segment_webcam()
|
47 |
|
48 |
|
49 |
iface = gr.Interface(
|
50 |
+
fn=process_inputs,
|
51 |
inputs=[gr.inputs.Checkbox(label="Segment Video"),
|
52 |
gr.inputs.Checkbox(label="Segment Webcam"),
|
53 |
gr.inputs.File(label="Upload Video")],
|
|
|
55 |
live=True
|
56 |
)
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
iface.launch()
|