File size: 656 Bytes
be29b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()