Skip to content

Repository files navigation

AutoPlateTN - Automatic Tunisian License Plate Recognition System

Python PyTorch License Streamlit

An end-to-end deep learning pipeline for detecting and recognizing Tunisian license plates in images. Built with state-of-the-art object detection and OCR models, featuring an interactive web interface.

DemoFeaturesQuick StartResultsUsage


Demo

Complete Pipeline Visualization

1️ Vehicle Detection

Vehicle Detection Cascade R-CNN detects all vehicles in the image with bounding boxes

2️ License Plate Detection

Plate Detection Faster R-CNN localizes license plates on detected vehicles

3️ Plate Enhancement

Plate Enhancement Advanced image preprocessing: denoising, upscaling (4x-6x), CLAHE, binarization

4️ Final OCR Results

Final Results CRNN model reads characters and formats plates in Tunisian standard (Arabic + digits)


Features

Multi-Stage Detection Pipeline

  • Stage 1: Vehicle Detection using Cascade R-CNN
  • Stage 2: License Plate Detection using Faster R-CNN
  • Stage 3: Adaptive Image Enhancement (4 methods)
  • Stage 4: OCR Recognition using CRNN with CTC Loss

Advanced Image Processing

  • 4 Enhancement Methods: Original, Light, Full (recommended), Aggressive
  • Techniques:
    • Denoising (fastNlMeans)
    • Super-resolution upscaling (4x-6x)
    • Contrast enhancement (CLAHE)
    • Gamma correction
    • Bilateral filtering
    • Adaptive binarization
    • Morphological operations

Interactive Web Interface

  • Built with Streamlit for easy deployment
  • Real-time processing with live visualization
  • Adjustable confidence thresholds
  • Multiple enhancement method selection
  • Downloadable results

Tunisian Plate Support

  • Recognizes both standard and private plates
  • Automatic formatting with Arabic text (تونس / نت)
  • Proper number grouping and centering
  • Format: XXX تونس XXXX or XXXXXX نت

Quick Start

Prerequisites

  • Python 3.8+
  • CUDA-capable GPU (optional, for faster processing)
  • Git

Installation

  1. Clone the repository
git clone https://github.com/Malek-logh/AutoPlateTN.git
cd AutoPlateTN
  1. Clone Detectron2 (no pip install needed)
git clone https://github.com/facebookresearch/detectron2.git
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install opencv-python numpy pandas streamlit pillow tqdm
pip install fvcore
  1. Download pre-trained models
    • Place your trained models in models/detection/ and models/ocr/
    • Required files:
      • cascade_best.pth (vehicle detection)
      • fasterrcnn_tunisia_plates.pth (plate detection)
      • best_crnn_model.pth (OCR)
      • Optional: best_crnn_light.pth, best_crnn_full.pth, best_crnn_aggressive.pth

Run the Application

Option 1: Streamlit Web Interface (Recommended)

streamlit run app.py

Then open your browser at http://localhost:8501

Option 2: Command Line Pipeline

# Step 1: Detect vehicles
python vehicle_detection_inference.py

# Step 2: Detect plates
python platedetectortest.py

# Step 3: Enhance plates
python src/preprocessing/image_enhancing.py

# Step 4: Run OCR
python test_crnn_model.py

Usage

Web Interface

  1. Launch the app: streamlit run app.py
  2. Upload an image containing vehicles
  3. Adjust confidence thresholds if needed
  4. Select enhancement method (Full recommended)
  5. Click "Start Processing"
  6. View results with formatted plate numbers

Model Training (Optional)

If you want to train your own models:

1. Vehicle Detection

2. Plate Detection

3. OCR Model

Star this repository if you find it helpful!

About

A complete end-to-end system for detecting vehicles, localizing license plates, enhancing plate images, and performing OCR to extract Tunisian plate numbers. This project combines object detection, image processing, and deep-learning OCR to build a full ALPR pipeline suitable for real-time or batch processing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages