This project aims to detect Personal Protective Equipment (PPE) using YOLOv11 or other YOLO models of your choice. It includes data preprocessing, model training, and evaluation to ensure accurate detection of PPE in images.
Main Directory
│ .env
│ .gitignore
│ requirements.txt
│ README.md
│
├── dataset
│ ├── dataset_train.yaml
│ ├── images
│ │ ├── test
│ │ ├── train
│ │ └── val
│ └── labels
│ ├── test
│ ├── train
│ └── val
│
├── P1 - Data Preprocessing
│ ├── data_preprocessing.py # Main script to preprocess images and labels
│ ├── convert_xml_to_txt.py # Converts annotation files from XML (Pascal VOC) to TXT (YOLO format)
│ ├── display_labels.py # Displays dataset labels and their distributions
│ └── separate_non_annotated_images.py # Filters out images without annotations
│
├── P2 - Model Training
│ ├── yolo_v11_model_training.py # Script for training YOLOv11 model
│ ├── model_loader.py # Loads and initializes the YOLO model
│ └── augment_data.py # Applies data augmentation techniques to improve model performance
│
└── P3 - Model Evaluation
├── model_evaluation.py # Evaluates the trained YOLO model using test data
├── model_visual_test.py # Visualizes model predictions on sample images
└── performance_metrics.py # Computes key performance metrics (mAP, precision, recall)
git clone https://github.com/akshaysatyam2/yolo-for-detection.git
cd yolo-for-detectionpython -m venv venv- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt- Rename
.env.exampleto.envand configure necessary variables.
Preprocess the dataset before training.
Run:
python "P1 - Data Preprocessing/data_preprocessing.py"Train the YOLOv11 model on the dataset.
Run:
python "P2 - Model Training/yolo_v11_model_training.py"Evaluate the trained model’s performance.
Run:
python "P3 - Model Evaluation/model_evaluation.py"The dataset follows this format:
dataset/
├── images/
│ ├── test/
│ ├── train/
│ └── val/
└── labels/
├── test/
├── train/
└── val/
- Images: Store images in
images/train,images/val, andimages/test. - Labels: Store corresponding labels in
labels/train,labels/val, andlabels/test.
train: dataset/images/train
val: dataset/images/val
test: dataset/images/test
nc: 2
names: ["Helmet", "No Helmet"]
epochs: 50
batch_size: 16
image_size: 640This project requires:
ultralyticsopencv-pythonnumpymatplotlibpandaspython-dotenv
Install with:
pip install -r requirements.txtWhen done, deactivate the virtual environment:
deactivateFor questions or contributions:
- Name: Akshay Kumar
- Email: akshaysatyam2003@gmail.com
- GitHub: @akshaysatyam2