import cv2 from ultralytics import YOLO import gradio as gr def fonk(img_path): model=YOLO("best.pt") img= cv2.imread(img_path, cv2.IMREAD_UNCHANGED) results= model(img) for result in results: if result.boxes is not None and len(result.boxes): box = result.boxes x1, y1, x2, y2 = map(int, box.xyxy[0]) img = cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) return img demo = gr.Interface(fonk, inputs= gr.Image(type="filepath"), outputs=gr.Image(), #examples= "images.jpeg" ) demo.launch()