Gender task
Binary classification on UBIPr periocular images, evaluated with a subject level split to prevent identity leakage.
Computer vision and biometrics
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.
Problem
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.
Binary classification on UBIPr periocular images, evaluated with a subject level split to prevent identity leakage.
Ten age buckets from UTKFace, using crops generated around detected eyes rather than the original full face image.
ImageNet pretrained ResNets are compared with scratch models and a hybrid that adds periocular specific multiscale fusion.
Why the project was rebuilt
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
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.
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.
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
ImageNet pretrained backbones provide strong transfer learning references. Their final layer is replaced for two gender classes or ten age buckets.
A scratch trained convolutional network reuses features at several scales, then applies a stronger fusion block and classifier than the original model.
The age hybrid combines a pretrained ResNet34 feature extractor with periocular specific multiscale fusion. It keeps useful pretrained features without abandoning the custom design.
Gender results
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.
| Model | Image accuracy |
|---|---|
| ResNet18 | 98.10% |
| ResNet34 | 97.74% |
| PeriGender V2 | 97.11% |
| ResNet50 | 96.93% |
Age results
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.
| 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
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
A subject safe split asks whether the model transfers to unseen people, which is the behavior the task actually needs.
A full face age model does not answer a periocular age question. Strict cropping made the task harder and the result more honest.
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
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.