Computer Vision with PyTorch: Classify Real Photos
IntermediateTransfer learning from a small pretrained model, trained and tested on a laptop CPU.
You build
A command-line program that tells which of five kinds of flower is in a photo, built by adapting a small pretrained network from torchvision (MobileNetV3-Small) to a few thousand real photos on a laptop CPU.
You need
- Writing Python with functions and imports, and running a script from a terminal
- PyTorch basics: tensors with their shape and data type, a network built from layers, and a training loop with batches, a loss, an optimizer and epochs. The course Deep Learning with PyTorch teaches all of this.
- How a classifier is trained and judged: class scores turned into probabilities, cross-entropy loss, accuracy on a validation and a test set, and what overfitting is
To build it on your own machine
This is optional and comes with a plan. The course pack brings the starting files, a ready container and a check for every lesson. You need only Docker and git, plus your own AI coding agent if you want a tutor.
What you learn
You do not train a vision model from zero. You borrow one and teach it your classes.
You build one program that says which of five flowers is in a photo. It starts from a small network already trained on a million images, and you adapt it to your own classes with a few thousand real photos, in minutes, on a laptop CPU. You see what an image is to a model, what a convolutional network looks for, how to load and augment photos, train a new final layer, fine-tune the rest, measure the result honestly and read its mistakes. One task, image classification, done properly.
- Images as Tensors. A photo is a grid of numbers in three colour channels. Decoding, resizing, cropping, scaling and normalising turn any photo file into the tensor a model expects.
- What a Pretrained Network Knows. Convolution layers turn pixels into edges, textures and parts, and finally into one feature vector. A network trained on a large image collection has already learned features that fit many other photos.
- Transfer Learning. Freeze the pretrained layers, replace the final layer, train it on your own classes, then fine-tune with a small learning rate and augmented photos.
- Honest Measurement. A fixed split, a test set used once, a confusion matrix, precision and recall per class, and a look at the photos the model gets wrong.
Lessons
A Photo Is a Tensor
Pixels and colour channels, Decoding an image file, Image tensor shape, Integer and float pixel values
Classify a Photo with a Pretrained Model
Pretrained model, ImageNet classes, Model size and speed, Normalisation
What a Convolutional Network Sees
Convolution, Feature map, Downsampling, From edges to parts
Turn a Folder of Photos into Batches
Labels from folders, Dataset and transform, A fixed random split, Class balance
Transfer Learning: Train a New Final Layer
Transfer learning, Freezing layers, A new final layer, Feature extraction
Augment the Training Photos
Data augmentation, Random crop and flip, Changes that keep the label, Training and evaluation transforms
Fine-Tune and Keep the Best Weights
Fine-tuning, Final layer first, A small learning rate, How much to unfreeze
Measure on the Test Set and Read the Mistakes
A test set used once, Confusion matrix, Precision and recall per class, Reading the mistakes
Classify a New Photo with Your Model
Loading a model for inference, Loading weights safely, What ships with a classifier, Photos from anywhere
Where it fits
Course 5 of 5 on the Machine Learning Engineer path.