Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +25 -0
- requirements.txt +3 -0
- yolov8_license_plate.pt +3 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralytics import YOLO
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Load the trained YOLOv8 model
|
| 7 |
+
model = YOLO("yolov8_license_plate.pt") # Path where you uploaded the model
|
| 8 |
+
|
| 9 |
+
# Define prediction function
|
| 10 |
+
def detect_objects(image):
|
| 11 |
+
results = model(image) # Perform inference
|
| 12 |
+
result_img = results[0].plot() # Draw bounding boxes
|
| 13 |
+
return Image.fromarray(result_img.astype(np.uint8)) # Ensure correct image format
|
| 14 |
+
|
| 15 |
+
# Build Gradio interface
|
| 16 |
+
interface = gr.Interface(
|
| 17 |
+
fn=detect_objects,
|
| 18 |
+
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 19 |
+
outputs=gr.Image(type="pil", label="Detected Image"),
|
| 20 |
+
title="License Plate Detection (YOLOv8)",
|
| 21 |
+
description="Upload an image. The model will detect license plates using YOLOv8."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Launch the interface
|
| 25 |
+
interface.launch(debug=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ultralytics
|
| 2 |
+
gradio
|
| 3 |
+
pillow
|
yolov8_license_plate.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d40a3545ad6233df455577e0235ec863da1f89b998e46098a07d2d15d6651fb7
|
| 3 |
+
size 6248227
|