Spaces:
Sleeping
Sleeping
File size: 758 Bytes
82b42af 903bdfb 82b42af 903bdfb 82b42af 903bdfb |
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 34 35 36 37 |
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()
# Example images
examples = [
"exm_1.jpg",
"exm_3.jpg"
]
# Create Gradio interface
demo = gr.Interface(
fn=predict,
inputs=gr.Image(),
outputs=gr.Image(),
title="HockeyAI",
description="Upload an image to detect 7 differnt objects using a finetuned YOLOv8 for Icek Hockey frames.",
examples=examples
)
demo.launch()
|