How to Learn Computer Vision, from Pixels to Vision Transformers
A computer vision roadmap in eleven stages, from images as arrays and classic filters to CNNs, ResNet, detection, segmentation, Vision Transformers, CLIP and diffusion, with a tested coding problem for each topic.
How do you learn computer vision?
You learn computer vision by writing its core operations yourself in the order models depend on them, starting with images as arrays and ending with Vision Transformers, CLIP and diffusion models. Each stage reuses the one before it, so preprocessing feeds convolutions, convolutions build CNNs, and CNN features power detection and segmentation. TensorTonic has a coding problem with tests for each topic in this roadmap, and the Cracking CV study plan collects 35 computer vision problems in five sections.
This guide is a computer vision roadmap in eleven stages. Each stage has a short explanation and a table that pairs every topic with a page to read and a problem to solve, so you can learn computer vision one tested function at a time.
| Stage | What you write | What works at the end |
|---|---|---|
| 1. Images as arrays and preprocessing | Grayscale conversion, per-channel statistics, normalization, padding, cropping and bilinear resizing | A pipeline that turns any photo into a model-ready tensor |
| 2. Classic filters and edges | A Gaussian blur and Sobel gradients with hand-made kernels | An edge map of a real image |
| 3. Convolutions and pooling | Multichannel, dilated, depthwise separable and transposed convolutions and three kinds of pooling | Every layer a CNN is built from, with the right output shapes |
| 4. CNN architectures and ResNet | VGG blocks, Inception modules, residual blocks and squeeze-and-excitation | A deep classifier that keeps training well as layers are added |
| 5. Training and augmentation | Cross-entropy, label smoothing, batch normalization, MixUp, CutMix and top-k accuracy | A classifier that generalises beyond its training images |
| 6. Transfer learning | A new head on a pretrained backbone with frozen and unfrozen layers | A strong model for a small dataset |
| 7. Object detection | IoU, anchors, box encoding, NMS, FPN fusion, ROI Align, detection losses, matching and mAP | Boxes, labels and scores you can evaluate |
| 8. Segmentation | U-Net skip connections, upsampling, Dice loss and mean IoU | A class label for every pixel |
| 9. Vision Transformers | Patchify, a class token, position embeddings, attention over patches and window partitioning | An image read as a sequence of tokens |
| 10. Contrastive learning and CLIP | InfoNCE, the symmetric CLIP loss, the SigLIP loss and cosine retrieval | Images and captions in one shared embedding space |
| 11. Generative models and diffusion | A VAE, a GAN training step and the core DDPM pieces | New images generated from noise |
What does computer vision cover?
Computer vision covers the methods that let a model understand images and video, from classifying a whole image to locating, outlining and describing what it contains. The main tasks are image classification, object detection, which returns a box and a label for each object, and segmentation, which labels every pixel. Modern computer vision also includes models that connect images with text, such as CLIP, and models that generate new images, such as diffusion models.
Almost all of these tasks share the same foundations. A detector and a segmentation model both start from a CNN or Transformer backbone trained like a classifier, and a text-to-image model uses image encoders and attention layers you will have written earlier in the roadmap.
What do you need to know before learning computer vision?
You need Python, NumPy, the basics of PyTorch and an understanding of how a neural network is trained before you start learning computer vision. NumPy matters more than people expect, because most vision code is careful indexing and reshaping of four-dimensional arrays. The math is linear algebra for arrays and matrix products, calculus for gradients, and enough probability to read a softmax output.
- For arrays, you should be comfortable with shapes, broadcasting and reshaping, which the NumPy study plan covers.
- For PyTorch, you should be able to write a small network and a training loop, and the guide to learning PyTorch and the PyTorch study plan cover both.
- For neural networks, you should understand backpropagation, activations and losses at the level of the Cracking Deep Learning study plan.
- For math, the maths for machine learning guide lists what to learn and in what order.
In what order should you learn computer vision?
You should learn computer vision in the order data flows through a vision system, which means image preprocessing first, then convolutions and CNNs, then training and transfer learning, then the dense prediction tasks, and finally Transformers, contrastive models and generative models. The Cracking CV plan covers the image basics, convolution and pooling, detection, losses and augmentation and Vision Transformer material, and the research tracks and projects linked below cover the architectures, CLIP and diffusion in more depth.
Stage 1: How is an image stored, and how do you prepare it for a model?
An image is stored as an array of height by width by channels, usually with 8-bit integer values from 0 to 255, and you prepare it for a model by converting it to floats, putting the channels first and normalizing each channel. Image libraries such as PIL and OpenCV load images in height, width and channel order, and OpenCV uses BGR channel order, while PyTorch convolutions expect a batch laid out as batch, channels, height and width. Resizing and cropping bring every image to the size the model expects, and bilinear interpolation is the usual way to resize without blocky artefacts.
| Topic | Read | Practice |
|---|---|---|
| Colour channels and grayscale | RGB to Grayscale | |
| Per-channel mean and standard deviation | Basic statistics lesson | Per-Channel Mean and Std |
| Normalization | Image Normalize | |
| Padding and cropping | Zero Pad and Center Crop | |
| Resizing | Bilinear Interpolation, Bilinear Resize | |
| A transform pipeline in PyTorch | How to learn PyTorch | Transform Pipeline |
Normalization subtracts a per-channel mean and divides by a per-channel standard deviation, so the inputs sit near zero with a similar scale. When you later reuse a pretrained model, you must apply the same statistics it was trained with, which is why it pays to compute them yourself once.
Stage 2: How do classic filters find edges?
Classic filters find edges by sliding a small hand-designed kernel over the image and computing a weighted sum at each position, which gives a large response wherever brightness changes quickly. A Gaussian blur uses weights from a 2D normal distribution to average each pixel with its neighbours and remove noise. The Sobel filter estimates the horizontal and vertical derivatives, and the square root of the sum of their squares is large at edges.
| Topic | Read | Practice |
|---|---|---|
| Sliding a kernel over an image | 2D Convolution (Image Filtering) | |
| Gaussian blur | Gaussian Blur 2D | |
| Image gradients and edges | Partial derivatives and gradients | Sobel Edge Detection |
These filters are worth writing because a convolutional layer performs the same sliding weighted sum with kernels that are learned instead of designed. Blurring before taking derivatives is standard, since derivatives amplify pixel noise, and the Gaussian kernel is separable, so a 2D blur can be computed as one horizontal and one vertical 1D pass.
Stage 3: How do convolutions and pooling work?
A convolution layer slides a set of learned K by K filters over the input, and each filter has one slice per input channel whose results are summed into a single output map. A layer with C_out filters has a weight tensor of shape C_out by C_in by K by K, and with padding P and stride S the output height is (H plus 2P minus K) divided by S, rounded down, plus 1. Pooling then shrinks each feature map by taking the maximum or the mean over small windows, with no learned weights.
| Topic | Read | Practice |
|---|---|---|
| A single-channel convolution | AlexNet convolution layers | 2D Convolution from Scratch |
| Multiple input and output channels | Multichannel 2D Convolution | |
| A convolution layer in PyTorch | Conv2d from Scratch | |
| Dilated convolution | Dilated 2D Convolution | |
| Depthwise separable convolution | Depthwise Separable Convolution | |
| Transposed convolution | 2D Transposed Convolution | |
| Max and average pooling | AlexNet pooling, VGG max pooling | Max Pool 2D, Average Pool 2D |
| Adaptive and global pooling | Adaptive Average Pool 2D, Global Average Pooling |
The variants each solve a specific problem. Dilated convolutions see a wider area without extra weights, depthwise separable convolutions cut the cost for mobile networks, and transposed convolutions upsample feature maps for segmentation. Global average pooling reduces each channel to one number at the end of a classifier, which lets the same network accept different input sizes.
Stage 4: Which CNN architectures should you study, and why does ResNet matter?
The CNN architectures worth studying are VGG, Inception and ResNet, and ResNet matters most because its residual connection made very deep networks trainable. A residual block computes a small stack of convolutions F of x and adds the input back, so the block outputs F of x plus x and only has to learn a correction. The identity path gives gradients a direct route to early layers, which let He and colleagues train networks with 152 layers on ImageNet in 2015.
| Topic | Read | Practice |
|---|---|---|
| Stacks of small kernels | VGG convolution block, VGG full network | VGG Convolution Block |
| Parallel branches with 1 by 1 reductions | Inception Module | |
| The residual connection | ResNet skip connection, ResNet identity block | ResNet Residual Block |
| Bottleneck and downsampling blocks | ResNet bottleneck, ResNet conv block | Residual Block |
| The full ResNet | ResNet full network | |
| Dense connections | DenseNet dense block | |
| Channel attention | Squeeze-and-Excitation Block |
VGG showed that stacks of 3 by 3 convolutions cover a large receptive field with fewer weights than one large kernel. Inception ran several kernel sizes in parallel and used 1 by 1 convolutions to keep the cost down, and ResNet bottleneck blocks use the same 1 by 1 trick around a 3 by 3 layer. Squeeze-and-excitation reweights the channels of a block from their pooled values, and it appears in later efficient networks.
Stage 5: How do you train an image classifier that generalises?
You train an image classifier that generalises by combining a cross-entropy loss and a standard optimizer with data augmentation that shows the model realistic variations of each image. Random resized crops, horizontal flips and colour jitter teach the model that these changes do not alter the class, while batch normalization and dropout keep training stable and reduce overfitting. MixUp and CutMix go further by blending two images and their labels, which acts as a strong regularizer.
| Topic | Read | Practice |
|---|---|---|
| The classification loss | Which loss function to use | Cross-Entropy Loss |
| Label smoothing | Label Smoothing Loss | |
| Batch normalization | ResNet batch norm | Batch Normalization |
| Dropout | AlexNet dropout | Dropout from Scratch |
| Crops, flips and colour changes | AlexNet data augmentation | |
| Mixing images and labels | MixUp Augmentation, CutMix Augmentation | |
| Top-k accuracy | ML evaluation metrics | Top-K Classification Accuracy |
| Debugging a stuck run | Training loss not decreasing |
An augmentation is only safe when it keeps the label true, so flipping a photo of a cat is fine while flipping text or rotating a 6 into a 9 is not. Report top-1 and top-5 accuracy on a held-out set, and look at the confusion between classes, because a single accuracy number hides which classes the model mixes up.
Stage 6: How does transfer learning work for vision models?
Transfer learning works by taking a backbone pretrained on a large dataset such as ImageNet, replacing its final classification layer with one sized for your classes, and training on your smaller dataset. You usually train only the new head first with the backbone frozen, then unfreeze the later layers and continue with a smaller learning rate. Early layers detect generic edges and textures that transfer well, while later layers are more specific to the original task.
| Topic | Read | Practice |
|---|---|---|
| The pretrained backbone and its head | ResNet full network | |
| Reusing the pretraining statistics | Image Normalize | |
| Batch normalization with small batches | Batch normalization lesson | |
| Optimizer and learning rate choice | Which optimizer to use | Learning Rate Warmup Scheduler |
Most real vision projects start this way, because a fine-tuned pretrained model beats a model trained from scratch whenever data is limited. Reuse the preprocessing of the backbone exactly, and consider keeping batch normalization in evaluation mode when your batches are small.
Stage 7: How does object detection work?
Object detection works by running a backbone over the image and predicting, at many positions and scales, a class score and a box for each candidate object. Many detectors place anchor boxes of preset sizes on the feature map, label each anchor by its IoU with the true boxes, and regress small offsets from the anchor to the object. At inference, non-maximum suppression removes duplicate boxes that overlap a higher-scoring box of the same class, and the detector is scored with mean average precision.
| Topic | Read | Practice |
|---|---|---|
| Intersection over union | Intersection over Union (IoU), Pairwise IoU | |
| Anchor boxes | Anchor Box Generation | |
| Box offsets against an anchor | Box Encode and Decode | |
| Removing duplicate boxes | Non-Maximum Suppression, Soft Non-Maximum Suppression | |
| Feature pyramids | FPN Top-Down Fusion | |
| Features for each region | ROI Align | |
| Class imbalance in dense detectors | Sigmoid Focal Loss | |
| Box regression losses | Generalized IoU Loss, Complete IoU Loss | |
| Set prediction without NMS | Hungarian Matching | |
| Mean average precision | ML evaluation metrics | Compute Mean Average Precision (mAP) |
Write IoU first, since anchor matching, NMS, the IoU-based losses and mAP all depend on it. Feature pyramids let a detector find small objects on fine maps and large ones on coarse maps, focal loss handles the huge number of easy background anchors in one-stage detectors, and DETR replaces anchors and NMS with Hungarian matching between a fixed set of predictions and the true objects.
Stage 8: How does image segmentation work?
Image segmentation works by predicting a class for every pixel, which needs a network whose output has the same height and width as its input. U-Net does this with an encoder that downsamples and adds channels, a decoder that upsamples back to full resolution, and skip connections that concatenate encoder features into the decoder to restore fine detail. Semantic segmentation labels pixels by class, instance segmentation separates individual objects, and panoptic segmentation does both.
| Topic | Read | Practice |
|---|---|---|
| The encoder and decoder | U-Net encoder block, U-Net decoder block | |
| Skip connections | U-Net skip connection | U-Net Skip Connection |
| Learned upsampling | 2D Transposed Convolution | |
| The full U-Net | U-Net output layer, U-Net full network | |
| A loss for small foreground regions | Dice Loss | |
| The segmentation metric | Mean IoU for Segmentation |
Segmentation reuses earlier stages directly, with transposed convolutions for upsampling and IoU computed over masks instead of boxes. Dice loss helps when the foreground covers a small part of the image, and mean IoU across classes is the standard metric.
Stage 9: How does a Vision Transformer read an image?
A Vision Transformer reads an image by cutting it into non-overlapping patches, flattening each patch and projecting it to a vector, so the image becomes a sequence of tokens like words in a sentence. A 224 by 224 image with 16 by 16 patches becomes 196 tokens, and this projection is the same as a convolution whose kernel size and stride equal the patch size. A learned class token and position embeddings are added, Transformer encoder blocks let every patch attend to every other patch, and the final class token feeds the classifier.
| Topic | Read | Practice |
|---|---|---|
| Cutting an image into patches | ViT patch embedding | ViT Patchify, Patchify a Batch of Images |
| The class token | ViT class token | |
| Position embeddings | ViT position embedding | 2D Sinusoidal Positional Embedding |
| Attention over patches | ViT encoder block | ViT Multi-Head Self-Attention |
| The classification head | ViT MLP head | |
| The full model | ViT full network | Build a Tiny Vision Transformer |
| Windowed attention | Window Partition and Reverse |
A ViT gives up the locality and translation equivariance that convolutions build in, so it needs more data or stronger augmentation to match a CNN. Windowed attention, as in the Swin Transformer, limits attention to local windows to keep the cost manageable at high resolution.
Stage 10: How does CLIP learn from images and captions?
CLIP learns from images and captions by training an image encoder and a text encoder so that each image and its own caption end up with similar embeddings. For a batch of N pairs it computes an N by N matrix of cosine similarities scaled by a learned temperature, and the loss is a cross-entropy over the rows plus one over the columns, with the matching pairs on the diagonal. Every other caption in the batch acts as a negative example, and the original CLIP was trained this way on 400 million image and text pairs.
| Topic | Read | Practice |
|---|---|---|
| The contrastive loss | InfoNCE Loss | |
| The CLIP objective | Symmetric CLIP Contrastive Loss | |
| The sigmoid loss | SigLIP Pairwise Loss | |
| Retrieval and zero-shot classification | CLIP Cosine Retrieval | |
| The text encoder | Transformer encoder block | |
| Training both encoders end to end | Train a Tiny CLIP from Scratch |
Once trained, CLIP classifies images it was never labelled for by embedding one text prompt per class and picking the closest one. SigLIP replaces the softmax over the batch with an independent sigmoid for every pair, which makes very large batches cheaper to train.
Stage 11: Where do generative models and diffusion fit in?
Generative models fit at the end of the roadmap because they reuse almost everything before them, from convolutions and U-Nets to attention and text embeddings. A VAE learns a smooth latent space with a reconstruction loss and a KL penalty, and a GAN trains a generator against a discriminator. A diffusion model adds Gaussian noise to images and trains a network, usually a U-Net or a Transformer, to predict that noise, then generates by removing noise step by step from pure randomness.
| Topic | Read | Practice |
|---|---|---|
| Variational autoencoders | VAE reparameterization | Variational Autoencoder Forward Pass |
| Generative adversarial networks | GAN full network, GAN mode collapse | GAN Training Step |
| Adding noise in one jump | DDPM forward diffusion | Forward Diffusion Sample |
| The noise prediction loss | DDPM training loss | Noise Prediction Loss |
| Sampling from noise | DDPM sampling | DDPM Ancestral Step |
| The full diffusion path | How to learn diffusion models | Build Diffusion Model from Scratch study plan |
Diffusion is a large topic of its own, and the guide to learning diffusion models breaks it into nine stages. The Build Diffusion Model from Scratch study plan covers that material in 26 problems across seven sections.
Can you learn computer vision without a GPU?
Yes, you can learn computer vision without a GPU, because every operation in this roadmap can be written and tested on small arrays, and small models on small images train on a laptop CPU. Fashion-MNIST images are 28 by 28 pixels, and a tiny CNN or ViT trains on them quickly enough to run many experiments. A GPU only becomes necessary when you train large models on full-size images or fine-tune big pretrained backbones on large datasets.
The coding problems linked in this guide run in the browser and are checked against tests, so there is nothing to install. Our guide on practising ML without a GPU covers where to find compute when you want to train something larger.
What should you build to learn computer vision?
You should build a few small end-to-end projects that each answer a question, such as why a CNN beats a ViT on little data or how a contrastive model takes shortcuts. A project like this forces you to combine preprocessing, a model, a training loop and an evaluation, and it gives you something concrete to explain in an interview.
| Project | What you build | What you learn |
|---|---|---|
| Build a Tiny Vision Transformer | A ViT trained on Fashion-MNIST next to a CNN with the same budget, with tests of patch shuffling, local attention, augmentation and more data | Why a CNN wins on little data and what closes the gap |
| Train a Tiny CLIP from Scratch | An image encoder and a text encoder trained into one shared space on drawn scenes of coloured shapes | Retrieval, zero-shot classification and how hard negatives fix a shortcut |
| Generate Images with Diffusion and Rectified Flow | DDPM and rectified flow trained on a 2D spiral and then on 14 by 14 clothing images | How generation works and how many sampling steps each model needs |
| A fine-tuned classifier on your own images | A pretrained ResNet with a new head, trained on a dataset you collect | Transfer learning, preprocessing and honest evaluation on held-out data |
The Computer Vision projects sheet lists more builds, and the guide to building an ML portfolio explains how to present them. If you are preparing for interviews, the computer vision interview questions guide has model answers for the questions asked most often on each of these stages.
What mistakes do people make when learning computer vision?
- Skipping preprocessing and treating it as library glue leaves you unable to find bugs such as a BGR image fed to an RGB model or normalization statistics that differ between training and inference.
- Jumping to Vision Transformers before convolutions and ResNet makes it hard to understand why ViTs need more data, since that answer depends on what convolutions assume about images.
- Training from scratch on a small dataset when a pretrained backbone is available wastes time and usually gives a worse model.
- Applying geometric augmentation to an image without applying it to the boxes or masks gives labels that no longer match the pixels.
- Mixing up box formats, such as corners against a centre with width and height, produces detection code that runs and returns wrong numbers.
- Checking only the training loss hides overfitting, so track accuracy, mAP or mean IoU on a held-out set from the first run.
- Starting with a large model on a large dataset makes every experiment slow, while a small model on Fashion-MNIST or CIFAR-10 shows the same bugs in minutes.
Practice this
- Multichannel 2D Convolution is the operation every CNN is built from, with padding, stride and the sum over input channels in one function.
- Non-Maximum Suppression combines IoU with the greedy loop that turns raw detector outputs into a clean set of boxes.
- ViT Patchify turns an image into a sequence of tokens, which is the step that connects vision to Transformers.
Then work through the full Cracking CV study plan, or train a ViT against a CNN in the Build a Tiny Vision Transformer project.
How long does it take to learn computer vision?
Most people who already know Python and the basics of neural networks can work through the core of computer vision in a few months of steady practice. Image preprocessing, convolutions, CNN architectures and transfer learning come first and take the longest to make solid. Detection, segmentation, Vision Transformers and CLIP each reuse those foundations, so they go faster once the convolution and training material is comfortable.
What math do you need for computer vision?
You need linear algebra, basic calculus and some probability for computer vision. Linear algebra covers images as arrays, convolutions as weighted sums and attention as matrix products. Calculus covers gradients and backpropagation, and probability covers softmax outputs, the cross-entropy loss and the Gaussian noise used in diffusion models.
Do you still need classic image processing now that deep learning dominates?
You still need a small amount of classic image processing, because every deep vision pipeline starts with loading, resizing, cropping and normalizing images. Filters such as the Gaussian blur and the Sobel operator also explain what a convolutional layer computes. You do not need to master older feature pipelines in depth before moving on to CNNs.
Which datasets should you start with when learning computer vision?
You should start with small datasets such as MNIST, Fashion-MNIST or CIFAR-10, because a model trains on them in minutes and every bug shows up quickly. They are large enough to compare a CNN with a Vision Transformer or to test an augmentation. Move to a larger dataset or a detection benchmark once your training loop and evaluation code are reliable.
Is computer vision still worth learning with large multimodal models available?
Computer vision is still worth learning, because large multimodal models are built from the same parts, such as patch embeddings, Vision Transformer encoders and contrastive image and text training. Teams that fine-tune, evaluate or deploy these models need people who understand how images become tokens and why a model fails on a given input. Many production systems also still run small CNN or detector models on cameras and phones, where a large model is too slow or too expensive.
Related guides
- Computer vision interview questions with answers
- How to learn diffusion models from scratch, one stage at a time
- How to learn PyTorch, from tensors to a training loop
- Deep learning interview questions with answers
- 15 ML papers worth implementing from scratch, and in what order
- How to practise ML with no GPU, no dataset and no team