Skip to content

AliRazaviJ/Helmet-Detection

Repository files navigation

Helmet Detection

🧠 Overview

The Helmet Detection project leverages deep learning techniques to identify whether individuals are wearing helmets in images or video streams. This system is designed to enhance safety monitoring in various environments, such as construction sites, roadways, and industrial areas.

⚠️ Note: This project is currently under active development. I am working on improving the model to achieve higher accuracy and better generalization across diverse datasets.

🛠️ Use Cases

This project can be leveraged for enhancing worker safety by automatically detecting whether workers are wearing helmets in real-time, helping to enforce safety compliance on worksites.

Additionally, insurance companies can use this solution to estimate insurance costs more accurately by analyzing existing safety risks. By identifying the frequency and conditions of safety violations, insurers can better assess risk levels and tailor insurance premiums accordingly.

⚙️ Features

• Real-Time Detection: Efficiently detects helmet usage in real-time video feeds.

• High Accuracy: Utilizes advanced deep learning models to ensure precise identification.

• User-Friendly Interface: Simple command-line interface for easy operation.

•Customizable: Allows for adaptation to different datasets and environments.

🛠️ Technologies Used

• Programming Language: Python

• Deep Learning Framework: TensorFlow

•Model Architecture: YOLO (You Only Look Once)

•Computer Vision Library: OpenCV

•Data Annotation Tool: Labelimg

• Development Environment: PyCharm, Google Colab

📁 Project Structure

├── cfg/ # Configuration files for model settings ├── data/ # Dataset and annotations ├── output/ # Model outputs (e.g., trained weights, logs) ├── utils/ # Utility scripts for data processing ├── detect.py # Script for detecting helmets in images/videos ├── train.py # Script for training the model ├── requirements.txt # Required Python packages └── README.md # Project documentation

🚀 Installation

To set up the project locally:

Clone the repository:

git clone https://github.com/AliRazaviJ/Helmet-Detection.git cd Helmet-Detection

Install the required dependencies:

pip install -r requirements.txt

🧪 Usage •Training the Model

•To train the model on your dataset:

•python train.py --img 640 --batch 16 --epochs 50 --data data.yaml --weights yolov5s.pt

•Detecting Helmets

•To detect helmets in an image:

•python detect.py --source path_to_image.jpg --weights best.pt --img-size 640

•To detect helmets in a video:

•python detect.py --source path_to_video.mp4 --weights best.pt --img-size 640

📊 Dataset

The model is trained on a custom dataset containing images of individuals with and without helmets. The dataset is organized as follows:

data/ ├── images/ │ ├── train/ │ ├── val/ │ └── test/ └── labels/ ├── train/ ├── val/ └── test/

Each image has a corresponding label file in YOLO format. 🔧 Customization

•To adapt the model to a different dataset:

• Prepare your dataset in the structure mentioned above.

•Update the data.yaml file to reflect the paths and class names.

•Train the model using the training command provided.

📈 Evaluation

To evaluate the model's performance:

python evaluate.py --weights best.pt --data data.yaml

🔄 Ongoing Work

I am actively working to:

•Improve detection accuracy across diverse lighting and environmental conditions

•Expand and clean the dataset

• Optimize model size and inference time for edge deployment

• Add helmet color classification (planned)

•Stay tuned for updates!

🤝 Contributing

Contributions are welcome! To contribute:

• Fork the repository.

• Create a new branch (git checkout -b feature-branch).

• Make your changes.

•Commit your changes (git commit -am 'Add new feature').

• Push to the branch (git push origin feature-branch).

• Create a new Pull Request.

📄 License

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

📞 Contact

For questions or feedback, please open an issue on the GitHub repository.

Releases

No releases published

Packages

No packages published

Languages