Computer Vision1 code example
⚡ +100 XP

Transfer Learning for Computer Vision

1

What is Transfer Learning?

Transfer learning reuses a model pretrained on a large dataset (ImageNet — 1.2M images, 1000 classes) as a starting point for a new task. The pretrained model has already learned universal visual features: edges, textures, shapes, object parts. You only need to adapt the final layers. Why it works: early CNN layers are task-agnostic feature extractors. Only the final classification layers are task-specific.

2

Two Strategies

Feature Extraction — Freeze ALL pretrained layers. Add and train only a new classification head. Best when: small dataset (<5K images), similar domain to ImageNet. Fine-Tuning — Unfreeze the last few blocks and train with a small learning rate alongside the new head. Best when: medium dataset, slightly different domain. Full Fine-Tuning — Unfreeze everything. Needs large dataset or risks catastrophic forgetting of pretrained knowledge.

3

Choosing a Pretrained Backbone

EfficientNet-B0 to B7 — Excellent accuracy/speed tradeoff. Good default. ResNet-50/101 — Reliable, widely studied, easy to fine-tune. ConvNeXt-Base — Modern CNN matching ViT performance, better than ResNet. ViT-B/16 — Vision Transformer, best accuracy when pretrained on large data. MobileNetV3 — Optimized for edge/mobile deployment. DINO/SAM — Self-supervised, excellent features without task-specific pretraining.

4

Transfer Learning Pipeline

Full EfficientNet fine-tuning pipeline with two-stage training.

💡

Always normalize with ImageNet mean/std when using ImageNet-pretrained weights. Different normalization = garbage features.

Finished reading? Mark it complete to earn your XP.