Custom data
Collect and annotate the training set instead of wrapping a packaged face detector.
Case study / 07
Training a face detector from raw webcam data to real-time localization.
Focal builds face detection end to end: collecting and annotating webcam images, augmenting a small dataset, training a shared CNN backbone to jointly predict face presence and bounding-box coordinates, then running real-time inference through OpenCV.
Collect and annotate the training set instead of wrapping a packaged face detector.
One VGG16 feature extractor supports classification and localization heads.
Classification and bounding-box regression are optimized in one training step.
One forward pass returns face presence and normalized box coordinates.
| Decision | Why | Tradeoff |
|---|---|---|
| Shared backbone with separate heads | Classification and localization can reuse the same learned image features. | Both objectives influence one shared representation. |
| Normalized bounding-box coordinates | Regression stays independent of image resolution and composes with bbox-aware augmentation. | Coordinates must return to pixel space at inference. |
| Custom training loop | The model explicitly combines localization and classification losses and controls each update. | More code and responsibility than default Keras multi-output training. |
Deep dive A
The VGG16 backbone computes one shared feature representation. Independent dense heads then answer two different questions: whether a face is present and where its normalized bounds lie.
Deep dive B
Bounding-box aware transforms keep labels aligned with altered images. If a crop removes the face, the pipeline writes a class-0 example and a zero box. The notebook saves a model locally; that generated artifact is not committed.
Verified notebook behavior
Training and validation loss converge in the included run, with a transient validation spike around epoch 7. The repository does not report general detection accuracy.