0:00Intro: MOFUSA Tech Academy
Welcome to MOFUSA Tech Academy. Beyond learning, towards mastery.
0:09Borrow a network that studied a million photos
Sana's team has labelled a few thousand product photos. That's a lot of work, but for training a deep vision network from scratch, it's tiny. The networks that changed computer vision learned from over a million images. So here's the trick we'll learn today. What if Brightcart could borrow the visual knowledge of a network that has already studied a million photos, and simply teach it the last step: mugs, lamps, kettles? That's transfer learning, and it's how most real-world vision systems are built. But first, let's assemble a complete convolutional network, and tour the famous architectures, from a digit reader in the nineteen-nineties to networks over a hundred layers deep, and see the one big idea each one contributed.
1:01Where we are on the map
Season Two, Module Eight, stop two: CNN architectures and transfer learning.
1:08The standard CNN recipe: backbone and head
Almost every convolutional network follows the same recipe. A few convolution layers with ReLU, then a pooling step to shrink the maps. Repeat. As we go deeper, the feature maps get smaller in width and height, but the number of channels grows, so the network trades "where" for "what". At the end, the maps are averaged down and fed to a small dense classifier with softmax. The convolutional part is often called the backbone, or feature extractor. The final classifier is called the head. Keep those two words in mind.
They're the key to transfer learning.
1:50LeNet: where it began
The story starts with LeNet, developed by Yann LeCun and colleagues from the late nineteen-eighties and refined through nineteen ninety-eight. It used convolutions and pooling to read handwritten digits, and versions of it were used to read cheques. It had about sixty thousand parameters, about one thousandth of the size of AlexNet, which we'll meet shortly. The ideas were right. But computers were slow and large labelled image datasets didn't exist yet, so for over a decade, convolutional networks remained a specialised tool.
2:28AlexNet and ImageNet (2012)
Everything changed in two thousand twelve. ImageNet, a huge collection of labelled photos, ran a yearly competition: about one point two million training images in a thousand categories. That year, a deep convolutional network called AlexNet, from Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton, made far fewer mistakes than any other entry. Its top-five error rate was about fifteen percent, against twenty-six percent for the runner-up. It wasn't one new idea, but several coming together: it was trained on graphics cards, used ReLU activations, regularised with dropout, and expanded its training data with augmentation.
Many people see this result as the moment the deep learning boom began.
3:18VGG, Inception and ResNet
After AlexNet, the race was on. VGG, in two thousand fourteen, showed the power of simplicity: nothing but three-by-three convolutions, stacked sixteen or nineteen layers deep. Its weakness was size: about a hundred and thirty-eight million parameters, most of them in the dense layers at the end. Inception, also from two thousand fourteen, ran several filter sizes side by side in each block, so the network could look at small and large patterns at once, and used one-by-one convolutions to cheaply reduce the number of channels.
Then ResNet, in two thousand fifteen, added the residual connections from episode twenty-eight and went to a hundred and fifty-two layers. ResNet-50, a popular version, has about twenty-five million parameters, far fewer than VGG, and works better. Later came families that scale networks more carefully, like EfficientNet, and Vision Transformers, which apply the attention mechanism we'll meet in Module Ten to patches of an image.
4:26Data augmentation
Before transfer learning, one more tool that every vision system uses: data augmentation. A few thousand photos can become many more training examples if we make random, realistic changes to each one: flip it horizontally, rotate it slightly, crop and zoom, adjust the brightness. A mug is still a mug from a slightly different angle or in dimmer light. This teaches the network the variations it should ignore, and it's a powerful defence against overfitting. Just make sure the change doesn't alter the label. Rotate a handwritten six by a hundred and eighty degrees and it becomes a nine.
And only augment the training data. Validation and test images stay exactly as they are.
5:13Transfer learning: borrow a trained backbone
Now the main event. Take a network that has already been trained on a huge, varied image collection. Its backbone has learned general visual features: edges, textures, shapes, parts of objects. Those features are useful for almost any photo, including Brightcart's products. So we remove its old head, which predicted a thousand general categories, and attach a new, small head that predicts Brightcart's categories. There are two main ways to train it. In feature extraction, we freeze the whole backbone, locking its weights, and train only the new head.
It's fast and works with very little data. In fine-tuning, we also unfreeze some of the backbone, usually the later layers first, and train them gently, with a much smaller learning rate, so the general features are adjusted to the new task without being wrecked. Picture the experiment on Brightcart's own photos: training from scratch, with a frozen backbone, and with fine-tuning, at several different amounts of labelled data. The pattern it shows is one practitioners see again and again: with limited labelled data, a pre-trained backbone gives a big head start.
6:31When to use transfer learning
How much to freeze depends on two things: how much labelled data you have, and how similar your images are to the ones the network was pre-trained on. Little data and similar images: freeze the backbone and just train the head. More data, or quite different images: fine-tune more of the network, gently. Even for very different images, like medical scans, starting from pre-trained weights often helps more than starting from random ones. Two practical tips: prepare your images exactly the way the pre-trained model expects, with the same size and scaling, and keep the backbone's learning rate low.
This idea, pre-train once on a huge dataset, then adapt to many tasks, is one of the most important in modern AI. In Season Three, we'll see language models built on exactly the same principle. One caveat: this corner of AI moves quickly. These examples were current when we made this video, and they may look different on the day you watch it.
7:37Try it yourself: how many parameters do we train?
Here's a quick calculation. We freeze a ResNet-50 backbone, about twenty-three and a half million parameters once its original classification head is removed, which turns each photo into a list of two thousand and forty-eight features. We add a new head that predicts Brightcart's four categories. How many parameters will we actually train? Pause and compute.
Two thousand and forty-eight times four weights, plus four biases: eight thousand one hundred and ninety-six. Less than four hundredths of a percent of the whole model. That's why feature extraction is so fast and works with so little data, and why it makes an excellent baseline before trying full fine-tuning.
8:26Fine-tuning step by step
Fine-tuning works best in stages. First, freeze the whole backbone and train just the new head until validation stops improving. Then unfreeze the last block or two, and continue training with a much smaller learning rate for the backbone than for the head, often ten times smaller. If there's enough data, unfreeze a little more, always watching the validation curve for signs of overfitting. The classic mistake is a learning rate that's too large, which can wipe out the valuable features the backbone learned during pre-training.
And with very small batches, batch normalisation statistics can misbehave, as we saw in episode twenty-eight.
9:10Choosing an augmentation policy
Augmentation must suit the task. For Brightcart's product photos, flips, small rotations and lighting changes are all safe. But if the label includes colour, like "red mug", changing the colour would teach the wrong thing. And crops shouldn't cut the product out of the picture. Automated policies that randomly combine many transformations can work very well, with their strength tuned on validation data. And a small extra trick: at prediction time, average the model's answers over a few flipped or cropped versions of the image.
9:46Domain shift: when photos look different
A model trained on clean studio photos can stumble on customers' phone pictures: cluttered backgrounds, odd angles, dim lighting. That's domain shift. The fixes: include real customer photos in training, even a few hundred labelled ones; use augmentations that mimic phone photos, like blur, noise and skewed perspective; fine-tune on in-domain data; and track accuracy separately for each source of images, so a drop doesn't hide inside an average.
10:17Vision Transformers in one minute
You'll hear about Vision Transformers, so here's the idea in one minute. Cut an image into small square patches, turn each patch into a vector, and treat the patches like words in a sentence, feeding them to the transformer we'll build at the end of this season. CNNs come with built-in assumptions, look locally and reuse filters everywhere, which helps when data is limited. Vision Transformers let every patch attend to every other patch, and they shine with large amounts of data or strong pre-training. Today, both families are widely used.
10:56Shipping an image model
Finally, shipping an image model. Apply exactly the same preprocessing in production as in training. Send low-confidence predictions to a person instead of guessing. Choose a backbone small enough for your speed and hardware limits, or compress it, a topic for Season Five. Check per-category metrics on fresh data. And watch for products the model has never seen: when Brightcart launches a new style of kettle, the classifier needs new examples, and retraining.
11:29Try it yourself: which strategy?
Let's test your judgement. Three projects. Three hundred photos of everyday products. Forty thousand product photos. And two thousand X-ray scans of sealed parcels. Which strategy fits each? Pause. Three hundred everyday photos: freeze the backbone and train just the head, because there's too little data to safely change the rest. Forty thousand: fine-tune more of the network, with small learning rates. X-ray scans look nothing like everyday photos, so the backbone's higher-level features fit less well: fine-tune deeper.
The rule of thumb depends on two things: how much data you have, and how similar it is to what the backbone was trained on.
12:22Seeing what the network looks at (heatmaps)
How can we check what a CNN is paying attention to? Class-activation heatmaps use the gradients of a class score to highlight the regions of the image that pushed that score up. For a good kettle classifier, the heatmap glows on the spout and handle. But if it glows on the white background instead, the model may have learned a shortcut, like "studio photo means kettle". These heatmaps are rough, and they're not a complete explanation, but they're a quick way to catch a model that's right for the wrong reasons.
12:58Myth vs Fact
Myth: you need millions of labelled images to use deep learning for vision. Fact: thanks to transfer learning and augmentation, a few hundred to a few thousand labelled examples are often enough to build something useful, depending on how hard the task is. The only way to know is to measure it on your own validation data.
13:20Recap
Let's recap. A convolutional network is a backbone of convolution, ReLU and pooling layers, topped with a classifier head. The landmark architectures each added an idea: GPUs and ReLU in AlexNet, small stacked filters in VGG, multi-scale branches in Inception, and residual connections in ResNet. Data augmentation multiplies training examples. And transfer learning reuses a pre-trained backbone with a new head, frozen for little data and fine-tuned gently for more. One sentence to remember: don't teach a network to see from scratch.
Teach it what to look for.
14:04Next: object detection and segmentation
Mission complete. Brightcart's product classifier stands on the shoulders of a network that studied over a million photos, and needed only a fraction of the labelling work. But Dev needs more than a label. In warehouse photos, he wants to know where every product is, and draw a box or even an outline around each one. That's object detection and segmentation, next. See you on the map.