import cv2
from ultralytics import YOLO

model = YOLO('ai/v2_epoch50.pt') 

cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    if not ret:
        break

    results = model(frame)
    annotation = results[0].plot()

    cv2.imshow("YOLO Live Webcam", annotation)

    # 'e' to quit
    if cv2.waitKey(1) & 0xFF == ord('e'):
        break

cap.release()
cv2.destroyAllWindows()