File size: 938 Bytes
f7f9344 |
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 30 31 32 33 |
import gradio as gr
from ultralytics import YOLO
import numpy as np
from PIL import Image
# Load YOLO model
model = YOLO("yolo11n-pose.pt") # Replace with your YOLO model path
# Function to process the input image
def process_image(image):
# YOLO inference
results = model(image)
# The result is a list, access the first item
processed_image = results[0].plot() # .plot() returns the image with detections
# Return the processed image for display
return processed_image
# Gradio Interface
iface = gr.Interface(
fn=process_image, # Function to call on image input
inputs=gr.Image(type="pil"), # Image input (Upload an image file)
outputs=gr.Image(type="pil"), # Output processed image
live=True, # Enable live feedback (optional)
title="Object Detection with YOLO",
description="Upload an image for object detection using YOLO."
)
# Launch the Gradio app
iface.launch()
|