>_ Jorge Uc / projects← All projects
~/projects/dog-identity // COMPUTER VISION
◆ Transfer learningPyTorchVGG16

Recognize the dog.
Not just the breed.

Can a pretrained vision network identify one particular dog from a small set of photographs? This case study explores individual-animal recognition through VGG16 transfer learning, a new binary classifier and staged fine-tuning.

Bo, the dog targeted by the identity-recognition exercise
BO / TARGET DOGVGG16 + TRANSFER LEARNING
BACKBONEVGG16ImageNet-pretrained
TRAIN SET139Images, original exercise
VALIDATION30Images, original exercise
ORIGINAL ACCURACY96.7%29/30, not independently reproduced
01 / PROJECT CONTEXT

From object recognition to individual identity.

Most general-purpose image classifiers learn categories such as “dog” or “cat.” Here the target is more specific: telling one known dog apart from other images.

01DATA

Very few positive images

Only 19 positive examples appeared in the original training split. Learning directly from scratch would be difficult and prone to overfitting.

SMALL-DATA LEARNING
02MODEL

Reuse general visual features

Use patterns learned on ImageNet rather than training millions of convolutional parameters from random initialization.

TRANSFER LEARNING
03EVALUATION

Avoid overstating accuracy

One missed sample changes validation accuracy by 3.33 percentage points. Class-specific metrics and a fresh test set matter.

RESPONSIBLE VALIDATION
02 / DATA EXPLORATION

Small dataset. Uneven classes.

The original educational “Presidential Doggy Door” exercise distinguishes Bo from other images. Counts below are from the supplied exercise, not from a new training run.

> dataset.class_distributionORIGINAL COUNTS
Training139 images
Bo: 19Not Bo: 120
Validation30 images
Bo: 10Not Bo: 20

Illustrated bars show class proportions, not model performance. Example photographs illustrate the intended classes, not actual model predictions.

WHY IT MATTERS
13.7%

Positive examples in training

The target identity is strongly underrepresented. Accuracy alone may hide mistakes on the minority class, so precision, recall and F1 are important additions.

19 / 139 training images belong to the target class.
03 / MODEL ARCHITECTURE

Keep the vision. Replace the decision.

VGG16 acts as a feature extractor. A new small classifier learns the task-specific distinction between the target animal and other images.

> model.forward(image)CONCEPTUAL DATA FLOW
INPUT
RGB image224 × 224 × 3
PRETRAINEDVGG16 featuresConvolutional backboneFreeze → partial unfreeze
TASK-SPECIFICBinary headNew learnable parametersTrainable
OUTPUT
BONOT BO
2 class scoresConverted to probabilities

Conceptual illustration, not a layer-by-layer tensor specification. The new repository uses PyTorch and TorchVision.

04 / TRAINING STRATEGY

Two stages. Different learning rates.

Training a small classifier first reduces unnecessary changes to pretrained features. Fine-tuning then adapts the final convolutional block more cautiously.

01

Load weights

Initialize VGG16 from ImageNet-pretrained weights.

02

Train new head

Freeze convolutional features and learn the binary classifier.

03

Fine-tune

Unfreeze the final feature block and train at a lower learning rate.

04

Evaluate

Track validation loss and class-specific metrics; save the best checkpoint.

STAGE A / FEATURE EXTRACTION

Pretrained layers stay frozen

VGG16 feature blocks FROZENClassification head TRAINABLE
STAGE B / FINE-TUNING

Adapt higher-level features

Earlier feature blocks FROZENFinal feature block + head TRAINABLE
05 / ORIGINAL EXPERIMENT

Promising validation. Limited evidence.

The educational notebook reported 29 correct predictions on a 30-image validation set. This result is not a benchmark for the cleaned PyTorch implementation.

LAST REPORTED VALIDATION ACCURACY
96.67%

■ 29 correct■ 1 incorrect

Each square represents one validation prediction. The incorrect sample's class is unknown from this summary, so this is not a confusion matrix.

INTERPRETATION

What 96.67% does not prove

  • No separate independent test dataset was supplied.
  • The validation set contained only 30 samples.
  • The clean reimplementation has not been trained to reproduce this value.
  • Performance on unfamiliar lighting, poses and backgrounds remains untested.
