Face Mask Classifier.
Two models, head to head — a fine-tuned ResNet50 and a custom CNN, trained on the same 12K-image dataset, evaluated the same way.
Overview
12,000 images, evenly split
Kaggle's Face Mask Detection dataset: 6,000 masked / 6,000 unmasked. Split into 10,000 train (5K/5K), 800 validation (400/400), 800 test (400/400).
The custom model won, unexpectedly
Both models were scored on the same held-out test set with evaluate.py. The from-scratch CNN outperformed the pretrained ResNet50 — the author's own writeup speculates this may come down to the custom model's larger parameter count (19,264,322) or the small test set size, rather than a definitive architectural conclusion.
- ResNet50
- acc 0.91 · precision 0.93 · recall 0.87 · F1 0.90
- Custom CNN
- acc 0.98 · precision 0.97 · recall 0.98 · F1 0.98
Method
The same Kaggle dataset trains two independent models — a transfer-learning ResNet50 and a from-scratch CNN — then one evaluation script scores both the same way.
- 01Dataset
12K images, Kaggle, 50/50 split
- 02Two models
ResNet50 vs. custom CNN
- 03evaluate.py
accuracy · precision · recall · F1
Results
Stack
Reproduce it
$ pip install -r requirements.txt$ python resnet_train.py <train_dir> <val_dir> <epochs> <save_name>$ python tf_model_train.py <train_dir> <val_dir> <epochs> <save_name>$ python evaluate.py <test_dir> <model_path>
$ python main.py --img_path path/to/img --model_path path/to/model