Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,26 +108,29 @@ def process_image(image):
|
|
| 108 |
|
| 109 |
return Image.fromarray(img)
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
| 115 |
with gr.Tabs():
|
| 116 |
with gr.TabItem("Video Detection"):
|
| 117 |
with gr.Row():
|
| 118 |
-
video_input = gr.Video(label="Upload Video")
|
| 119 |
-
process_button = gr.Button("Process Video")
|
| 120 |
-
video_output = gr.Video(label="Processed Video")
|
| 121 |
process_button.click(fn=process_video, inputs=video_input, outputs=video_output)
|
| 122 |
|
| 123 |
with gr.TabItem("Image Detection"):
|
| 124 |
with gr.Row():
|
| 125 |
-
image_input = gr.Image(type="pil", label="Upload Image",
|
| 126 |
-
image_output = gr.Image(label="Detected Objects", width=256, height=256)
|
| 127 |
with gr.Row():
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
clear_button.click(fn=lambda: None, inputs=None, outputs=image_output)
|
| 131 |
submit_button.click(fn=process_image, inputs=image_input, outputs=image_output)
|
| 132 |
|
| 133 |
demo.launch()
|
|
|
|
|
|
| 108 |
|
| 109 |
return Image.fromarray(img)
|
| 110 |
|
| 111 |
+
with gr.Blocks(title="Real-Time YOLOv5 Video & Image Object Detection") as demo:
|
| 112 |
+
gr.Markdown("""
|
| 113 |
+
# Real-Time YOLOv5 Object Detection
|
| 114 |
+
""", elem_id="title")
|
| 115 |
+
|
| 116 |
with gr.Tabs():
|
| 117 |
with gr.TabItem("Video Detection"):
|
| 118 |
with gr.Row():
|
| 119 |
+
video_input = gr.Video(label="Upload Video", interactive=True, elem_id="video-input")
|
| 120 |
+
process_button = gr.Button("Process Video", variant="primary", elem_id="video-process-btn")
|
| 121 |
+
video_output = gr.Video(label="Processed Video", elem_id="video-output")
|
| 122 |
process_button.click(fn=process_video, inputs=video_input, outputs=video_output)
|
| 123 |
|
| 124 |
with gr.TabItem("Image Detection"):
|
| 125 |
with gr.Row():
|
| 126 |
+
image_input = gr.Image(type="pil", label="Upload Image", tool="editor", elem_id="image-input")
|
|
|
|
| 127 |
with gr.Row():
|
| 128 |
+
image_output = gr.Image(label="Detected Objects", elem_id="image-output")
|
| 129 |
+
with gr.Row():
|
| 130 |
+
clear_button = gr.Button("Clear", variant="secondary", elem_id="clear-btn")
|
| 131 |
+
submit_button = gr.Button("Detect Objects", variant="primary", elem_id="submit-btn")
|
| 132 |
clear_button.click(fn=lambda: None, inputs=None, outputs=image_output)
|
| 133 |
submit_button.click(fn=process_image, inputs=image_input, outputs=image_output)
|
| 134 |
|
| 135 |
demo.launch()
|
| 136 |
+
|