https://github.com/ashithapallath/facemaskdetection-using-cnn
This project implements a CNN-based Face Mask Detection Model to classify images as with mask or without mask. Trained on a labeled dataset, the model achieves 90% accuracy, making it suitable for real-world applications like public safety monitoring.
https://github.com/ashithapallath/facemaskdetection-using-cnn
adam-optimizer batch-normalization detection dropout-layers machine-learning python
Last synced: 10 months ago
JSON representation
This project implements a CNN-based Face Mask Detection Model to classify images as with mask or without mask. Trained on a labeled dataset, the model achieves 90% accuracy, making it suitable for real-world applications like public safety monitoring.
- Host: GitHub
- URL: https://github.com/ashithapallath/facemaskdetection-using-cnn
- Owner: ashithapallath
- Created: 2025-02-01T14:09:15.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-02-01T15:00:36.000Z (12 months ago)
- Last Synced: 2025-02-01T15:23:13.881Z (12 months ago)
- Topics: adam-optimizer, batch-normalization, detection, dropout-layers, machine-learning, python
- Language: Jupyter Notebook
- Homepage:
- Size: 501 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## **Face Mask Detection Model using CNNs**
### **Overview**
This project implements a **Convolutional Neural Network (CNN)** to detect whether a person is wearing a face mask or not. The model is trained on a labeled dataset of masked and unmasked faces.
### **Dataset**
- The dataset is sourced from Kaggle: [Face Mask Dataset](https://www.kaggle.com/datasets/omkargurav/face-mask-dataset).
- It contains images categorized as **with mask** and **without mask**.
### **Model Architecture**
- **Convolutional Layers**: Extract spatial features from images.
- **Batch Normalization & Dropout**: Prevent overfitting and improve generalization.
- **Fully Connected Layers**: Perform classification into mask/no-mask categories.
- **Activation Function**: ReLU (hidden layers) & Softmax (output layer).
- **Loss Function**: Categorical Crossentropy.
- **Optimizer**: Adam.
### **Training Details**
- **Batch Size**: 32
- **Epochs**: 30 (with Early Stopping based on validation loss)
- **Validation Split**: 20% of the dataset
### **Results**
**Classification Report:**
| Class | Precision | Recall | F1-Score | Support |
|---------------|-----------|--------|----------|---------|
| **Without Mask** | 0.89 | 0.93 | 0.91 | 397 |
| **With Mask** | 0.92 | 0.87 | 0.90 | 366 |
| **Accuracy** | **0.90** | - | - | 763 |
| **Macro Avg** | 0.91 | 0.90 | 0.90 | 763 |
| **Weighted Avg** | 0.91 | 0.90 | 0.90 | 763 |

**Accuracy & Loss Plots:**


### **Usage**
1. **Install Dependencies**
```bash
pip install tensorflow opencv-python pandas numpy matplotlib
```
2. **Run the Model Training**
```python
python train.py
```
3. **Test the Model on New Images**
```python
python predict.py --image path/to/image.jpg
```
### **Future Improvements**
- Train on a **larger dataset** for better generalization.
- Implement **real-time detection** using OpenCV and a webcam.
- Optimize for **mobile deployment** using TensorFlow Lite.