LIVE ON STREAMLIT CLOUD

Real-Time Face Mask
Detection

3-class classification โ€” Mask On, Mask Incorrect, No Mask โ€” powered by EfficientNetB0 TFLite at 98.33% accuracy. Upload an image or use your webcam, directly in the browser.

โœ… Mask On โš ๏ธ Mask Incorrect โŒ No Mask
98.33%
Val Accuracy
3
Classes Detected
8.4 MB
TFLite Model Size
3.8K
Training Images
Pipeline

How It Works

Two-stage inference โ€” face detection followed by mask classification, all running in the browser.

๐Ÿ“ท InputImage / Webcam
โ†’
๐Ÿ” SSD Detectorres10_300x300
โ†’
โœ‚๏ธ Face Crop224 ร— 224 px
โ†’
๐Ÿง  EfficientNetB0TFLite FP16
โ†’
๐Ÿท๏ธ ResultClass + Confidence

Face Detector

ModelOpenCV SSD (Caffe)
Input size300 ร— 300
Confidence threshold0.5 (adjustable)
Multi-faceโœ“ Supported
Backendcv2.dnn (CPU)

Mask Classifier

BackboneEfficientNetB0
FormatTFLite FP16
Input224 ร— 224 RGB
Output3-class softmax
Accuracy98.33%

Phase 1 Training

GoalFeature extraction
BackboneFrozen
OptimizerAdam 1e-3
LossCatCE + smoothing 0.1
Class weightsBalanced

Phase 2 Fine-tuning

GoalFine-tuning
BackboneTop 15 layers unfrozen
OptimizerCosine Decay 5e-6
LossCatCE + smoothing 0.05
Class weightsBalanced
Benchmarks

Model Comparison

8-epoch benchmark across three architectures on the same dataset and training setup.

Model Val Accuracy Size Train Time
EfficientNetB0
98.33%
8.4 MB 205 s โœ“ Deployed
YOLOv8n-cls (TF)
94.88%
13.6 MB 182 s
MobileNetV2
84.81%
9.5 MB 155 s
Training Curves
Training & Validation Curves
Confusion Matrix
Confusion Matrix
Model Comparison
Model Comparison Chart
Predictions
Sample Predictions
Class Distribution
Class Distribution
Augmentation
Data Augmentation Preview
Applications

Two Ways to Run

Browser-based for sharing, or native OpenCV window for real-time local detection.

๐ŸŒ
Streamlit Web App โ€” app.py
Runs entirely in your browser. No installation required via the live demo link.
  • Upload JPG / PNG / WEBP image
  • Browser webcam capture via st.camera_input
  • Per-face confidence bars for all 3 classes
  • Download annotated result image
  • Deployed on Streamlit Cloud
Streamlitai-edge-litert Python 3.11Browser Webcam
๐Ÿš€ Launch App
๐ŸŽฅ
Live Webcam โ€” app2.py
Native OpenCV window for real-time continuous detection. Runs locally, fully offline.
  • Live webcam feed โ€” processes every frame
  • FPS counter, face count, per-class counts on screen
  • Press S to save screenshot ยท Q to quit
  • Smooth FPS with exponential moving average
  • Semi-transparent bounding box overlay
OpenCVTensorFlow Local OnlyReal-time
View Source
Dataset & Stack

Built With

Dataset

SourceKaggle (vijaykumar1799)
Total images~3,800
Classes3 (balanced)
Split80 / 20 stratified
Class weightssklearn balanced

Tech Stack

TrainingTensorFlow / Keras
Deployment modelTFLite FP16
Inference (cloud)ai-edge-litert
Face detectionOpenCV DNN (Caffe)
Web appStreamlit

Try It Now โ€” No Install Needed

Upload a photo or use your webcam to detect mask usage instantly.

Launch Live App GitHub Repo โ† Back to Portfolio