Skip to content

Shailesh22290/SmartVehEntryAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— SmartVehEntryAI

An AI-powered vehicle entry management system with dual interfaces for staff and administrators. Detects license plates with YOLO, extracts text using PaddleOCR, validates it with a robust Regex layer, and provides comprehensive vehicle tracking with entry/exit management.

Designed for smart gates, parking systems, security checkpoints, and access-controlled facilities.

SmartVehEntryAI

Features

Core AI Pipeline

  • YOLOv8-based Plate Detection – Custom-trained for high accuracy on Indian number plates.
  • Robust OCR with PaddleOCR – Extracts text from plates, even in challenging conditions.
  • Advanced Number Plate Validation – A powerful regex layer cleans raw OCR output (e.g., removes noise like "IND") and validates the text against multiple official Indian formats (Standard, BH-Series, Army, Diplomatic, etc.) to ensure high data accuracy.
  • End-to-End Workflow: Image/Video β†’ Detect Plate β†’ Extract Text β†’ Validate & Clean β†’ Log Result.
  • Versatile Input – Works with images, videos, and live camera feeds.
  • Real-World Ready – Handles glare, skewed angles, and low-light conditions.

SmartVehEntryAI


πŸ“‚ Project Structure

SmartVehEntryAI/
β”‚
β”œβ”€β”€ app.py                  # Staff interface (FastAPI) with OCR & Regex logic
β”œβ”€β”€ admin.py                # Admin panel (FastAPI)
β”œβ”€β”€ database.py             # Database models and setup
β”œβ”€β”€ plate_reader.py         # Core detection + OCR pipeline
β”‚
β”œβ”€β”€ detection_model.pt      # YOLO model weights
β”œβ”€β”€ vehicles.db             # SQLite database (auto-created)
β”‚
β”œβ”€β”€ dataset/                # Training / testing data
β”‚   β”œβ”€β”€ train/              # Training images & labels
β”‚   β”œβ”€β”€ val/                # Validation images & labels
β”‚   └── test/               # Test images & labels
β”‚
β”œβ”€β”€ runs/                   # YOLO training outputs (weights, logs)
β”œβ”€β”€ scripts/                # Utility scripts (e.g., data prep)
β”œβ”€β”€ static/                 # Annotated images (auto-created)
β”‚
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ start.bat               # Windows startup script
β”œβ”€β”€ start.sh                # Linux/Mac startup script
└── README.md

πŸ—„οΈ Database Schema

The SmartVehEntryAI system utilizes an SQLite database (easily adaptable to PostgreSQL) to manage vehicle logs and banned vehicle records. Below is a detailed breakdown of the tables and their respective fields:

vehicle_logs Table

This table stores comprehensive records of all vehicle entries and exits, including detection details and operational metadata.

Column Name Data Type Constraints Description
id Integer PRIMARY KEY, INDEX Unique identifier for each vehicle log entry.
vehicle_number String(20) INDEX, NOT NULL The detected and validated license plate number.
driver_name String(100) NULLABLE Name of the vehicle's driver.
vehicle_type String(50) NULLABLE Type of vehicle (e.g., Car, Truck, Motorcycle).
entry_time DateTime NOT NULL, DEFAULT=datetime.now, INDEX Timestamp when the vehicle entered or was first logged.
exit_time DateTime NULLABLE, DEFAULT=None, INDEX Timestamp when the vehicle exited, if applicable.
status String(10) DEFAULT="ENTRY" Current status of the vehicle log (ENTRY or implicitly EXIT if exit_time is set).
operator_id String(50) DEFAULT="system" Identifier for the operator who logged the entry (or "system").
image_path Text NULLABLE Path to the image file associated with the log entry.
gate_id String(50) DEFAULT="main_gate" Identifier for the gate where the entry/exit occurred.
remarks Text DEFAULT="" Any additional remarks or notes for the entry.

Indexes:

  • idx_entry_time on entry_time
  • idx_exit_time on exit_time
  • idx_vehicle_exit on vehicle_number, exit_time

banned_vehicles Table

This table stores records of vehicles that are prohibited from entering the facility.

Column Name Data Type Constraints Description
id Integer PRIMARY KEY, INDEX Unique identifier for each banned vehicle record.
vehicle_number String(20) INDEX, NOT NULL, UNIQUE The license plate number of the banned vehicle.
reason Text NULLABLE Reason for banning the vehicle.
banned_at DateTime NOT NULL, DEFAULT=datetime.now Timestamp when the vehicle was added to the banned list.
banned_by String(50) DEFAULT="admin" User or system responsible for banning the vehicle.


πŸš€ Installation

1️⃣ Clone & create a virtual environment

git clone https://github.com/shailesh22290/SmartVehEntryAI.git
cd SmartVehEntryAI

conda create -n veh_ai python=3.10
conda activate veh_ai

2️⃣ Install dependencies

pip install --upgrade pip
pip install -r requirements.txt

Requirements: Python β‰₯3.10, CUDA-enabled PyTorch for GPU (optional but recommended).


⚑ Usage

Run Both Interfaces

Windows:

# Double-click or run from terminal:
start.bat

Linux/Mac:

chmod +x start.sh
./start.sh

# http://0.0.0.0:8000/ for Input 
# http://0.0.0.0:8000/admin/login for Management

Admin Panel | Username: admin
Password: admin123


🧠 Training (YOLO)

To retrain the YOLOv8 model on your custom dataset, run the following command:

yolo task=detect mode=train model=yolov8n.pt data=dataset.yaml epochs=50 imgsz=640

dataset.yaml:

train: dataset/train/images
val: dataset/val/images
nc: 1
names: ["number_plate"]

Training results

SmartVehEntryAI
SmartVehEntryAI

Validation

SmartVehEntryAI

Result

  • Snapshot of the frontend showing the Model ouptut and a form to save the details in the database. This inteface will be used by the staff at the main gate.

SmartVehEntryAI

  • Snapshot of the Admin Panel showing the interface that will be displayed to the Admin for monitering and managing the entry/exit process.

SmartVehEntryAI


πŸ› οΈ Tech Stack

Backend

  • FastAPI – Modern, high-performance web framework.
  • SQLAlchemy – ORM for database interaction.
  • Uvicorn – Lightning-fast ASGI server.

AI/ML

  • YOLOv8 – State-of-the-art license plate detection.
  • PaddleOCR – High-accuracy OCR engine.
  • OpenCV – Real-time computer vision and image processing.
  • Python re Module - For number plate cleaning and regex validation.

Frontend

  • Tailwind CSS – Utility-first CSS framework for rapid UI development.
  • Chart.js – Simple yet flexible data visualization.
  • Material Icons – Clean and modern icons.
  • Vanilla JavaScript – Lightweight and efficient, with no framework overhead.

Database

  • SQLite (Default) – Easy setup, ideal for development and small-scale deployment.
  • PostgreSQL (Production Ready) – Easily adaptable for a scalable and robust database.

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

License

This project is released under the MIT License.

For commercial use or enterprise deployment, please contact the maintainers.


Acknowledgments

  • YOLOv8 by Ultralytics
  • PaddleOCR by PaddlePaddle
  • The FastAPI framework and its community
  • Tailwind CSS
  • Chart.js

Support

For issues, questions, or contributions, please use the following channels:


About

Automatic Vehcile Entry Management System

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages