komaldosanjhh's picture
Update app.py
27a8b03 verified
raw
history blame contribute delete
772 Bytes
import gradio as gr
import numpy as np
from PIL import Image
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
# Download model from Hugging Face
model_path = hf_hub_download(repo_id="keremberke/yolov5n-license-plate", filename="best.pt")
# Load YOLO model using ultralytics
model = YOLO(model_path)
def detect_license_plate(image):
results = model(image)
# Get annotated image
result_img = results[0].plot()
return Image.fromarray(result_img)
interface = gr.Interface(
fn=detect_license_plate,
inputs=gr.Image(type="pil"),
outputs=gr.Image(type="pil"),
title="License Plate Detection",
description="Upload an image to detect license plates using YOLOv5."
)
if __name__ == "__main__":
interface.launch()