Do not report this as production accuracy. It is an observation from the original educational experiment.
06 / INFERENCE EXPERIENCE

From an image to a prediction.

The repository includes a command-line predictor that loads a trained checkpoint and returns scores for both classes.

CLI WORKFLOW

A simple, reproducible prediction path.

After training, pass a new image to the model. The output contains the predicted label and two class scores. Scores are not calibrated confidence measures.

POWERSHELL / EXAMPLE COMMANDpython -m dog_identity.predict --image path/to/photo.jpg --checkpoint models/best_model.pt

No example prediction is shown because the clean implementation has not been trained with a verified dataset.

Bo, the target dog for the identity classifier
Bo · Reference photograph, not a model prediction
STEP 01 / DOG DETECTION

Dog or not dog?

Bear, an example of the not-dog category
Bear NOT DOG
Bo, an example of the dog category
Bo DOG
Cat, an example of the not-dog category
Cat NOT DOG
STEP 02 / IDENTITY RECOGNITION

Bo vs. Not Bo

Bo, target identity
Bo BO
Another dog, not Bo
Other dog NOT BO
Another dog with a blue ball, not Bo
Other dog NOT BO

These are labeled example photos, not outputs from a trained model.

07 / CLEAN IMPLEMENTATION

From course exercise to reusable code.

The public repository is a new modular implementation inspired by the training exercise, not a redistribution of the original notebooks.

01 / BACKBONE

TorchVision VGG16

Pretrained convolutional features are reused to support learning with a small image dataset.

02 / TRAINING

Staged optimization

Classifier training followed by controlled fine-tuning of the last feature block.

03 / VALIDATION

Class-specific metrics

Compute precision, recall and F1 alongside accuracy, reducing reliance on a single number.

04 / REPRODUCIBILITY

Separate train and predict

Command-line entry points keep training and single-image inference independent.

05 / CHECKPOINTS

Best model saving

Save the lowest-validation-loss checkpoint and keep epoch-level history locally.

06 / DISCLOSURE

Licensed data only

Original course images and proprietary teaching materials are not included in the public repository.

SOURCE CODE

Explore the implementation

Training, prediction, tests and documentation are available in the public-facing code package. The link will work after the repository is published.

View on GitHub ↗
08 / PERSONAL RETROSPECTIVE

What I learned from this experiment.

Its strongest portfolio value lies in the decisions around data scarcity, pretraining and honest model evaluation—not in a single validation accuracy figure.

BEYOND THE SCORE

A high accuracy number is meaningful only alongside the data and protocol that produced it. Transfer learning can make small-data experiments feasible, but careful validation is what makes their conclusions credible.

01 / TRANSFER LEARNING

Reuse representation, not assumptions

Features learned on ImageNet provide a useful starting point even when the downstream problem is identifying one individual animal.

VGG16ImageNetPyTorch
02 / OPTIMIZATION

Freezing is a design choice

Training a new head before unfreezing higher-level features gives control over how much of the pretrained network changes.

Frozen layersFine-tuningLearning rates
03 / CLASS IMBALANCE

Inspect each class

With fewer examples of the target class, overall accuracy may obscure low recall or high false-positive rates.

PrecisionRecallF1
04 / REPRODUCIBILITY

Separate experimentation from delivery

Transforming notebook logic into modules, tests and documented commands creates a clearer, more maintainable codebase.

Project structureTestingCLI
09 / LIMITATIONS & NEXT STEPS

A prototype, not an access-control system.

This project is an educational study in binary visual classification. Reliable real-world identity recognition would need broader data, evaluation and an ability to reject unknown inputs.

CURRENT SCOPE

Documented and implemented

Fresh PyTorch code, a VGG16 binary head, staged fine-tuning, training metrics, checkpoint saving and CLI inference. Original notebook results are explicitly labeled as historical.

FUTURE WORK

Validate real-world robustness

Collect licensed samples, use an independent test split, check duplicate leakage, compare with smaller backbones, repeat across seeds and introduce a reject/unknown option.

Attribution: The original learning activity was inspired by NVIDIA Deep Learning Institute's “Pre-Trained Models” and “Presidential Doggy Door” exercises. The public implementation is independently reorganized; no original training images are bundled.