Skip to content

Commit

Permalink
added benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulgoel873 committed Jan 5, 2025
1 parent edb14cb commit 2d0d09e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions vision/ultralytics-benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import cv2

from ultralytics import YOLO

# Load the YOLO11 model
model = YOLO("best.pt")

# Open the video file
video_path = "data\9-21-whobaat1.avi"
cap = cv2.VideoCapture(video_path)

subsample = 5

i = 0
# Loop through the video frames
while cap.isOpened():
# Read a frame from the video
success, frame = cap.read()
i += 1
if (i % subsample != 0):
continue
if success:
# Run YOLO11 tracking on the frame, persisting tracks between frames
results = model.track(frame, persist=True)

# Visualize the results on the frame
annotated_frame = results[0].plot()

# Display the annotated frame
cv2.imshow("YOLO11 Tracking", annotated_frame)

# Break the loop if 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord("q"):
break
else:
# Break the loop if the end of the video is reached
break

# Release the video capture object and close the display window
cap.release()
cv2.destroyAllWindows()

0 comments on commit 2d0d09e

Please sign in to comment.