File size: 805 Bytes
be29b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1bc2e23
 
405847d
1bc2e23
be29b6d
 
1bc2e23
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
26
27
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", label= "Input image"),
                    outputs=gr.Image(label= "Output image"),
                    examples= [["images.jpeg"],["Screenshot from 2024-02-12 23-14-36.png"]],
                    title= "Detection Cattle from Image"
                    )
demo.launch()