File size: 743 Bytes
ad671e3
ba4b32e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f8a16f
 
ba4b32e
 
 
 
 
 
 
 
 
0f8a16f
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
28
29
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.Image()
output_component = gr.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)