← Back to projects

Computer vision and biometrics

What can a model learn from the region around the eyes?

I revisited an undergraduate computer vision project and rebuilt it as a command line research workflow. The new version uses strict periocular crops for age prediction, separates UBIPr subjects across train and test sets, records each run, and compares pretrained baselines with custom multiscale models.

PyTorchTorchvisionOpenCV UBIPrUTKFaceTransfer learning
98.10%Best UBIPr gender image accuracy
97.11%Best custom gender model
86.68%Best strict periocular age accuracy
0Subjects shared by gender train and test sets

Problem

Soft biometric prediction with most of the face removed

Masks, pose, framing, and other occlusions can hide the lower face. The periocular region still contains the eyes, eyebrows, eyelids, and nearby skin texture. This project tests how much gender and coarse age information remains in that limited crop. Age is expected to be harder because many useful cues occur outside the eye region and change gradually rather than by class.

Gender task

Binary classification on UBIPr periocular images, evaluated with a subject level split to prevent identity leakage.

Age task

Ten age buckets from UTKFace, using crops generated around detected eyes rather than the original full face image.

Model study

ImageNet pretrained ResNets are compared with scratch models and a hybrid that adds periocular specific multiscale fusion.

Why the project was rebuilt

The refreshed evaluation replaced the old headline results

The 2023 report used notebook based experiments and reported gender results around 93 to 97 percent, age results around 57 to 61 percent, and roughly 32.7 percent joint accuracy. The refreshed repository fixes two evaluation problems that matter more than the model choice: age experiments now operate on actual periocular crops, and UBIPr is divided by person rather than image.

Area Original workflow Refreshed workflow
Execution Notebook centered Repeatable scripts and command line entry points
Gender split Image split Subject split with overlap check
Age input Mixed or full face path Strict eye region crop from UTKFace
Tracking Summary results Timestamped runs, checkpoints, metrics, plots, and comparisons
Models ResNets and first custom models ResNets, V2 fusion models, and a ResNet34 hybrid

Data pipeline

Separate preprocessing for two different datasets

Raw image and metadata
Face and eye localization
Periocular crop
Task specific split
Train and evaluate

UBIPr gender

Labels come from the paired metadata rather than filename guesses. The preparation script groups images by identity, assigns each person to one side of a 90 and 10 split, and can balance the training classes. The test set remains untouched.

UTKFace age

OpenCV detects the face and eye region, then writes a strict periocular crop. Age is parsed from the UTKFace filename and mapped to one of ten buckets. The prepared crop set is divided 80 and 20 for training and testing.

Why subject separation matters

UBIPr contains multiple images of the same person. A random image split can put one person's eyes in training and another image of the same eyes in testing. The model may then recognize identity instead of learning a transferable gender cue.

Model families

Baselines first, then custom models with a specific purpose

ResNet18, 34, and 50

ImageNet pretrained backbones provide strong transfer learning references. Their final layer is replaced for two gender classes or ten age buckets.

PeriGender V2

A scratch trained convolutional network reuses features at several scales, then applies a stronger fusion block and classifier than the original model.

PeriAgeResNet34

The age hybrid combines a pretrained ResNet34 feature extractor with periocular specific multiscale fusion. It keeps useful pretrained features without abandoning the custom design.

224 pixel crop
ResNet34 stem
Feature stages
Multiscale fusion
10 age logits

Gender results

ResNet18 won overall; PeriGender V2 led the custom models

ResNet18 reached 98.10 percent image accuracy on the UBIPr test set. ResNet34 followed at 97.74 percent, while the larger ResNet50 reached 96.93 percent. PeriGender V2 achieved 97.11 percent and substantially improved the custom architecture family. Subject level majority voting was effectively saturated on the best runs, but image accuracy remains the more discriminating metric.

Bar chart comparing UBIPr gender accuracy across ResNet and PeriGender models
Model size alone did not predict the ranking. ResNet18 outperformed the deeper pretrained backbones.
Model Image accuracy
ResNet18 98.10%
ResNet34 97.74%
PeriGender V2 97.11%
ResNet50 96.93%
Confusion matrix for the PeriGender V2 test predictions
PeriGender V2 confusion matrix from the canonical saved run.

Age results

The hybrid model was the first custom variant to beat the plain baseline

PeriAgeResNet34 reached 86.68 percent test accuracy and finished above the 85.08 percent ResNet34 baseline. ResNet18 reached 84.07 percent. ResNet50 fell to 81.58 percent, another sign that a larger backbone was not automatically better. PeriAge V2 was the strongest scratch model at 79.83 percent but still lacked the pretrained representation used by the leaders.

Bar chart comparing strict periocular age classification accuracy
All values use the refreshed strict periocular UTKFace pipeline.
Model Type Best test accuracy Reading
PeriAgeResNet34 Hybrid 86.68% Best overall
ResNet34 Pretrained baseline 85.08% Strongest plain backbone
ResNet18 Pretrained baseline 84.07% Compact and competitive
ResNet50 Pretrained baseline 81.58% Extra depth did not help
PeriAge V2 Scratch custom 79.83% Best scratch variant

Reproducible workflow

Preparation, training, comparison, and inference are separate commands

The scripts make the data assumptions visible and keep model experiments comparable. Each run writes a configuration, epoch history, and best checkpoint. Report generation reads those files rather than transcribing results by hand.

python scripts/prepare_ubipr_gender.py --split-by-subject
python scripts/extract_utkface_periocular.py --strict
bash run_gender_baselines.sh
bash run_age_baselines.sh
python scripts/compare_runs.py --runs-dir runs/age/periocular
python scripts/generate_report_artifacts.py

What changed my conclusions

Evaluation design mattered more than adding another network

Leakage can flatter a classifier

A subject safe split asks whether the model transfers to unseen people, which is the behavior the task actually needs.

The crop defines the question

A full face age model does not answer a periocular age question. Strict cropping made the task harder and the result more honest.

Pretraining and fusion can coexist

The winning age model used pretrained ResNet features and a custom fusion head. The useful distinction was not generic versus custom, but what each part contributed.

Limits

Accuracy is specific to these datasets and label definitions

UBIPr is comparatively controlled, while UTKFace age labels are inferred from filenames and converted into broad buckets. Neither result establishes demographic fairness or performance in surveillance conditions. A production study would need external datasets, subgroup analysis, calibrated uncertainty, and explicit consent and privacy requirements.