Skip to content

vinugawade/helmet-project

Repository files navigation

Helmet & Number Plate Detection

🚨 Project Overview

This project leverages deep learning techniques to create an intelligent system that can detect bikes, verify helmet usage, and locate number plates in video footage. This solution combines object detection and image classification models, leveraging YOLOv3 for bike and number plate detection, and a custom CNN for helmet classification.

📌 Objective

The objective of this project is to provide an AI-driven solution that can detect bikes, verify helmet usage, and locate number plates from video footage in real-time. This application uses both pre-trained and custom-trained deep learning models to perform these tasks.

🧠 Technology Stack

🎯 Frontend

  • Streamlit: A Python-based web framework used to build and display the real-time video analysis UI.

🧰 Backend / Core Technologies

  • Python 3.10: The core language used for developing the project.
  • OpenCV: Used for video processing and real-time frame capture.
  • YOLOv3 (You Only Look Once): A pre-trained object detection model used for detecting bikes and number plates.
    • Model: yolov3-custom.cfg, yolov3-custom_7000.weights
  • TensorFlow + Keras: Used for loading and utilizing the custom helmet detection model.
    • Model: helmet-nonhelmet_cnn.h5 (CNN-based)
  • Imutils, NumPy, Pillow: Utilities for image and video frame processing.

📦 Installation & Setup

1. Install Python 3.10 and UV

Ensure you have Python 3.10 installed on your system. For managing dependencies, this project uses UV (a dependency management tool).

Install UV

# If UV is not installed, run the following:
pip install uv

2. Go inside project folder

cd helmet-project

3. Create a Virtual Environment

Use UV or venv to create a virtual environment:

# Create a virtual environment using uv
uv venv

Activate the virtual environment:

# For macOS/Linux
source env/bin/activate
# For Windows
env\Scripts\activate

4. Install Dependencies

Install the project dependencies listed in requirements.txt:

# Install dependencies using uv
uv add -r requirements.txt

5. Set Up Environment Variables

Copy the provided .env.example to .env:

cp example.env .env

Update the .env file with the user details as needed:

USER1_EMAIL=demo@example.com
USER1_PASSWORD=password123

USER2_EMAIL=user2@example.com
USER2_PASSWORD=user2password

6. Run the Project

You can now run the application using the following command:

uv run streamlit run main.py

This will start the app locally and open it in your browser. You should be able to login & upload a video and see the real-time helmet and number plate detection results.

💻 Project Structure

Here’s a breakdown of the project files and their purpose:

.
├── README.md                     # Project description & setup instructions
├── example.env                   # Template for environment variables
├── helmet-nonhelmet_cnn.h5        # Custom CNN model for helmet classification
├── helmet_project_summary.md      # Summary and explanation of the project
├── main.py                        # Main entry point for the Streamlit app
├── output.avi                     # Sample output video (for testing)
├── pyproject.toml                 # Project configuration file (for uv)
├── requirements.txt               # Required Python dependencies
├── source.py                      # Detection logic (YOLOv3 and helmet detection)
├── temp                           # Temporary directory for storing uploaded files
├── uv.lock                        # uv dependency lock file
├── yolov3-custom.cfg             # YOLOv3 configuration file
└── yolov3-custom_7000.weights    # YOLOv3 trained weights

🤖 Model Details

YOLOv3 Object Detection

The YOLOv3 model is used for detecting bikes and number plates in each frame of the uploaded video. The detection is performed using the YOLOv3 configuration and weights (yolov3-custom.cfg and yolov3-custom_7000.weights).

Helmet Classification Model

A custom CNN model (helmet-nonhelmet_cnn.h5) is used to classify whether a detected bike rider is wearing a helmet or not. The image of the rider’s head is cropped from the frame and passed to the CNN for classification.

⚙️ Features

  • User Authentication: Login using demo credentials stored in a .env file.
  • Real-time Detection: Upload a video and detect bikes, helmets, and number plates in real-time.
  • Customizable User Management: Add multiple users by modifying the .env file.

Releases

No releases published

Contributors

Languages