Nepal Vehicle License Plates Detection Model (YOLOv8 Small)
This is a lightweight and efficient YOLOv8 Small model trained to detect vehicle license plates in Nepal. The model is optimized for deployment on various devices, including edge devices and low-resource environments, making it suitable for real-world applications like traffic monitoring, toll systems, and surveillance.
Try the Model in Action
You can test the model interactively on Hugging Face Spaces. Upload an image, and the app will detect vehicle license plates and display bounding boxes with confidence scores.
๐ Test the Model Here
Model Overview
- Architecture: YOLOv8 Small
- Dataset: Vehicle license plates in Nepal (custom dataset)
- Performance:
- Precision (P): 0.973
- Recall (R): 0.956
- mAP@50: 0.988
- mAP@50-95: 0.929
- Size: 22.5 MB
- Training Duration:
24 epochs (0.8 hours on Tesla T4 GPU)
This model is lightweight and designed to balance accuracy and efficiency, making it highly deployable in various scenarios.
Try Our Nano Model for Low-Resource Devices
If you are working in low-resource environments or require an even smaller model for deployment, consider using our YOLOv8 Nano model. It achieves similar results to this Small model but requires significantly less computational power and memory.
- Nano Model Repository: Nepal Vehicle License Plate Detection (Nano)
The Nano model is ideal for:
- Devices with limited resources like Raspberry Pi Zero, Arduino Portenta, and similar hardware.
- Scenarios where trade-offs in performance for size and speed are necessary.
Features
- Detects vehicle license plates with high accuracy.
- Optimized for real-time applications on low-resource devices.
- Robust to common variations such as lighting and orientation.
# Example Code: To Test model in Google Colab Just Copy Paste
# Install necessary libraries
!pip install ultralytics
!pip install -q huggingface_hub
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
import cv2
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
# Step 1: Download the YOLO model weights from your Hugging Face repository
weights_path = hf_hub_download(repo_id="krishnamishra8848/Nepal-Vehicle-License-Plate-Detection", filename="last.pt")
# Step 2: Load the YOLO model
model = YOLO(weights_path)
# Step 3: Function to process and display results
def detect_license_plate(image_path):
# Load and preprocess the image
image = Image.open(image_path).convert('RGB')
img = np.array(image)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
# Perform inference
results = model(img)
# Draw bounding boxes and confidence scores
for result in results:
if hasattr(result, 'boxes') and result.boxes is not None:
for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
x1, y1, x2, y2 = map(int, box) # Convert to integers
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
label = f"Confidence: {conf:.2f}"
cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
# Display the image with bounding boxes
plt.figure(figsize=(10, 10))
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.show()
# Step 4: Upload an image and run inference
from google.colab import files
uploaded = files.upload() # Use Colab's file uploader
for filename in uploaded.keys():
print(f"Processing {filename}...")
detect_license_plate(filename)