import cv2 from ultralytics import YOLO from ultralytics.utils.plotting import Annotator model = YOLO("my_model.pt") # Run inference results = model("datasets/socker/valid/images/img_307_jpeg.rf.8ee20e9d3ea38fa3a62c2495e7e824e3.jpg", imgsz=1920) print(results) # Draw bounding boxes on the image result = results[0] annotator = Annotator(result.orig_img, line_width=3) boxes = result.boxes for box in boxes: b = box.xyxy[0] c = box.cls annotator.box_label(b, model.names[int(c)], color=(0, 0, 255)) img = annotator.result() cv2.imshow('YOLO V8 Detection', img) cv2.waitKey(0)