ma4389's picture
Upload 3 files
16c3ba2 verified
raw
history blame contribute delete
850 Bytes
from ultralytics import YOLO
import gradio as gr
from PIL import Image
import numpy as np
# Load the trained YOLOv8 model
model = YOLO("yolov8_license_plate.pt") # Path where you uploaded the model
# Define prediction function
def detect_objects(image):
results = model(image) # Perform inference
result_img = results[0].plot() # Draw bounding boxes
return Image.fromarray(result_img.astype(np.uint8)) # Ensure correct image format
# Build Gradio interface
interface = gr.Interface(
fn=detect_objects,
inputs=gr.Image(type="pil", label="Upload Image"),
outputs=gr.Image(type="pil", label="Detected Image"),
title="License Plate Detection (YOLOv8)",
description="Upload an image. The model will detect license plates using YOLOv8."
)
# Launch the interface
interface.launch(debug=True)