๐ข The situation
Datacore opened its own fulfillment center and installed cameras on the packing line. The operations director:
"Damaged boxes reach the customers โ returns, bad reviews. The inspector physically can't watch everything. The cameras photograph every box โ can we automatically catch crumpled and torn ones?"
Lena:
"Binary image classification: ok / defect. The dataset is small โ the inspectors labeled only 4,000 photos (400 with defects). The key technique here is transfer learning: don't train a network from scratch, fine-tune a pre-trained one. From scratch on 4,000 images it won't fly."
๐ฏ Your task
- Understand why images need convolutional networks (CNNs).
- Master transfer learning: fine-tuning a pre-trained model.
- Apply augmentations and evaluate correctly under imbalance.
๐ Theory
Why not a fully connected network
A 224ร224ร3 photo = 150,528 inputs. A dense layer of 1000 neurons โ 150M weights, and the net would have to learn a "crumpled corner" separately at every position in the frame. Convolution solves both problems: a small filter (e.g. 3ร3) slides across the image and looks for the same pattern everywhere (weight sharing).
How a CNN works
- Convolutional layers โ learn a feature hierarchy: early layers see edges and corners, middle ones โ textures, deep ones โ "crumpledness", "tears".
- Pooling โ reduces resolution, gives shift tolerance.
- The head โ a dense layer on top of the features โ classes.
Transfer learning โ practical CV's main tool
Networks pre-trained on ImageNet (millions of images) already know how to see edges, textures, shapes. Take a pre-trained backbone (ResNet, EfficientNet), then two regimes:
- Feature extraction: freeze the backbone, train only the new head. For tiny datasets.
- Fine-tuning: unfreeze some/all layers and retrain with a small LR (10โ100ร smaller than usual) so as not to destroy the pre-trained weights.
Augmentations โ free data
Random rotations, flips, brightness/contrast, crops โ from 4,000 photos we make an "infinite" stream of variations. Rules: augmentations โ train only; choose realistic ones (a box is never upside down on the conveyor? โ no vertical flip then).