FreeUpdated 12 May 202628 minEasy

Deep Computer Vision (CNN)

Lesson 2

Deep learning's role in computer vision

From hand-crafted features to representations learned from data

Deep learning's role in computer vision

Over the last decade, deep learning turned computer vision from hand-tuned features and brittle rules into models that learn straight from pixels. That change is not a small tweak; it is a different way to think about perception.

Classical ML + Handcrafted FeaturesDeep Neural Networks (Dense / MLPs)
Manual feature engineering requiredLearns features directly from pixels
Raw pixels were weak inputs for traditional ML algorithmsPixels can be fed directly into neural networks
Required image processing expertiseReduced dependence on handcrafted features
Features: , , , , Representation learning emerges during training
Separate feature extraction + classifier pipelineEnd-to-end learning becomes possible
Traditional ML: SVMs, Random ForestsDeep fully connected neural networks
Limited performance on complex visual tasksBetter learning capacity with large datasets
Math: y = ML(f(x)) where f(x) is handcrafted featuresMath: y = NN(x) where the network learns features automatically
Code intuition: features = hog(image)Code intuition: prediction = model(image_tensor)

Two pipelines, same goal

Classical ML — features hand-engineered

imagehand-crafted features (HOG / SIFT)classifier (SVM)prediction

Deep learning — features learned from pixels

imageneural network — learns features and classifiesprediction

Classical vision needs a separate feature step you design by hand; deep learning folds feature extraction into the trained network.

Neural networks are now the default engine for serious vision work, from datacenter training down to phones and wearables.

What the dense network gives up

Look again at the right-hand column: those are fully connected networks. A dense layer takes a flat vector, so the image has to be flattened first — a 28×28 grid becomes a 784-long list before the first weight is ever applied.

That step is lossless in values and catastrophic in structure. Pixel (5, 5) and pixel (5, 6) are neighbours in the image and 1 apart in the list; pixel (5, 5) and (6, 5) are also neighbours and 28 apart. The network is handed no reason to treat either pair as related. Shuffle every pixel with a fixed permutation and a dense network trains to exactly the same accuracy — proof that it never used the geometry at all.

Press Flatten below and watch the grid unravel into a row — the values all survive, the geometry does not:

Animation · Flattening Destroys Underlying Spatial Information

2D image (8 × 8) — a tiny cityscape

Sky · (0, 0) · flat index 0Sky · (0, 1) · flat index 1Sky · (0, 2) · flat index 2Sky · (0, 3) · flat index 3Sky · (0, 4) · flat index 4Sky · (0, 5) · flat index 5Sky · (0, 6) · flat index 6Sky · (0, 7) · flat index 7Sky · (1, 0) · flat index 8Sky · (1, 1) · flat index 9Sky · (1, 2) · flat index 10Sky · (1, 3) · flat index 11Sky · (1, 4) · flat index 12Sky · (1, 5) · flat index 13Sky · (1, 6) · flat index 14Sky · (1, 7) · flat index 15Sky · (2, 0) · flat index 16Sky · (2, 1) · flat index 17Sky · (2, 2) · flat index 18Building · (2, 3) · flat index 19Sky · (2, 4) · flat index 20Sky · (2, 5) · flat index 21Sky · (2, 6) · flat index 22Sky · (2, 7) · flat index 23Sky · (3, 0) · flat index 24Sky · (3, 1) · flat index 25Sky · (3, 2) · flat index 26Window · (3, 3) · flat index 27Sky · (3, 4) · flat index 28Sky · (3, 5) · flat index 29Sky · (3, 6) · flat index 30Sky · (3, 7) · flat index 31Sky · (4, 0) · flat index 32Sky · (4, 1) · flat index 33Sky · (4, 2) · flat index 34Building · (4, 3) · flat index 35Sky · (4, 4) · flat index 36Sky · (4, 5) · flat index 37Sky · (4, 6) · flat index 38Sky · (4, 7) · flat index 39Sky · (5, 0) · flat index 40Building · (5, 1) · flat index 41Window · (5, 2) · flat index 42Building · (5, 3) · flat index 43Window · (5, 4) · flat index 44Building · (5, 5) · flat index 45Sky · (5, 6) · flat index 46Sky · (5, 7) · flat index 47Road · (6, 0) · flat index 48Building · (6, 1) · flat index 49Building · (6, 2) · flat index 50Building · (6, 3) · flat index 51Building · (6, 4) · flat index 52Building · (6, 5) · flat index 53Road · (6, 6) · flat index 54Road · (6, 7) · flat index 55Road · (7, 0) · flat index 56Road · (7, 1) · flat index 57Road · (7, 2) · flat index 58Road · (7, 3) · flat index 59Road · (7, 4) · flat index 60Road · (7, 5) · flat index 61Road · (7, 6) · flat index 62Road · (7, 7) · flat index 63
SkyBuildingWindowRoad
👆 Hover any cell to see its 2D position. Click Flatten ▶ to unroll the image into the long vector an MLP would consume.

