Skip to content

Paulogb98/PlateScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PlateScanner

GitHub stars GitHub issues GitHub license Python 3.10+ PyTorch ONNX Docker

About β€’ Features β€’ Requirements β€’ Installation β€’ Usage β€’ Performance β€’ Contributing β€’ License


About

PlateScanner is a production-ready system for automatic vehicle license plate detection and character recognition. Using YOLOv5 for detection and ONNX-based OCR for character recognition, it processes images end-to-end: detects plates, extracts regions, recognizes characters, and exports results to CSV.

Deploy on CPU for accessibility or GPU for high-throughput processing with Docker.


Features

  • 🎯 End-to-End Pipeline - Automatic detection, cropping, and OCR
  • 🌍 Global Support - Trained on 9,000+ images from 50+ countries
  • πŸš€ High Performance - 300+ plates/second on CPU, faster on GPU
  • πŸ“Š 98% Accuracy - mAP@0.5 of 0.98 on detection task
  • 🐳 Docker Ready - CPU and GPU variants included
  • πŸ”„ Batch Processing - Process multiple images efficiently
  • πŸ“ CSV Export - Structured results with confidence scores

Requirements

  • Python: 3.10 - 3.12 (strongly recommended)
  • Docker & Docker Compose: Optional but recommended
  • GPU (Optional): NVIDIA with CUDA 11.0+ support

System Resources

Resource Minimum Recommended
Memory 512 MB 2 GB
Disk 2 GB 4 GB
CPU 1 core 4+ cores

Installation

Option 1: Docker (Recommended)

CPU Version:

git clone https://github.com/Paulogb98/PlateScanner.git
cd PlateScanner

# Download models and prepare images (see Setup below)

docker compose up -d --build platescanner-cpu

GPU Version (NVIDIA):

# Install NVIDIA Container Toolkit first:
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html

docker compose up -d --build platescanner-gpu

Option 2: Local Python

git clone https://github.com/Paulogb98/PlateScanner.git
cd PlateScanner

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

pip install -r requirements.txt

# Download models and prepare images (see Setup below)

python src/main.py

Setup Guide

Step 1: Download Pre-trained Models

Models are available on Google Drive.

Required files:

File Destination
yolo_detector_model.pt models/detector/
config.json models/detector/
license_plates_ocr_model.onnx models/recognizer/
license_plates_ocr_config.yaml models/recognizer/
license_plates_ocr_results.json models/recognizer/

Step 2: Prepare Input Images

Place images in data/raw/ directory:

Supported formats: .jpg, .jpeg, .png

data/
β”œβ”€β”€ raw/
β”‚   β”œβ”€β”€ image1.jpg
β”‚   β”œβ”€β”€ image2.png
β”‚   └── image3.jpeg

Step 3: Run Application

Docker:

docker compose up -d --build platescanner-cpu
docker compose logs -f

Python:

python src/main.py

Step 4: Access Results

Results are available in data/results/ocr_results.csv:

Image Name,Extracted Value
image1.jpg,ABC1234
image2.jpg,XYZ9876

Processed images are in data/processed/:

  • detected/ - Images with bounding boxes
  • cropped/ - Extracted plate regions

Usage

Basic Workflow

  1. Place images in data/raw/
  2. Run the application
  3. Check data/results/ocr_results.csv for results
  4. Review annotated images in data/processed/

Python API

from classes.detector import YOLOv5Inference
from classes.recognizer import ONNXPlateRecognizer

# Detection
detector = YOLOv5Inference("models/detector/yolo_detector_model.pt")
results = detector.infer("path/to/image.jpg")
detector.process_results(results, "image.jpg", output_dir="data/processed")

# Recognition
recognizer = ONNXPlateRecognizer(
    "models/recognizer/license_plates_ocr_model.onnx",
    "models/recognizer/license_plates_ocr_config.yaml"
)
recognizer.process_cropped_images("data/processed/cropped", "data/results")

Performance

Benchmarks

Hardware Speed Throughput
CPU (8-core) ~80ms/image 12.5 plates/s
GPU (RTX 3060) ~15ms/image 67 plates/s
GPU (RTX 4090) ~8ms/image 125 plates/s

Model Metrics

Metric Value
Detection mAP@0.5 0.98
Character Accuracy ~93%
Supported Formats 50+ countries
Dataset Size 9,000+ images

Directory Structure

PlateScanner/
β”œβ”€β”€ classes/
β”‚   β”œβ”€β”€ detector.py          # YOLOv5 detection
β”‚   └── recognizer.py        # ONNX OCR
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/                 # Input images
β”‚   β”œβ”€β”€ processed/
β”‚   β”‚   β”œβ”€β”€ detected/        # Images with boxes
β”‚   β”‚   └── cropped/         # Plate regions
β”‚   └── results/
β”‚       └── ocr_results.csv  # Results
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ detector/
β”‚   β”‚   β”œβ”€β”€ config.json
β”‚   β”‚   └── yolo_detector_model.pt
β”‚   └── recognizer/
β”‚       β”œβ”€β”€ license_plates_ocr_config.yaml
β”‚       β”œβ”€β”€ license_plates_ocr_model.onnx
β”‚       └── license_plates_ocr_results.json
β”œβ”€β”€ src/
β”‚   └── main.py
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── README.md

Troubleshooting

Docker GPU not working

Ensure NVIDIA Container Toolkit is installed:

# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
docker run --rm --gpus all nvidia/cuda:11.0-runtime nvidia-smi

Model files not found

Download from Google Drive and extract to correct directories.

No detections found

Verify image quality and ensure license plates are clearly visible. Try with sample images first.

Out of memory

Reduce batch size or process images individually. Consider using CPU version with smaller images.


Fine-tuning (Advanced)

To specialize the detection model for specific plate types:

yolov5 train \
  --data data.yaml \
  --img 640 \
  --batch 16 \
  --weights models/detector/yolo_detector_model.pt \
  --epochs 10

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'feat: add YourFeature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

Areas for Contribution

  • Additional plate format support
  • Performance optimizations
  • Test datasets
  • Documentation improvements
  • Web API interface
  • Cloud deployment guides

License

This project is licensed under the MIT License - see LICENSE for details.

Attribution: OCR modules adapted from fast_plate_ocr.


Contact

πŸ“§ Email: paulogb98@outlook.com

πŸ”— LinkedIn: https://www.linkedin.com/in/paulo-goiss/


Acknowledgments

  • Ultralytics - YOLOv5 framework
  • ONNX - Model interoperability
  • OpenCV - Computer vision library
  • PyTorch - Deep learning framework
  • fast_plate_ocr - OCR implementation reference

Built with ❀️ using Python, PyTorch & ONNX

πŸ”— Repository β€’ πŸ“ Issues β€’ πŸ“¦ Releases

PlateScanner v1.0 | βœ… Production Ready

About

OCR system for vehicle license plate detection and recognition using PyTorch, YOLOv5, and ONNX, with automated data processing and results exported to CSV.

Topics

Resources

License

Stars

Watchers

Forks

Contributors