Spaces:
Runtime error
Runtime error
| import cv2 | |
| from ultralytics import YOLO | |
| import numpy as np | |
| model = YOLO('yolov8n.pt') # Use lightweight model for Spaces | |
| def detect_cheating(frame): | |
| results = model(frame) | |
| boxes = results[0].boxes.xyxy.cpu().numpy() | |
| classes = results[0].boxes.cls.cpu().numpy() | |
| num_persons = sum(1 for c in classes if int(c) == 0) | |
| cheating_flag = num_persons > 1 | |
| return frame, cheating_flag, num_persons | |