|
import gradio as gr |
|
import cv2 |
|
import requests |
|
import os |
|
|
|
from ultralytics import YOLO |
|
|
|
path = ['./data/0068.jpg', './data/0210.jpg', './data/IMG_7078.jpg', './data/IMG_7103.jpg', './data/IMG_7705.jpg'] |
|
|
|
model_path = './best.pt' |
|
model = YOLO(model_path) |
|
|
|
def detect_cheerios(image_path): |
|
|
|
results = model(image_path) |
|
image = results[0].plot() [:,:,::-1] |
|
|
|
return image |
|
|
|
iface = gr.Interface( |
|
fn=detect_cheerios, |
|
inputs=gr.components.Image(type="filepath", label="Input Image"), |
|
outputs=gr.Image(), |
|
title="Cheerios detector", |
|
description='Check out our blog at <a href="https://falcon.duality.ai/secure/documentation?learnWelcome=true&sidebarMode=learn" target="_blank">this link</a>.', |
|
examples= path, |
|
|
|
) |
|
|
|
|
|
iface.launch() |