Learning visual patterns
Predict multiple facial attributes from images, learning useful visual features through supervised multi-label classification.
From a convolutional neural network trained from scratch to personalized face recognition through transfer learning — with an interactive tool for exploring 40 facial attributes.
Instead of starting from a generic pretrained architecture, I trained my own feature extractor on a large facial dataset and explored how well those representations adapted to a much smaller identity classification task.
Predict multiple facial attributes from images, learning useful visual features through supervised multi-label classification.
Adapt this visual knowledge to a binary target-person-versus-others task using a much smaller collection of labeled examples.
Investigate how class imbalance and decision thresholds affect the model's willingness to recognize positive examples.
The three folders in the repository represent successive experiments, not three unrelated systems.
The public Streamlit demo uses the original 40-attribute CNN, while the personalized recognition experiments are documented separately.
The first stage was multi-label representation learning: supervised training on CelebA before any personalized identity task was introduced.
Optimized with Adam and binary cross-entropy; the reported 91.50% validation binary accuracy measures attribute-label predictions, not identity recognition.
Images were resized to 128 × 128 and pixel values normalized to the [0, 1] range. Each sample provides an image and up to 40 independent binary attribute labels.
(128, 128, 3) → normalized RGBFour convolutional blocks, with two Conv2D layers per block and MaxPooling2D, progressively learn spatial patterns. The feature depth increases from 64 to 512 filters.
64 → 128 → 256 → 512 filtersGlobal average pooling summarizes feature maps; dropout and dense layers transform that representation into 40 sigmoid scores. Each score is independent, so several labels can be active at once.
GAP → Dense(256) → Dense(128) → Dense(40)During CelebA training, the network learned filters useful for describing facial patterns instead of memorizing an identity label. The research hypothesis was that those filters could provide a useful initialization for recognizing one target person with far fewer examples.
The checkpoint achieved 91.50% validation binary accuracy on the attribute task. This is the mean correctness of binary attribute predictions, not facial recognition accuracy. The model uses sigmoid outputs and binary cross-entropy, not a 40-class softmax.
Learned visual features directly from the annotated CelebA dataset rather than importing pretrained classification weights.
One image can exhibit multiple attributes simultaneously. The 40 outputs are not competing softmax classes.
Recovered the trained Keras model and ran it locally with Python 3.13 for a working public demonstration.
The scripts extract the feature maps immediately before the original GlobalAveragePooling2D and attach a fresh binary head. The pretrained attribute classifier is not reused.
The pretrained convolutional backbone is fixed (trainable = False). Only the new classifier head is optimized, initially with Adam at 1×10⁻³.
The backbone is made trainable again, but its first 10 layers remain frozen. Later convolutional layers and the binary head are adapted using Adam at 1×10⁻⁵.
The final sigmoid returns a score associated with the target-person class. At a chosen threshold, the output is classified as either target (1) or others (0). This experiment does not implement a face detector, face alignment, named multi-person recognition, or anti-spoofing.
The personalized experiment is binary verification of a target person's images versus other faces. It does not identify arbitrary people by name.
Important distinction: this experiment performs binary target-person recognition, not open-set identification of arbitrary named individuals. The public demo does not use personal identity checkpoints.
The second version did not introduce a new backbone: it changed the training strategy to address class imbalance and the difficulty of recognizing positive examples.
A frozen-then-partially-unfrozen CNN using geometric and brightness augmentation, without explicit class weighting in training.
Result: high precision, but 5 of 16 target-person validation images were missed.
Preserved the two-phase fine-tuning process, increased augmentation strength, weighted minority-class examples, and evaluated alternative classification thresholds.
Result: 15 of 16 positive validation images recovered, with 5 false positives.
The evaluation set contained 16 target-person images and 200 other-face images. A model predicting “others” too often could still obtain high overall accuracy. V2 uses class_weight inversely proportional to class frequency, increasing the training cost of errors on the underrepresented class.
Data augmentation introduces transformed training images; it does not create additional independent people. Threshold selection changes how sigmoid scores are converted into class decisions, not the CNN's weights.
Rather than treating accuracy as the only goal, I compared precision, recall, F1 and the numbers of missed or incorrectly accepted faces on the validation split.
| Metric | Transfer v1 | Transfer v2 |
|---|---|---|
| Accuracy | 97.69% | 97.22% |
| Precision | 100.00% | 75.00% |
| Recall | 68.75% | 93.75% |
| F1-score | 81.48% | 83.33% |
| Decision threshold | 0.50 | 0.60 |
Validation figures from the original report and saved threshold evaluation. The v1 F1-score is derived from the reported confusion matrix; v2 threshold 0.60 was selected on validation data.
V1 correctly classified 11 of 16 positive validation images with no false positives among 200 negatives. V2 recognized 15 of 16 positives but also misclassified 5 negatives as positive.
All 200 other faces were rejected, but five actual target images were missed.
More target faces were recognized, but five other faces were incorrectly accepted.
The saved evaluation compared thresholds from 0.10 to 0.90. The reported F1 peak (83.33%) occurred at 0.60 and 0.70. The report uses 0.60.
These are validation-selected thresholds, not results on a separate untouched test set.

Of the faces classified as the target, what fraction really belonged to the target?
Of all true target images, what fraction did the model recognize?
Harmonic mean of precision and recall, useful for viewing their tradeoff under class imbalance.
The two experiments were evaluated on validation data; these values are not evidence of production readiness or spoof-resistant authentication.
A usable interface for exploring what the original 40-output CNN learned — without exposing personalized identity recognition models.
Upload a single portrait to inspect the model's 40 facial attribute scores, browse prediction categories, change the decision threshold and export results as JSON.
This demonstration runs locally using the original CNN weights. The GitHub repository provides the application code and startup instructions.
VIEW DEMO ON GITHUB ↗
Upload a JPEG or PNG image and inspect the normalized CNN input pipeline.
Rank attributes, group them by category, and adjust the display threshold.
Download model outputs to inspect scores or reuse the results in further analysis.
Facial-analysis models can be sensitive to dataset bias, preprocessing choices, and the difference between validation performance and real-world reliability.
The identity-classification metrics were calculated on validation data. V2's decision threshold was also selected on validation, and an untouched independent test set was not documented.
The public demo resizes the supplied image to 128 × 128 RGB and normalizes pixels. It does not automatically locate, crop, or align faces, so framing matters.
Attributes such as “Attractive,” “Male,” and “Young” are CelebA annotations rather than verified facts about a person; high sigmoid scores are not calibrated guarantees.
No presentation-attack detection, demographic fairness audit or production authentication security evaluation is documented. Personal training photographs are not included in the public demo.
Important: The report and scripts support the architecture and validation results above. The original CSV column order, complete identity dataset provenance, and a truly independent identity test set are not available in the preserved files. These should not be assumed.
The biggest lessons came from comparing training strategies, understanding metric tradeoffs, and recovering a research model as a usable tool.
I learned how a multi-label training objective can build a transferable feature representation through progressively deeper convolutional blocks.
Replacing the classifier, freezing the backbone, and fine-tuning selected layers demonstrated how a learned representation can support a new prediction task.
Class imbalance made precision, recall, F1 and threshold selection more informative than headline accuracy alone.
I recovered and loaded a saved Keras checkpoint, reproduced preprocessing, and exposed the 40 CNN outputs through a Streamlit application and a Python CLI.
Training scripts, the original research report, experiment metrics and the public attribute-analysis demo are organized in the repository.
Architecture, training scripts, saved evaluation outputs and demo implementation.
OPEN GITHUB ↗Training methodology, evaluation and experiment discussion in the original notebook.
VIEW REPORT ↗