from ultralytics import YOLO # Load a pre-trained YOLOv8n model # Net downloaded from https://github.com/noorkhokhar99/face-detection-yolov8 model = YOLO('yolov8n-face.pt') names = model.model.names # Perform inference on 'bus.jpg' with specified parameters with conf=0.5 results = model.predict("/home/luca/git_repos/telegram_amicobot/data/photos/Grigliate_105.jpg", verbose=False, conf=0.7, device='cpu') # Process detections boxes = results[0].boxes.xywh.cpu() clss = results[0].boxes.cls.cpu().tolist() confs = results[0].boxes.conf.float().cpu().tolist() for box, cls, conf in zip(boxes, clss, confs): print(f"Class Name: {names[int(cls)]}, Confidence Score: {conf}, Bounding Box: {box}")