TashiKP commited on
Commit
7764610
·
verified ·
1 Parent(s): 765e1c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -8,8 +8,9 @@ from datetime import datetime
8
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
9
 
10
  def detect_video(video):
11
- cap = cv2.VideoCapture(video) # Directly use the video path
12
-
 
13
  # List to hold results
14
  detection_results = []
15
 
@@ -39,10 +40,10 @@ def detect_video(video):
39
 
40
  # Gradio Interface
41
  interface = gr.Interface(fn=detect_video,
42
- inputs=gr.Video(), # Correct input
43
  outputs="json",
44
  live=True,
45
- share=True,
46
  title="YOLOv5 Video Object Detection",
47
  description="Upload a video to detect objects and get bounding boxes with timestamps.")
48
 
 
8
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
9
 
10
  def detect_video(video):
11
+ # Use the video file provided by Gradio
12
+ cap = cv2.VideoCapture(video.name) # video.name gives the path to the temporary file
13
+
14
  # List to hold results
15
  detection_results = []
16
 
 
40
 
41
  # Gradio Interface
42
  interface = gr.Interface(fn=detect_video,
43
+ inputs=gr.Video(), # Correct input for video
44
  outputs="json",
45
  live=True,
46
+ share=True, # Share the interface publicly
47
  title="YOLOv5 Video Object Detection",
48
  description="Upload a video to detect objects and get bounding boxes with timestamps.")
49