Khalida1w commited on
Commit
297c2d0
1 Parent(s): cd3b30d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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 object_count
60
  elif output_option == "Video":
61
- return matched_mp4_files[0]
62
  elif output_option == "Both":
63
- return object_count, matched_mp4_files[0]
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"], # Update outputs to support multiple types
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>