Sunglass Detection with Transfer Learning
Real-time sunglass detection using a pre-trained CNN
A computer vision project that detects whether someone is wearing sunglasses in a live webcam feed, using transfer learning on top of the VGG16 model.
This project applies transfer learning to a practical computer vision task — detecting sunglasses in real time from a webcam feed — without needing to train a deep model from scratch.
- Training an image classifier from scratch requires large datasets and significant compute.
- Real-time detection needs a model that's both accurate and fast enough to run on live video.
OpenCV captures and preprocesses live webcam frames, which are passed to a fine-tuned VGG16-based model for real-time classification.
OpenCV captures a live frame from the webcam
Frame is resized and normalized for the model
Preprocessed frame is passed to the trained model
VGG16-based model extracts features and classifies the frame
Prediction (sunglasses / no sunglasses) is computed
Result is displayed live on the video feed
Key Architectural Decisions
- ✓Used VGG16 as a pre-trained feature extractor, then fine-tuned custom top layers for the sunglasses/no-sunglasses classification task.
- ✓Applied data augmentation (flipping, rotation, scaling) to improve model generalization.
- ✓Built a real-time pipeline with OpenCV to capture webcam frames, preprocess them, and run predictions live.
- Transfer learning significantly cuts down training time and data requirements for a niche classification task.
- Preprocessing choices, like frame sharpening and normalization, had a noticeable effect on live prediction accuracy.
- Building for real-time inference requires balancing model complexity against speed.