A Python-based tool designed to identify whether drivers in a set of images are wearing seat belts. Given a folder containing images, the application processes each image and generates a report indicating which drivers are wearing seat belts and which are not.
- Batch Processing: Processes multiple images in a single run.
- Accurate Detection: Utilizes advanced machine learning models to ensure high accuracy.
- Detailed Reports: Generates comprehensive reports of the results.
- User-Friendly: Simple command-line interface for easy interaction.
-
Clone the Repository:
git clone https://github.com/vlalef/SafetyStrapAI.git cd SafetyStrapAI
-
Create and Activate a Virtual Environment:
python -m venv venv source venv/bin/activate
-
Install Dependencies: Install the dependencies:
pip install -r requirements.txt
-
Prepare your dataset: Ensure that the images are organized into the appropriate directories under dataset/train and dataset/validation as it follows.
dataset/ ├── train/ │ ├── with_seatbelt/ │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ ├── 9.jpg │ │ └── 10.jpg │ └── without_seatbelt/ │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ └── 10.jpg └── validation/ ├── with_seatbelt/ │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ └── 5.jpg └── without_seatbelt/ ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg └── 5.jpg
-
Train the model:
python train_model.py
This command will train the model using the images in the
train
directory and validate it using images from thevalidation
directory. -
Run the application:
python safety_strap.py --input_folder ./dataset/validation --output_folder ./results --model ./models/seatbelt_detector.keras
-
Review the Results:
The application will generate a report in the specified output folder detailing which images contain drivers using seat belts and which do not.
Example Report:
image1.jpg: Using seat belt image2.jpg: Not using seat belt image3.jpg: Using seat belt
The application can be configured via command-line arguments:
--input_folder
: Path to the directory containing the images.--output_folder
: Path to the directory where results will be saved.--model
: (Optional) Path to a custom model file if you wish to use a different model.
python safety_strap.py --input_folder ./dataset/validation --output_folder ./results --model ./models/seatbelt_detector.keras
- Python 3.9+
- OpenCV
- TensorFlow
- NumPy
- Keras
- Pillow
- SciPy
This project is licensed under the GPL-3.0 license. Se the LICENSE
file for more details
- Author: Alef L. Vaz
- Email: [email protected]
- GitHub: vlalef