kixr's picture
detection model added
ba4b32e verified
raw
history blame
1.03 kB
# import gradio as gr
# def greet(name):
# return "Hello " + name + "!!"
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()
import gradio as gr
from ultralytics import YOLO
from PIL import Image
#Load model
model = YOLO('yolov8n.pt')
def image_display(input_image):
# Return the input image as the output
model = YOLO('yolov8n.pt')
results = model(input_image)
for r in results:
im_array = r.plot() # plot a BGR numpy array of predictions
im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
return im_array
input_component = gr.inputs.Image()
output_component = gr.outputs.Image()
# Create the Gradio interface
gr.Interface(
fn=image_display,
inputs=input_component,
outputs=output_component,
title="Image Display App",
description="Upload an image and see it displayed.",
theme="compact"
).launch(share=True)
# demo = gr.Interface(
# fn=greet,
# inputs='textbox',
# outputs='textbox',
# )
# demo.launch()