https://github.com/allanotieno254/face-mask-detection---object-detection
The model is trained using a labeled dataset containing images of people with and without masks. It utilizes a convolutional neural network (CNN) for object detection and classification. The implementation is done using TensorFlow/Keras, OpenCV, and other essential libraries.
https://github.com/allanotieno254/face-mask-detection---object-detection
cnn computer-vision deep-learning opencv tensorflow
Last synced: 7 months ago
JSON representation
The model is trained using a labeled dataset containing images of people with and without masks. It utilizes a convolutional neural network (CNN) for object detection and classification. The implementation is done using TensorFlow/Keras, OpenCV, and other essential libraries.
- Host: GitHub
- URL: https://github.com/allanotieno254/face-mask-detection---object-detection
- Owner: AllanOtieno254
- Created: 2025-03-13T19:32:44.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-13T19:41:49.000Z (7 months ago)
- Last Synced: 2025-03-13T20:33:57.498Z (7 months ago)
- Topics: cnn, computer-vision, deep-learning, opencv, tensorflow
- Language: Jupyter Notebook
- Homepage:
- Size: 1.33 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Face Mask Detection - Object Detection

## Description
This project focuses on face mask detection using object detection techniques. The model is designed to classify whether a person is wearing a mask or not, using deep learning-based image processing. This is especially relevant in health and safety applications, such as ensuring compliance with mask mandates in public places.The model is trained using a labeled dataset containing images of people with and without masks. It utilizes a convolutional neural network (CNN) for object detection and classification. The implementation is done using TensorFlow/Keras, OpenCV, and other essential libraries.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Dataset](#dataset)
- [Model Training & Evaluation](#model-training--evaluation)
- [File Structure](#file-structure)
- [Results & Visualization](#results--visualization)
- [Challenges & Future Improvements](#challenges--future-improvements)
- [License](#license)## Installation
Before running the project, ensure that you have all the required dependencies installed. The easiest way to do this is by running:```bash
pip install -r requirements.txt
```Dependencies include:
- TensorFlow/Keras (for deep learning model training and inference)
- OpenCV (for image processing and real-time face detection)
- NumPy (for numerical operations)
- Pandas (for dataset manipulation)
- Matplotlib (for visualizing training progress and results)Ensure you have Jupyter Notebook installed to run the `.ipynb` file:
```bash
pip install jupyter
```## Usage
To use this project, follow these steps:1. Clone the repository:
```bash
git clone https://github.com/yourusername/face-mask-detection.git
cd face-mask-detection
```2. Install dependencies using:
```bash
pip install -r requirements.txt
```3. Run the Jupyter Notebook:
```bash
jupyter notebook "Face Mask Detection - Object Detection.ipynb"
```4. Follow the steps outlined in the notebook to train and evaluate the model.
## Dataset
The dataset consists of labeled images of people wearing masks and those without masks. The dataset is sourced from various public image repositories or manually collected and annotated.### Preprocessing Steps:
- Image resizing to a fixed dimension (e.g., 224x224 pixels)
- Image augmentation techniques like rotation, flipping, and brightness adjustments
- Normalization to improve model performance
- Splitting into training, validation, and test sets## Model Training & Evaluation
The face mask detection model is built using a CNN architecture trained on labeled images. The training process includes:- Defining the CNN model architecture
- Compiling with an appropriate optimizer (e.g., Adam) and loss function (e.g., categorical crossentropy)
- Training the model on labeled images for multiple epochs
- Evaluating model performance using accuracy, precision, recall, and confusion matrix### Hyperparameters:
- Batch size: 32
- Learning rate: 0.001
- Number of epochs: 25-50 (depending on dataset size)
- Activation function: ReLU (hidden layers), Softmax (output layer)### Evaluation Metrics:
- **Accuracy**: Measures overall correctness of predictions.
- **Precision & Recall**: Evaluates class-specific performance.
- **Confusion Matrix**: Displays misclassifications.## File Structure
```
Face Mask Detection
│── dataset/
│ ├── with_mask/
│ ├── without_mask/
│
│── models/
│ ├── mask_detector_model.h5
│
│── Face Mask Detection - Object Detection.ipynb
│── requirements.txt
│── README.md
│── LICENSE
│── utils/
│ ├── preprocess.py
│ ├── train.py
│ ├── test.py
```## Results & Visualization
The trained model detects faces in images and determines whether they are wearing masks. Key outputs include:- Bounding boxes around detected faces
- Labels: "Mask" or "No Mask"
- Probability scores for each classification### Accuracy & Loss Graphs:
Training accuracy and loss plots are generated to evaluate model performance over epochs.### Example Detections:
Images with model-predicted labels are displayed for visual inspection.## Challenges & Future Improvements
### Challenges:
- Handling occlusions (e.g., sunglasses, scarves, or multiple masks)
- Dataset imbalance (more images of one class than the other)
- Real-time performance optimization### Future Improvements:
- Implementing real-time face mask detection using webcam integration
- Using Transfer Learning with pre-trained models like MobileNetV2
- Deploying the model as a web or mobile application## License
This project is licensed under the MIT License. See the LICENSE file for more details.---
**Contributors:**
- [Your Name](https://github.com/yourusername)If you find this project useful, consider giving it a ⭐ on GitHub!