So learning features from pixels was the right move, but doing it with dense layers throws away the one thing images have that vectors do not: locality. Lesson 5 is about putting it back.


Real-world computer vision: cloud to edge

Vision models run across very different compute environments, from datacenter GPUs to low-power edge devices.

EnvironmentTypical constraintsCommon vision tasks
Mobile / edge devicesLow latency, low power, small memoryFace unlock, portrait enhancement, AR depth
Robots / drones / wearablesReal-time inference, constrained hardwareNavigation, tracking, obstacle perception
Cloud / datacenterLarge-scale training and servingFoundation models, large-scale inference

Edge models are often:

  • quantized, lower-precision weights and activations
  • pruned, redundant connections removed
  • distilled, a small student trained to mimic a large teacher
  • hardware-optimized, kernels tuned for specific accelerators

Vision in healthcare

Medical imaging already contains high-signal visual patterns, making it a strong domain for deep learning.

DomainTypical vision tasks
Radiology (CT / MRI / X-ray)Detection, localization, triaging
PathologyTissue and cell-level analysis
Retina imagingDisease screening (e.g. diabetic retinopathy)

Models help surface subtle and repeatable patterns across large datasets, usually as decision-support systems alongside clinicians, not a replacement for clinical judgment.


Autonomous driving

Self-driving systems combine:

  • perception, what's in the scene
  • prediction, what will it do next
  • planning, what should we do
  • control, how do we execute it

One important research direction explored a much simpler framing:

InputOutput
Camera frames / videoSteering and driving commands

This introduced the idea of:

pixels → actions (end-to-end learning)

The challenge:

  • safety-critical edge cases
  • rare events ("long tail")
  • interpretability
  • real-world robustness

Modern autonomy stacks therefore combine learned vision systems, rules, mapping, planning, and systems engineering, rather than betting everything on a single end-to-end network.


Facial recognition and understanding

Computer vision evolved from simple face detection to rich facial understanding.

Earlier systemsModern deep learning systems
Detect whether a face existsDetect, align, and embed faces
Limited geometric featuresIdentity, landmarks, gaze, pose, expressions
Simple classifiersDeep metric-learning pipelines

Modern systems must additionally handle:

  • occlusion (masks, hands, hair)
  • lighting variation
  • pose changes
  • privacy and bias concerns

Try it: zero-shot vision with CLIP

The "one flexible toolkit" claim above is easy to wave away in prose. Here it is concretely. CLIP is a vision-language model trained on image-caption pairs scraped from the web. It learned a shared embedding space: an image and a sentence describing that image end up close together; an unrelated sentence ends up far away.

Once you have that, classification stops being a fixed list of categories. You feed the model an image and whatever candidate captions you want, "a photo of a cat", "an indoor scene", "the year 1985", and it scores how well each one matches. No retraining, no fine-tuning, no labeled dataset. The same model handles "is this a cat?" and "is this happy?" because it lives in language-space.

Pick a preset image (or upload your own), tweak the candidate labels, and watch the scores shift:

CLIP Zero-Shot Classificationclip-vit-base-patch32 · ~150 MB
CLIP similarity
Press Score labels to compute cosine similarities.
First run downloads the model — happens once, then cached in your browser.

The model running here is clip-vit-base-patch32, the same architecture used in production by Stable Diffusion, DALL·E text encoders, and countless retrieval systems. ~150 MB; cached in your browser after the first run.


Check your understanding

1 / 6

What is the key shift deep learning brought to computer vision?


Practice it yourself

From edge-shrinking tricks to CLIP's zero-shot magic — implement the ideas, real Python, hidden tests, no setup.

Test your understanding

Prof is ready

Prof will ask you questions about Deep learning's role in computer vision — not explain it. You'll be surprised what you don't know until you have to say it.

Finished this lesson?

Read through the lesson first (0/20s).