Spaces:
Sleeping
Sleeping
from ultralytics import YOLO | |
import cv2 | |
model = YOLO("runs/detect/weights/best.pt") | |
video_path = "test_video.mp4" | |
cap = cv2.VideoCapture(video_path) | |
while cap.isOpened(): | |
ret, frame = cap.read() | |
if not ret: break | |
results = model(frame, conf=0.5, imgsz=640, augment=False) | |
annotated_frame = results[0].plot() | |
cv2.imshow("Video Detection", annotated_frame) | |
if cv2.waitKey(1) == ord('q'): break | |
cap.release() | |
cv2.destroyAllWindows() |