Spaces:
Running
Running
File size: 632 Bytes
82b42af |
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
import torch
# Load your model
model = YOLO('HockeyAI_model_weight.pt')
def predict(image):
# Convert gradio image to PIL
if isinstance(image, str):
image = Image.open(image)
# Run inference
results = model.predict(image)
# Get the plotted image with predictions
return results[0].plot()
# Create Gradio interface
demo = gr.Interface(
fn=predict,
inputs=gr.Image(),
outputs=gr.Image(),
title="YOLOv8 Object Detection",
description="Upload an image to detect objects using YOLOv8"
)
demo.launch() |