Spaces:
Sleeping
Sleeping
| 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() | |