Computer Vision with PyTorch: Classify Real Photos
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.
What this course covers
- A Photo Is a Tensor: Load a photo file as a tensor, read its shape, data type and value range, and bring photos of any size to one fixed size.
- Classify a Photo with a Pretrained Model: Load a pretrained classifier with its weights and their own preprocessing, run it on a photo, and read its most likely classes, including when the right answer is not among the classes it knows.
- What a Convolutional Network Sees: Explain how convolution layers turn a photo into feature maps and then into one feature vector, and trace the shape of a photo's data through the stages of a network.
- Turn a Folder of Photos into Batches: Load a folder of photos as a labelled dataset, split it once into training, validation and test sets that never change, and serve it in batches.
- Transfer Learning: Train a New Final Layer: Adapt a pretrained network to new classes by freezing its layers, replacing its final layer and training only that layer, in a run that repeats exactly.
- Augment the Training Photos: Add random crops and flips to the training photos only, explain why they help a model on photos it has not seen, and choose changes that keep the label true.
- Fine-Tune and Keep the Best Weights: Unfreeze pretrained layers, continue training with a small learning rate, keep the weights of the best epoch, and judge by the validation accuracy whether fine-tuning helped.
- Measure on the Test Set and Read the Mistakes: Measure the finished model once on the test set, read its confusion matrix and the precision and recall of each class, and inspect the photos it gets wrong to see why.
- Classify a New Photo with Your Model: Load the saved model in a separate program, classify any photo file with the same preparation as in evaluation, and explain what its probabilities do and do not tell.