Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,13 +54,17 @@ def process_video(video_path, output_option):
|
|
54 |
if hasattr(result, 'boxes'):
|
55 |
object_count += len(result.boxes)
|
56 |
|
|
|
|
|
|
|
|
|
57 |
# Determine the output based on user's choice
|
58 |
if output_option == "Count":
|
59 |
-
return
|
60 |
elif output_option == "Video":
|
61 |
-
return
|
62 |
elif output_option == "Both":
|
63 |
-
return
|
64 |
|
65 |
# Define Gradio inputs
|
66 |
video_input = gr.Video()
|
@@ -76,7 +80,7 @@ examples = [
|
|
76 |
video_interface = gr.Interface(
|
77 |
fn=process_video,
|
78 |
inputs=[video_input, output_option_input],
|
79 |
-
outputs=[gr.Textbox(label="Object Count"), "video"], #
|
80 |
title="YOLO Video Tracking Application",
|
81 |
description="A simple application to track objects in a video using YOLO model. Upload your own video, or click one of the examples to load them.",
|
82 |
article="""<div>
|
|
|
54 |
if hasattr(result, 'boxes'):
|
55 |
object_count += len(result.boxes)
|
56 |
|
57 |
+
# Set default outputs
|
58 |
+
video_output = matched_mp4_files[0] if matched_mp4_files else None
|
59 |
+
count_output = object_count
|
60 |
+
|
61 |
# Determine the output based on user's choice
|
62 |
if output_option == "Count":
|
63 |
+
return count_output, None
|
64 |
elif output_option == "Video":
|
65 |
+
return None, video_output
|
66 |
elif output_option == "Both":
|
67 |
+
return count_output, video_output
|
68 |
|
69 |
# Define Gradio inputs
|
70 |
video_input = gr.Video()
|
|
|
80 |
video_interface = gr.Interface(
|
81 |
fn=process_video,
|
82 |
inputs=[video_input, output_option_input],
|
83 |
+
outputs=[gr.Textbox(label="Object Count"), "video"], # Ensure two outputs are defined
|
84 |
title="YOLO Video Tracking Application",
|
85 |
description="A simple application to track objects in a video using YOLO model. Upload your own video, or click one of the examples to load them.",
|
86 |
article="""<div>
|