Spaces:
Runtime error
Runtime error
File size: 416 Bytes
2cb83ee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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
|