MaskGuard-AI detects faces from webcam/video frames and classifies each face as:
MaskNo Mask
It includes:
- model training (
train_model.py) - model evaluation (
evaluate_model.py) - webcam detection (
detect_mask_video.py) - single image detection (
detect_mask_image.py) - Flask API + browser UI (
api_server.py+web/index.html)
| Home | Model Evaluation |
|---|---|
![]() |
![]() |
| Objectives | Live Detection (Mask) |
|---|---|
![]() |
![]() |
cd MaskGuard-AI
python -m venv .venvActivate venv:
- Windows:
.venv\Scripts\activate - macOS/Linux:
source .venv/bin/activate
Install dependencies:
pip install -r requirements.txtCreate and fill these folders:
dataset/
|- with_mask/
|- without_mask/
Supported formats: .jpg, .jpeg, .png, .bmp, .webp
python train_model.pyExpected output:
model/mask_detector.h5
python api_server.pyThen open:
http://127.0.0.1:5000/
In UI, click Start camera & API.
python detect_mask_video.pyPress q to quit.
python detect_mask_image.py path\to\image.jpgPOST /api/predict
- Request:
multipart/form-datawith fieldimage - Response: JSON containing
faces[]with box coordinates, label, and confidence
python evaluate_model.py- Model load error: run
python train_model.pyagain to regeneratemodel/mask_detector.h5 - UI not detecting: make sure server is running with
python api_server.py - Camera not opening: allow camera permission and try different camera index in OpenCV script if needed
- Do not open UI with
file://: always use Flask URL (http://127.0.0.1:5000/)
MaskGuard-AI/
|- assets/
| |- maskguard-banner.png
| |- ui-home.png
| |- ui-model-eval.png
| |- ui-objectives.png
| |- ui-live-mask.png
| |- ui-live-no-mask.png
|- dataset/
|- model/
|- haarcascades/
|- web/
| |- index.html
|- api_server.py
|- inference_backend.py
|- train_model.py
|- evaluate_model.py
|- detect_mask_video.py
|- detect_mask_image.py
|- requirements.txt
MIT - see LICENSE.





