Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,7 @@ def segment_webcam():
|
|
| 44 |
|
| 45 |
def process_inputs(start_button, stop_button, mode_selection, uploaded_video):
|
| 46 |
global process
|
| 47 |
-
if start_button:
|
| 48 |
process = True
|
| 49 |
if mode_selection == "Video" and uploaded_video:
|
| 50 |
segment_video(uploaded_video)
|
|
@@ -53,16 +53,28 @@ def process_inputs(start_button, stop_button, mode_selection, uploaded_video):
|
|
| 53 |
elif stop_button:
|
| 54 |
process = False
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
iface = gr.Interface(
|
| 57 |
fn=process_inputs,
|
| 58 |
-
inputs=[
|
| 59 |
-
gr.components.Button(label="Start"),
|
| 60 |
-
gr.components.Button(label="Stop"),
|
| 61 |
-
gr.components.Radio(["Video", "Webcam"], label="Mode Selection"),
|
| 62 |
-
gr.components.File(label="Upload Video")
|
| 63 |
-
],
|
| 64 |
outputs=None,
|
| 65 |
-
live=True
|
|
|
|
|
|
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
iface.launch()
|
|
|
|
| 44 |
|
| 45 |
def process_inputs(start_button, stop_button, mode_selection, uploaded_video):
|
| 46 |
global process
|
| 47 |
+
if start_button and mode_selection:
|
| 48 |
process = True
|
| 49 |
if mode_selection == "Video" and uploaded_video:
|
| 50 |
segment_video(uploaded_video)
|
|
|
|
| 53 |
elif stop_button:
|
| 54 |
process = False
|
| 55 |
|
| 56 |
+
start_button = gr.components.Button(label="Start", color="green", disabled=True)
|
| 57 |
+
stop_button = gr.components.Button(label="Stop", color="red", disabled=True)
|
| 58 |
+
mode_selection = gr.components.Radio(["Video", "Webcam"], label="Mode Selection")
|
| 59 |
+
uploaded_video = gr.components.File(label="Upload Video")
|
| 60 |
+
|
| 61 |
+
def on_mode_change(_, __, mode):
|
| 62 |
+
if mode == "Webcam":
|
| 63 |
+
uploaded_video.disable()
|
| 64 |
+
else:
|
| 65 |
+
uploaded_video.enable()
|
| 66 |
+
start_button.enable()
|
| 67 |
+
|
| 68 |
+
mode_selection.on_change(on_mode_change)
|
| 69 |
+
|
| 70 |
iface = gr.Interface(
|
| 71 |
fn=process_inputs,
|
| 72 |
+
inputs=[start_button, stop_button, mode_selection, uploaded_video],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
outputs=None,
|
| 74 |
+
live=True,
|
| 75 |
+
title="YOLO Image Segmentation",
|
| 76 |
+
description="This application uses the YOLO model to perform image segmentation on a video or webcam feed. Select a mode, upload a video (if applicable), and click 'Start' to begin. Click 'Stop' to end the process.",
|
| 77 |
+
theme="huggingface"
|
| 78 |
)
|
| 79 |
|
| 80 |
iface.launch()
|