Computer Vision: From Fundamentals to Applications
MSc&T · Year 1 · Period 2
Contents
- Introduction and overview
- 0. Review: convolution, CNNs, boxes
- 1. Object detection: the two paradigms
- 2. Evaluation (mAP) and modern detectors
- 3. Segmentation: semantic, instance, panoptic, SAM
- 4. Data, benchmarks and annotation
- 5. Multi-object tracking
- 6. Applied 3D vision: stereo and LiDAR
- 7. Industrial case studies
- 8. Deployment: ONNX, quantization, edge
- 9. Ethics, robustness and limits
- Exercises
- Projects and assessment
- References
Introduction and overview
| Module | Computer Vision: From Fundamentals to Applications |
| Code | MSc&T Brochure (no SynapseS code of its own) |
| Team and workload | Instructors: master’s team (instructor to be confirmed) · 36 h · 4.5 ECTS · the complete application-oriented vision pipeline: detection, segmentation, tracking, 3D vision, industrial case studies and embedded deployment — the “systems and applications” counterpart of the P1 course “Image Analysis and Computer Vision”. |
| Official course description (SynapseS 2026-2027) | No “Computer Vision” course unit in the LLGA track composition for S2 2026-2027. Closest course unit in the same period and the same track: CSC_52002_EP — “IA générative multimodale” (Multimodal Generative AI) (period X-3A-P2, from 04/01/2027 to 19/03/2027; course taught in English; head of the course unit: Xi Wang, with Vicky Kalogeiton on the track page; the facts of its sheet are quoted on the Multimodal Generative AI page): partial overlap with the brochure, see the “Official objectives and syllabus” section. |
| Assessment | Not displayed: the module has no SynapseS sheet of its own and the MSc&T brochure states no assessment modality; the subjects and the exam of Projects and assessment are proposals of these notes. |
| Status in the program | Slot TBCNotes kept for reference Announced in the MSc&T brochure; not in the 2026–27 LLGA lists; covered here for reference. The home page lists it under “Slot TBC — announced, not yet in the wiki lists”, on the AI-systems route. |
Audience: a CV engineer leaving benchmarks for field latency / robustness. Empirical first: high lab mAP, low nighttime recall; a tracker that swaps IDs at crossings — then we name detection, SAM, MOT, stereo/LiDAR, edge deploy.
The “systems” counterpart of foundational vision: full application pipeline.
What you will be able to do
- Compare the two paradigms of object detection and choose a detector under the application constraint.
- Rigorously evaluate a detector with mAP and read a public benchmark without being misled.
- Distinguish semantic, instance and panoptic segmentation, and use a generic segmentation model such as SAM.
- Implement multi-object tracking on a video sequence and measure it with MOTA and IDF1.
- Exploit stereo and LiDAR for applied 3D perception.
- Build and annotate a vision dataset, and measure its biases.
- Deploy a model under constraint: ONNX export, quantization, edge execution.
- Analyze the ethics, robustness and limits of an embedded vision system, with a per-subgroup evaluation.
Official objectives and syllabus (2026-2027 catalog)
Since this module is published by the brochure without a SynapseS course description of its own, the closest official reference in the 2026-2027 catalog is the description of CSC_52002_EP — “IA générative multimodale” (Multimodal Generative AI), a course unit of the (computer science) in-depth program of the LLGA track S2 with a vision focus.
Its official description presents multimodal generative AI — vision, audio, tactile information — as a paradigm shift that recomposes entire industries, from healthcare to automotive (tools such as Dall-E 3, Midjourney, GPT-Vision; autonomous driving).
The official course proposes to go “beyond CNNs and transformers” and to cover the advanced topics of multimodal generative AI: from image generation to that of videos, sounds and robot actions. Official prerequisites: not communicated (empty tab on the description).
| Official topic (CSC_52002_EP description) | Course section |
|---|---|
| Large vision models (GPT-Vision) | ch1–ch3 — detection, evaluation and segmentation (up to SAM), in a “foundation” logic |
| Beyond CNNs and transformers | ch0 — Refresher: convolution, CNNs, boxes (a stated starting point, then superseded) |
| Image and video generation | outside the scope of these materials; see the Image Synthesis module and Multimodal Generative AI of the same period |
| Sound and robot actions | outside the scope of these materials |
Complement to the official syllabus — the themes structuring the brochure and these materials (object detection, segmentation and SAM, multi-object tracking, 3D vision with stereo and LiDAR, dataset construction, industrial case studies, ONNX/quantization/edge deployment, ethics and robustness) do not appear in the description of the CSC_52002_EP course unit: the correspondence above is partial and these materials keep the brochure framing (36 h, 4.5 ECTS).
Where this course fits in the program
Module of period 2 of M1 (36 h and 4.5 ECTS in the brochure), announced in the MSc&T brochure; not in the 2026–27 LLGA lists; covered here for reference — the home page places it on the AI-systems route. No dedicated SynapseS course description exists in the 2026-2027 catalog (period and assessment modalities: not communicated). It is the module that turns vision skills into deployment skills.
- Prerequisites — Image Analysis and Computer Vision (P1), whose applied extension it is: its statements of IoU, AP, NMS and rectified stereo are recalled here, not redone. Deep Learning (P1), or its P2 variant taken in parallel, for CNNs and training; the review section covers convolution, CNNs and bounding boxes.
- Downstream modules — the deployment chapter (ONNX, quantization, edge) directly prepares ML Ops and LLM Engineering Principles (M2), and the industrial case studies anticipate the careers targeted by the master’s program; vision systems also feed the multimodal pipelines of the Multimodal Generative AI module (same period), and the attacks of ch. 9 are treated in depth in Security and Robustness (M2).
Course outline
- Review: convolution, CNNs, boxes — the deep vision building blocks revisited before the application tasks.
- Object detection: the two paradigms — one-stage and two-stage detectors, and their speed-accuracy trade-offs.
- Evaluation (mAP) and modern detectors — measuring honestly first, then the panorama of recent architectures.
- Segmentation: semantic, instance, panoptic, SAM — the three granularities of segmentation and the era of foundation models.
- Data, benchmarks and annotation — building the dataset and the protocol before chasing the model.
- Multi-object tracking — following targets across a video, identities included.
- Applied 3D vision: stereo and LiDAR — recovering depth for embedded applications.
- Industrial case studies — real deployments, with their constraints and lessons learned.
- Deployment: ONNX, quantization, edge — fitting a model into an embedded compute budget.
- Ethics, robustness and limits — biases, attacks and failure cases: what a deployed system must own up to.
- Exercises, Projects and assessment and References — systematic training, project subjects with an exam proposal, and sources to go further.
Session plan
36 h in class = 12 sessions of 3 h. The volume is the 36 h announced for this module by the MSc&T brochure — an announced volume, with no SynapseS sheet yet (the module has no catalogue code of its own); no session-by-session programme is published, so the split below is our proposal for covering these notes in that time. Level 1 = foundations (reviews, definitions, first worked examples), 2 = core methods and systems; the level never goes down from one session to the next.
| Session | Hours | Level | Content | Practice |
|---|---|---|---|---|
| 1 | 3 h | 1 | ch. 0 Review: convolution, CNNs, bounding boxes; IoU recalled from the P1 vision course | Ex. 1 |
| 2 | 3 h | 1 | ch. 1.1–1.2 Two-stage and single-stage detectors, anchors, focal loss | Ex. 4 |
| 3 | 3 h | 2 | ch. 1.3 Non-maximum suppression and Soft-NMS; ch. 2.1 the COCO protocol: AP recalled, ten IoU thresholds, 101 recall points, object sizes | Ex. 2, 3 |
| 4 | 3 h | 2 | ch. 2.2–2.5 Anchor-free detectors, DETR, the YOLO ecosystem; the COCO lab | lab sheet 2.5: continue the detector lab of the P1 vision course on COCO — size breakdown, error analysis, detections saved for session 7 |
| 5 | 3 h | 2 | ch. 3 Segmentation: FCN, U-Net, DeepLab, Mask R-CNN, panoptic quality, SAM and its prompts | Ex. 7; Example 3.3 |
| 6 | 3 h | 2 | ch. 4 Data, benchmarks and annotation; evaluation pitfalls | Ex. 11 |
| 7 | 3 h | 2 | ch. 5 Multi-object tracking: SORT and the Kalman filter, DeepSORT, ByteTrack, MOTA and IDF1 | Ex. 5, 12; track the detections saved in session 4 |
| 8 | 3 h | 2 | ch. 6.1–6.2 Pinhole model; stereo: depth law recalled, cost volume, SGM, PSM-Net | Ex. 6 |
| 9 | 3 h | 2 | ch. 6.3–6.4 LiDAR point clouds, PointNet, fusion in bird’s eye view | Ex. 9 |
| 10 | 3 h | 2 | ch. 7 Industrial case studies: inspection, driving, medical imaging | Example 7.1; start the project (Ex. 13) |
| 11 | 3 h | 2 | ch. 8 Deployment: ONNX export, INT8 quantization, compression, latency budgets | Ex. 8, 10 |
| 12 | 3 h | 2 | ch. 9 Ethics, robustness and limits; per-subgroup evaluation | Example 9.1; project presentations (Ex. 13) |
Self-study, outside the 36 h: none — every chapter is covered in class; the project (Ex. 13) is the personal work expected alongside.
How to study this module
- Redo the review section if the P1 vision course is no longer fresh: detection and segmentation reuse convolution and boxes without revisiting them.
- For every task, start from the metric before the model: understanding mAP or IoU first avoids 90 % of benchmark misinterpretations.
- Reproduce a small end-to-end experiment on a public dataset: training, evaluation, then export — that is the heart of the module.
- Concretely try ONNX export and quantization on a small model: the deployment chapter is understood with hands on the keyboard.
- Prepare questions for the industrial case studies: that is where constraints, trade-offs and real careers play out.
- Redo the exercises of each section before moving on to the next; they calibrate your expectations of what a deployed system can actually do.
Independent note This module gives the master’s program its “perception systems” building block: vision is the sensory input of multimodal pipelines and multimodal LLMs, and its embedded deployment foreshadows the practices of the ML Ops and LLM Engineering Principles module (M2). Inspection, autonomous vehicles, robotics, imaging: the course’s case studies are a dress rehearsal for the industrial careers targeted by the program.
0. Review: convolution, CNNs, boxes
Every task of this module — detecting, segmenting, tracking — outputs regions of an image and must compare them with annotated regions. This chapter recalls the deep-learning background assumed and the one tool used everywhere afterwards — the bounding box and its overlap measure, the IoU, stated in the P1 vision course — then proves the properties of the IoU that the metrics of chapter 2 rely on.
L3 review — what is assumed known
- Digital image: an H \times W grid of pixels with C channels (3 in RGB), a tensor x \in \mathbb{R}^{C \times H \times W}; grayscale, resolution, sampling (cf. Image Analysis and Computer Vision, ch. 1 and Signal Processing, ch. 4).
- 2D convolution: (I * k)(u, v) = \sum_{i,j} I(u-i, v-j)\,k(i, j); properties (commutativity, association with the product), Sobel / low-pass counterparts, correlation vs convolution (cf. Image Analysis and Computer Vision, ch. 2).
- Convolutional networks: receptive fields, weight sharing, pooling, the ResNet architecture (residual connections) — cf. Deep Learning, ch. 4, or the CNN section of the P2 variant; attention and transformers — Deep Learning, ch. 6, or the transformer block of the P2 variant.
- Supervised learning: gradient descent, SGD/Adam, overfitting, regularization, transfer learning and fine-tuning — cf. Deep Learning, chapters 3 and 7; cross-validation, ROC curves — cf. Machine Learning, ch. 1 and 4.
The P1 course “Image Analysis and Computer Vision” (CSC_51073_EP) laid the foundations: filtering, local features, projective geometry, reconstruction. The present module takes the systems and applications orientation: we build the complete pipeline of a vision product — from annotated data to a model deployed on constrained hardware — and study the building blocks industry actually uses (detectors, segmenters, trackers, 3D sensors, inference runtimes).
Recall — stated in Image Analysis and Computer Vision, Definition 9.4
Definition 0.1 — Bounding box and IoU (Image Analysis and Computer Vision, Definition 9.4, the reference statement). A bounding box is an axis-aligned rectangle b = (x_1, y_1, x_2, y_2) with x_1 < x_2, y_1 < y_2, encoding the top-left and bottom-right corners. For two boxes a and b, let A(a) denote the area of the rectangle.
The intersection-over-union is \mathrm{IoU}(a, b) \;=\; \frac{|a \cap b|}{|a \cup b|} \;=\; \frac{|a \cap b|}{A(a) + A(b) - |a \cap b|}, where |\cdot| denotes area.
The intersection box has corners (\max(x_1^a, x_1^b), \max(y_1^a, y_1^b)) and (\min(x_2^a, x_2^b), \min(y_2^a, y_2^b)) if these coordinates are consistent, otherwise the intersection is empty and \mathrm{IoU} = 0.
Proposition 0.2 — Properties of IoU For all axis-aligned boxes a, b:
- (i) \mathrm{IoU}(a,b) \in [0, 1];
- (ii) \mathrm{IoU}(a,b) = \mathrm{IoU}(b,a);
- (iii) \mathrm{IoU}(a,b) = 1 if and only if a = b (up to equality of pixel sets);
- (iv) \mathrm{IoU}(a,b) = 0 if and only if the interiors of the two rectangles are disjoint.
Proof.
- (i) The intersection area is a rectangle area, positive and bounded by each of the areas, so 0 \leq |a \cap b| \leq \min(A(a), A(b)) \leq |a \cup b| .
- (ii) The intersection and union operations are symmetric.
- (iii) If \mathrm{IoU} = 1 then |a \cap b| = |a \cup b|, so |a \setminus b| = |b \setminus a| = 0 and the rectangles coincide; the converse is immediate.
- (iv) If the intersection is empty, the numerator is zero; conversely a non-empty intersection rectangle has strictly positive area, hence \mathrm{IoU} > 0. ∎
Example 0.3 — An IoU computation Let the ground truth be g = (0, 0, 10, 10) (area 100) and the prediction p = (5, 5, 15, 15) (area 100). The intersection is the square (5,5,10,10) of area 25, the union equals 100 + 100 - 25 = 175, so \mathrm{IoU}(g, p) = 25/175 \approx 0.143 : the prediction is rejected at the usual threshold \tau = 0.5.
A prediction shifted by only 2 pixels, p' = (2, 2, 12, 12), gives an intersection of 64 and a union of 136, i.e. \mathrm{IoU} \approx 0.47 — still below the threshold: on small objects the metric is unforgiving, which will justify the multiple thresholds of chapter 2.
Note — Position in the program This module is announced in the MSc&T brochure (period 2) but is not in the 2026–27 LLGA lists; these notes cover it for reference, and its instructor would be confirmed if it opens. The technical choices (detectors selected, lab datasets) will follow the industrial standards presented here: COCO for detection/segmentation, MOT for tracking, nuScenes/KITTI for 3D, MVTec AD for inspection.
1. Object detection: the two paradigms
Concrete scene: an embedded detector misses small objects because it looks at a single scale. This chapter defines the detection task — finding an unknown number of objects and their boxes — and the two families of networks that solve it.
What breaks mAP alone without latency cost; too aggressive NMS; dataset without night / weather domain.
Definition 1.1 — The detection task Given an image x, produce a set \{(b_i, c_i, s_i)\}_{i=1}^{N} where b_i is a bounding box, c_i a class among K classes and s_i \in [0,1] a confidence score. Unlike classification (cf. Deep Learning, ch. 1), the output has variable cardinality: the number of objects is unknown and depends on the image content.
1.1. The two-stage family: propose then refine
Two-stage detectors separate the generation of candidates from their classification:
- R-CNN (2014): ~2000 candidate regions extracted by cluster-based segmentation (selective search), each crop goes through a CNN; slow (tens of seconds per image), but the proof of concept of the CNN in detection;
- Fast R-CNN (2015): the whole image passes through the CNN once, candidates are projected into the feature space (RoI pooling); only a light classifier is applied per candidate;
- Faster R-CNN (2015): candidates are produced by an integrated, end-to-end learned Region Proposal Network (RPN) — the canonical scheme;
- FPN (2017): feature pyramid; small objects are detected on the high-resolution maps, large ones on the low-resolution maps.
Definition 1.2 — Anchors For each cell of a feature map, the RPN predicts offsets with respect to a fixed set of A reference rectangles — the anchors — produced by the Cartesian product of S scales and R aspect ratios, so that A = SR.
Faster R-CNN takes 3 scales (box areas of 128², 256² and 512² pixels) and 3 ratios (1:2, 1:1, 2:1), hence A = 9 anchors per position. With an FPN, each pyramid level keeps a single scale and the three ratios, A = 3 per position, and the five levels together cover 15 anchor shapes; RetinaNet uses A = 9 per position on every level.
The box regression encodes t_x = \frac{x - x_a}{w_a}, \quad t_y = \frac{y - y_a}{h_a}, \quad t_w = \log\frac{w}{w_a}, \quad t_h = \log\frac{h}{h_a}, where (x_a, y_a, w_a, h_a) are the center and size of the anchor.
Proposition 1.3 — Why the logarithm for sizes The logarithmic parameterization makes the regression scale invariant: the same offset t_w corresponds to the same size ratio. An error |t_w| = \varepsilon means w = w_a e^{\pm\varepsilon}, i.e. a constant relative error rate; with a linear parameterization, the same absolute error would be negligible for a truck (600 px) and fatal for a distant pedestrian (10 px).
Proof. With t_w = \log(w / w_a), we have w = w_a e^{t_w}, so the relative error equals |e^{t_w} - 1| \approx |t_w| at first order — independent of w_a.
With a direct parameterization \tilde t_w = w - w_a, the relative error |\tilde t_w| / w_a depends on w_a; fixing a homogeneous noise scale for all object sizes would require weighting by size class, and the loss would be dominated by large objects. ∎
1.2. The single-stage family: everything in one pass
Single-stage detectors directly predict boxes and classes over a dense grid, in a single pass:
- YOLO (2016): the image is cut into a 7 \times 7 grid; each cell predicts 2 boxes + class probabilities; remarkable speed (45 images/s at the time), at the cost of coarser localization;
- SSD (2016): multi-scale predictions via feature maps of decreasing resolutions, anchors per cell;
- RetinaNet (2017): introduced the focal loss to correct the foreground/background imbalance (hundreds of thousands of easy anchors against a few objects), reconciling single-stage and two-stage accuracy.
Definition 1.4 — Focal loss For per-anchor binary classification with logit z, predicted probability p = \sigma(z) and label y \in \{0, 1\}: \mathrm{FL}(p) \;=\; -\alpha\,(1 - p_t)^{\gamma}\,\log(p_t), \qquad p_t = y\,p + (1 - y)(1 - p), with balancing factor \alpha \in [0,1] and focusing \gamma > 0 (typically \gamma = 2). When \gamma = 0 and \alpha = 1, one recovers the cross-entropy.
The effect of the factor (1 - p_t)^{\gamma} is to divide the contribution of easy examples: a background anchor classified at p_t = 0.9 has its loss reduced by a factor 0.1^2 = 0.01; the rare hard examples (small p_t) keep an almost intact gradient.
For a positive anchor (y = 1, so p_t = p and \partial p_t / \partial z = p_t(1 - p_t)), the gradient
Key result — focal-loss gradient \frac{\partial \mathrm{FL}}{\partial z} = -\alpha\,(1-p_t)^{\gamma}\big(1 - p_t - \gamma\, p_t \log p_t\big).
It reduces to the cross-entropy gradient -(1 - p_t) for \gamma = 0, \alpha = 1: the extra factor (1-p_t)^\gamma makes it vanish on well-classified anchors, so the magnitude concentrates on the hard ones.
| Criterion | Two-stage (Faster R-CNN + FPN) | Single-stage (YOLO/SSD/RetinaNet) |
|---|---|---|
| Principle | proposals then refined classification | dense prediction in one pass |
| Accuracy (COCO mAP) | historically the high reference | comparable since RetinaNet and recent YOLOs |
| Latency | higher (two passes + RoI) | low, suited to real time |
| Small objects | good (FPN, aligned RoIs) | sensitive to input resolution |
| Use cases | offline analysis, medical imaging | embedded, video, robotics |
1.3. Non-maximum suppression (NMS)
Dense detectors emit many redundant boxes around the same object. NMS, stated in Image Analysis and Computer Vision, Definition 9.2, keeps the highest-scoring box and removes the ones that overlap it too much; this section adds its vectorized code, its cost and its limits:
- sort the N detections by decreasing score;
- take the first box b, add it to the kept ones;
- remove every box b' such that \mathrm{IoU}(b, b') > \tau (typically \tau = 0.5);
- resume at step 2 with the remaining boxes, until exhaustion.
import numpy as np
def nms(boxes, scores, tau=0.5):
"""boxes: (N,4) [x1,y1,x2,y2]; scores: (N,); returns the kept indices."""
x1, y1, x2, y2 = boxes[:, 0], boxes[:, 1], boxes[:, 2], boxes[:, 3]
areas = np.maximum(0, x2 - x1) * np.maximum(0, y2 - y1)
order = scores.argsort()[::-1] # sort by decreasing score
keep = []
while order.size > 0:
i = order[0]
keep.append(i)
xx1 = np.maximum(x1[i], x1[order[1:]])
yy1 = np.maximum(y1[i], y1[order[1:]])
xx2 = np.minimum(x2[i], x2[order[1:]])
yy2 = np.minimum(y2[i], y2[order[1:]])
inter = np.maximum(0, xx2 - xx1) * np.maximum(0, yy2 - yy1)
iou = inter / (areas[i] + areas[order[1:]] - inter)
order = order[1:][iou <= tau] # remove the overlapping ones
return np.array(keep)Note — Limits of greedy NMS NMS is greedy: worst-case O(N^2), it can remove a true detection that overlaps a distinct object (two people touching, aligned train cars). Soft-NMS (Bodla et al., 2017) replaces the binary removal with a score decay s_i \mapsto s_i \cdot f(\mathrm{IoU}) — linear or Gaussian — giving overlapping boxes a second chance; per-class NMS must be applied class by class, except in “class-agnostic” variants. The set-prediction detectors of chapter 2 replace NMS with a global, differentiable matching.
2. Evaluation (mAP) and modern detectors
Two detectors can only be compared with a single number that accounts for misses, false alarms, localization quality and score ranking at once. This chapter recalls that number, the mAP, from the P1 vision course, works it by hand on a new list and adds what the COCO protocol specifies; it then reviews the detectors that improved it since 2017 — without anchors, without NMS, and the industrial YOLO line — and ends with the session-4 lab.
2.1. Precision, recall, AP and the COCO protocol
Recall — stated in Image Analysis and Computer Vision, Definition 9.4 and Example 9.5
Definition 2.1 — Precision, recall, AP and mAP (Image Analysis and Computer Vision, Definition 9.4, the reference statement). For a given class, a detection is a true positive (TP) if \mathrm{IoU}(\text{prediction}, \text{ground truth}) \geq \tau (and if that ground truth is not already matched); otherwise it is a false positive (FP); an undetected ground truth is a false negative (FN).
Then \text{precision} = \frac{TP}{TP + FP}, \qquad \text{recall} = \frac{TP}{TP + FN} = \frac{TP}{|\text{ground truths}|}.
The average precision (AP) is the area under the precision-recall curve obtained by sweeping the score threshold; the COCO mAP averages the APs over 80 classes and over 10 IoU thresholds \tau \in \{0.5,\, 0.55,\, \dots,\, 0.95\} — denoted \mathrm{mAP}@[0.5{:}0.95].
The example below repeats the P1 computation on a longer list, then the note gives what the COCO protocol adds.
Example 2.2 — AP of one class by hand One class (“cat”) with 3 ground truths and 5 detections sorted by decreasing score, evaluated at threshold \tau = 0.5:
| Rank | Score | Verdict | Cumulative TP | Precision | Recall |
|---|---|---|---|---|---|
| 1 | 0.95 | TP | 1 | 1/1 = 1.00 | 1/3 = 0.33 |
| 2 | 0.90 | FP | 1 | 1/2 = 0.50 | 0.33 |
| 3 | 0.85 | TP | 2 | 2/3 = 0.67 | 2/3 = 0.67 |
| 4 | 0.70 | FP | 2 | 2/4 = 0.50 | 0.67 |
| 5 | 0.40 | TP | 3 | 3/5 = 0.60 | 3/3 = 1.00 |
With “all-points” interpolation (precision clipped by the maximum to the right), the retained points are (0.33; 1.00), (0.67; 0.67) and (1.00; 0.60), hence \mathrm{AP} = \tfrac13 \times 1 + \tfrac13 \times \tfrac23 + \tfrac13 \times 0.6 \approx 0.756.
The AP rewards both the ranking of the scores (an FP at high score is costly) and completeness; this is why it is more informative than a simple accuracy at a fixed threshold.
Note — The COCO protocol: why multiple thresholds and sizes At \tau = 0.5, a detector can be right “loosely”: averaging over [0.5{:}0.95] penalizes mediocre localizations.
- Interpolation: COCO reads the precision envelope at 101 recall points 0, 0.01, \dots, 1 instead of all points; on Example 2.2 this gives 0.756 as well (0.7564 against 0.7556).
- Sizes: COCO also publishes \mathrm{mAP}_S, \mathrm{mAP}_M, \mathrm{mAP}_L for objects of area below 32² pixels, between 32² and 96², and above 96² — a “globally” good industrial model can be very poor on small objects, a crucial point for video surveillance or microscopy.
- Budget: at most 100 detections per image are scored, and the average recall (AR) is reported for 1, 10 and 100 detections.
2.2. Without anchors: anchor-free detectors
Anchors impose an arbitrary grid of hypotheses. Anchor-free detectors directly predict, per pixel of the feature map: (i) a probability of being an object center (centerness / center heatmap, cf. FCOS and CenterNet) and (ii) regressions of the distances to the four edges.
The decoding becomes: b = (x_c - l, \; y_c - t, \; x_c + r, \; y_c + b'), where (x_c, y_c) is the position of the central pixel and l, t, r, b' the regressed distances — all of it without any reference box.
Benefits: fewer hyperparameters (scales/ratios), no anchor/object imbalance, better on atypical shapes; cost: an NMS is still needed, and the center-to-ground-truth assignment requires zone rules (assignment by feature zone).
2.3. Detection as set prediction: DETR
Definition 2.3 — DETR (DEtection TRansformer) DETR treats detection as a set prediction problem: a CNN extracts features, a transformer encoder-decoder (cf. Deep Learning, ch. 6) produces N object queries decoded into N (box, class) pairs; training matches predictions and ground truths, padded with “no object” up to N, by minimum-cost bipartite coupling (the Hungarian algorithm of Refresher in Computer Science, section 7.7): \hat\sigma = \arg\min_{\sigma \in \mathfrak{S}_N} \sum_{i=1}^{N} \Big( \mathcal{L}_{\mathrm{box}}(b_i, g_{\sigma(i)}) + \mathcal{L}_{\mathrm{cls}}(c_i, y_{\sigma(i)}) \Big), then applies a “set prediction”-type loss (Hungarian loss) on the optimal matching. Since the output is a learned set without redundancy, DETR removes NMS and anchors.
Note — Why DETR converges slowly, and the fix Global attention struggles to precisely localize small boxes (attention spreads over the whole image): DETR needed ~500 epochs. Deformable DETR replaces dense attention with deformable attention that samples only a small set of relevant points per query, speeding up convergence by an order of magnitude. The Hungarian matching is a minimum-cost assignment: the discrete optimal transport of Computational Optimal Transport, ch. 1 between two uniform measures on N points, whose optimal plans include a permutation (Birkhoff). DETR solves it exactly with the Hungarian algorithm rather than approximately with the Sinkhorn iterations of that module’s ch. 3.
2.4. The industrial YOLO ecosystem
| Version | Year | Key contribution | Typical use |
|---|---|---|---|
| YOLOv1 | 2016 | single-pass dense prediction, real time | proof of concept |
| YOLOv3 | 2018 | multi-scale predictions (FPN), anchors per scale | legacy surveillance |
| YOLOv5 | 2020 | tooling (ONNX/TF Lite export, S–X sizes), Ultralytics ecosystem | fast deployment |
| YOLOv8+ | 2023 | anchor-free heads, unified detection + segmentation + pose + tracking | current industrial standard |
The important point for the engineer: these versions are less scientific revolutions than training and tooling recipes (mosaic augmentation, dynamic assignment loss, multi-format export). Knowing how to read a detector’s changelog — which modules change, which data, which licenses (GPL, now AGPL-3.0, for the Ultralytics line, Apache-2.0 for others) — is part of the module’s skills.
2.5. Lab sheet: from the P1 detector to the COCO protocol (session 4)
About two hours, on a laptop CPU or a free GPU tier, in PyTorch and torchvision. It continues the detector lab of Image Analysis and Computer Vision, which fine-tuned a Faster R-CNN on Penn-Fudan and measured its AP@0.5 and mAP@[0.5:0.95], and it hands its detections to the tracking session (chapter 5).
- Models. Two torchvision detectors pretrained on COCO: the two-stage
fasterrcnn_resnet50_fpn(section 1.1) and the one-stageretinanet_resnet50_fpn(section 1.2) — or, for the class person, your fine-tuned detector of the P1 lab. - Data. 500 images of COCO val2017 that contain people, with their official annotations.
- COCO protocol. Run
COCOevalofpycocotoolson both models for the class person: AP, AP@0.5, AP@0.75 and the small, medium and large breakdown of the COCO note in section 2.1. Check that small people are the weak spot, and say why with Example 0.3. - Error analysis. Sort 50 errors by hand, or all of them with the TIDE toolbox (Bolya et al., ECCV 2020): localization errors (IoU between 0.1 and 0.5 with a ground truth), duplicates (section 1.3), background detections and missed people. TIDE also gives the AP that fixing each type would gain.
- Ablation. NMS threshold 0.5 against 0.7, score threshold 0.05 against 0.3: effect on the AP and on the number of boxes per image.
- Hand-off to tracking. Run the better model on the training sequence MOT17-04 and save its boxes in the MOTChallenge text format (frame, identity −1, left, top, width, height, score): session 7 tracks them with SORT.
- Report, one page: the two COCO tables, the error breakdown, and the latency per image of both models on your machine.
3. Segmentation: semantic, instance, panoptic, SAM
A box is a coarse answer when the application needs the exact outline of an object — a tumor, a road, a defect. Segmentation assigns a label to every pixel; this chapter distinguishes its three variants, the architectures and metrics of each, and the promptable foundation model SAM.
3.1. Three granularities
| Task | Output | Question answered | Examples |
|---|---|---|---|
| Semantic | class map H \times W | “what is the class of this pixel?” | U-Net, DeepLab |
| Instance | set of masks (m_i, c_i, s_i) | “which distinct objects?” | Mask R-CNN |
| Panoptic | map of segmented identifiers | “‘stuff’ pixels + ‘thing’ instances” | Panoptic FPN |
3.2. Semantic segmentation: from FCN to U-Net and DeepLab
- FCN (2015): fully convolutional classification — the fully-connected layers become 1×1 convolutions, and upsampling (transposed) layers restore the resolution; dense output, end-to-end training;
- U-Net (2015): symmetric encoder-decoder with skip connections that reinject the encoder’s high-resolution details into the decoder; designed for medical imaging with few annotated images, and still the domain’s reference;
- DeepLab (v1→v3+): dilated (atrous) convolutions: a 3 \times 3 kernel with dilation d sees a neighborhood of size 2d+1, enlarging the receptive field without losing resolution; the ASPP module (Atrous Spatial Pyramid Pooling) combines several dilations in parallel to capture several scales; v3+ adds a light decoder.
Example 3.1 — Dice and IoU of masks For a predicted binary mask p and a ground truth g (sets of pixels), the IoU is |p \cap g| / |p \cup g| and the Dice 2|p \cap g| / (|p| + |g|).
With |p| = 1200, |g| = 1000 and |p \cap g| = 900: \text{IoU} = 900/1300 \approx 0.69 \quad\text{and}\quad \text{Dice} = 1800/2200 \approx 0.82 .
One checks the identity \mathrm{Dice} = 2\,\mathrm{IoU} / (1 + \mathrm{IoU}): 2 \times 0.692 / 1.692 = 0.818 — the two metrics are interchangeable as a ranking, but Dice looks “kinder”: always specify the metric in a report.
3.3. Instance segmentation: Mask R-CNN
Mask R-CNN (2017) extends Faster R-CNN: in parallel with the classification and box-regression heads, each region of interest receives a segmentation head that predicts a 28 \times 28 binary mask (per class). The decisive detail is RoI Align: the original RoI pooling quantized the cell coordinates (rounding), shifting the features by a few tenths of a pixel — negligible for classification, disastrous for aligning a mask.
RoI Align samples by bilinear interpolation at the real coordinates, without rounding. The authors report about 3 mask AP points gained with a ResNet-50-C4 backbone (26.9 → 30.2) and about 7 points with coarser stride-32 features — a relative gain of 10 % to 50 %, larger under stricter IoU thresholds — from a mere numerical-precision fix: a fine engineering lesson.
3.4. Panoptic: a single metric
Definition 3.2 — Panoptic Quality (PQ) Predicted segments and ground truths are matched per class with \mathrm{IoU} > 0.5 (at-most-one-to-one coupling). With TP the set of matches, FP the unmatched predictions and FN the unmatched ground truths: \mathrm{PQ} \;=\; \underbrace{\frac{1}{|\mathrm{TP}|}\sum_{(p,g) \in \mathrm{TP}} \mathrm{IoU}(p, g)}_{\text{segmentation quality (SQ)}} \;\times\; \underbrace{\frac{|\mathrm{TP}|}{|\mathrm{TP}| + \tfrac12|\mathrm{FP}| + \tfrac12|\mathrm{FN}|}}_{\text{recognition quality (RQ = F1 score)}}, then averaged over the classes. PQ cleanly decouples “are the boundaries right?” (SQ) and “did I find the right objects?” (RQ).
3.5. SAM: promptable segmentation
The Segment Anything Model (Meta, 2023) changes paradigm: instead of training a model per task, SAM learns a general task — produce a valid mask for any prompt (point, box, coarse mask, text to come):
- architecture: a heavy image encoder (a vision transformer, Deep Learning, section 6.6; in depth in Advanced Deep Learning, ch. 4) computed once per image; a light prompt encoder; a light mask decoder, re-runnable in real time (~50 ms) for every prompt — the expensive-once / light-many-times separation is the “interactive” deployment pattern;
- data engine: an assisted-annotation loop (model suggests, human corrects) at first, then semi-automatic then automatic annotation — culminating in SA-1B: 11 million licensed images, 1.1 billion masks, 99 % automatic;
- usage: zero-shot mask extraction, serving as a base for fine-tuning (medical, satellite), or as an annotation assistant — SAM closes the loop there: the model manufactures its own data.
Example 3.3 — Prompting SAM: one click, three masks An inspector clicks once on a scratch of a metal casing. A single point is ambiguous — the scratch, the panel that carries it, or the whole casing — so SAM returns three nested masks (subpart, part, whole), each with a predicted IoU score; the interface shows the best-scored one and lets the user switch.
- Disambiguation: a second, negative click (label 0) on the panel, or a box drawn around the scratch, removes the ambiguity, and a single mask is then requested.
- Detector boxes as prompts: the boxes of a detector (chapter 1) can serve as box prompts, which gives instance masks without training a mask head.
- Cost: for 50 images with 4 prompts each, the encoder runs 50 times and the decoder 200 times. At about 0.15 s per encoding (largest encoder, ViT-H, on an A100 GPU, as reported by the authors) and 50 ms per decoding on a CPU, the machine time is 7.5 s + 10 s — small next to the human time spent correcting masks.
import numpy as np
from segment_anything import sam_model_registry, SamPredictor
sam = sam_model_registry["vit_b"](checkpoint="sam_vit_b_01ec64.pth")
predictor = SamPredictor(sam)
predictor.set_image(image) # H x W x 3 RGB uint8: heavy encoder, once
masks, scores, _ = predictor.predict(
point_coords=np.array([[420, 310]]), # one click (x, y)
point_labels=np.array([1]), # 1 = foreground, 0 = background
multimask_output=True) # three nested candidates
best = masks[np.argmax(scores)] # highest predicted IoU
masks, scores, _ = predictor.predict( # a box removes the ambiguity
box=np.array([380, 280, 470, 340]), multimask_output=False)4. Data, benchmarks and annotation
The quality of a deployed vision system is bounded by its data long before its architecture. This chapter reviews the reference datasets, what annotation costs and how to reduce that cost, and the three evaluation pitfalls that make a model look better than it is.
4.1. The reference datasets
| Dataset | Year | Content | Annotations | Use |
|---|---|---|---|---|
| ImageNet | 2009– | 14M images, 22k classes | labels | pretraining (DL reminder ch. 7) |
| COCO | 2014– | 330k images, 80 classes | boxes, masks, captions | detection, segmentation, standard mAP |
| KITTI | 2012 | urban scenes (camera + LiDAR) | 3D boxes, disparity | stereo, embedded 3D detection |
| nuScenes | 2019 | 1000 scenes, 1.4M images, 6 cameras + 1 LiDAR + radars | 3D boxes, tracks | complete autonomous driving |
| Waymo Open | 2019– | ~2000 scenes, 5 LiDAR + 5 cameras | 3D boxes, tracking | large-scale 3D benchmark |
| MVTec AD | 2019 | 5k industrial images, 15 categories | anomaly masks | inspection (chapter 7) |
4.2. The cost of annotation
A COCO box costs from a few seconds to a minute; a polygon mask, much more; a 3D LiDAR box at 25 Hz over 20 objects, several minutes with dedicated tooling. Three industrial levers:
- assisted annotation: a pretrained model proposes, the human corrects — the SA-1B loop of chapter 3 is its large-scale version; a complementary lever is active learning, which sends to annotation only the examples on which the model is uncertain;
- synthetic data: procedural 3D rendering with domain randomization (random textures, lighting to force invariance); the P2 elective Image Synthesis: Theory and Practice (one of the Choose-1 options) covers rendering; sim2real remains the hard part;
- augmentation: geometric (cropping, rotation, mosaic) and photometric (color, blur, noise); caution: geometric transformations must transform the boxes/masks and the metadata (rotation → bounding boxes of the rotated masks).
4.3. Evaluation pitfalls
Note — The three classic pitfalls
- Data leakage: near-duplicate images between train and test (video sequences); always split by video/scene, not by image.
- Long-tail imbalance: the global mAP masks rare classes — look at the per-class APs; the training data must be resampled or reweighted (cf. focal loss, chapter 1).
- Domain shift: a COCO model collapses on your production cameras (angle, compression, weather); plan from the protocol stage for a “shadow” set of unseen real data, and drift monitoring in operation (chapter 8).
5. Multi-object tracking
A detector run frame by frame does not know that the pedestrian of frame 12 is the one of frame 11. Tracking adds this identity across time; this chapter presents the association methods that dominate in practice and the metrics that evaluate them.
Definition 5.1 — Multi-object tracking (MOT) Given a video stream, associate across frames the detections of the same physical object under a stable track identifier, while managing appearances, disappearances, occlusions and crossings. The dominant paradigm is tracking-by-detection: a detector (chapters 1–2) runs at every frame; the tracker reduces to the association problem between current detections and existing tracks.
5.1. SORT: Kalman + Hungarian matching
SORT (2016) is the minimal tracker:
- each track carries a constant-velocity Kalman filter with state [u, v, s, r, \dot u, \dot v, \dot s]: box center (u, v), area s and aspect ratio r, the ratio being assumed constant; the detection observes [u, v, s, r], and the Kalman filter is recalled below;
- prediction: the boxes are extrapolated to the current frame;
- association: solve the bipartite coupling between predictions and detections with cost 1 - \mathrm{IoU} (the Hungarian algorithm of Refresher in Computer Science, section 7.7); pairs with an IoU below a minimum are rejected;
- the formed pairs update the filters (correction); tracks left unmatched for T_{\text{max}} consecutive frames are destroyed; orphan detections create new tracks.
Reminder — the Kalman filter in two steps
Linear-Gaussian state model x_t = F x_{t-1} + w, observation model z_t = H x_t + v, white noises with covariances Q, R. Here H is the observation matrix and R the measurement-noise covariance, not the image height or the rotation of chapter 6: \hat x_{t|t-1} = F \hat x_{t-1|t-1}, \quad P_{t|t-1} = F P_{t-1|t-1} F^\top + Q \quad (\text{prediction}), K_t = P_{t|t-1} H^\top (H P_{t|t-1} H^\top + R)^{-1}, \quad \hat x_{t|t} = \hat x_{t|t-1} + K_t (z_t - H \hat x_{t|t-1}), P_{t|t} = (I - K_t H) P_{t|t-1} \quad (\text{correction}).
The gain K_t weighs the prediction (motion) and the observation (detection) according to their uncertainties. Both steps are proved as recursive Gaussian conditioning in Signal Processing, theorem 7.7, with the same letters.
5.2. DeepSORT: adding appearance
In a crowd, two pedestrians who cross paths swap their boxes: IoU alone re-associates poorly. DeepSORT (2017) associates in two stages:
- matching cascade, which gives priority to the tracks seen most recently. The cost combines the Mahalanobis distance between a detection and the Kalman prediction of the track, measured in the covariance of that prediction, and the cosine distance between appearance embeddings — a small ReID (re-identification) network learns a descriptor e_i \in \mathbb{R}^{128} invariant to pose/scale. Both distances also act as gates: a pair beyond either threshold is forbidden;
- IoU matching (as in SORT) on what is left: the unconfirmed tracks and those lost for a single frame.
The “appearance memory” (a gallery of the last descriptors per track) resists long occlusions.
5.3. ByteTrack: don’t throw away low-score detections
ByteTrack (2022) starts from a simple observation: during a partial occlusion, the detector often emits a correct but low-confidence detection — which classical pipelines discard at the threshold. The algorithm sketch:
- split the detections into high score (\geq \tau_{\mathrm{high}}, e.g. 0.5) and low score (\tau_{\mathrm{low}} \leq s < \tau_{\mathrm{high}});
- first matching: active tracks vs high-score detections, Hungarian coupling on the IoU distance — or on an appearance distance when a ReID model is added;
- second matching: tracks still orphaned vs low-score detections, coupling on IoU alone — the low-confidence boxes “carry” the track through the occlusion;
- tracks still orphaned are put on hold then destroyed; orphan high-score detections create tracks (never the low-score ones).
Result: notable MOTA/IDF1 gains without any new detector — association is a lever as profitable as perception.
5.4. Measuring a tracker
Definition 5.2 — MOTA and IDF1 \mathrm{MOTA} = 1 - \frac{|\mathrm{FN}| + |\mathrm{FP}| + |\mathrm{ID\ switches}|} {\sum_t |\text{ground truths}_t|}, \qquad \mathrm{IDF1} = \frac{2\,\mathrm{IDTP}}{2\,\mathrm{IDTP} + \mathrm{IDFP} + \mathrm{IDFN}}, where ID switches count identity flips (a tracker that “swaps” two people loses IDF1 even if its MOTA is good).
MOTA mostly measures detection; IDF1 mostly measures identity; HOTA (2020) rebalances detection and association. Ex. 12 computes both on two trackers that rank differently.
Note — In production Tracking imposes strong system constraints: per-frame latency (the tracker must fit in the budget, cf. chapter 8); robustness to detector dropouts (a missed frame); re-identification after leaving the field of view; and, in multi-camera settings, cross-camera association (pure ReID, with no IoU available). The two key building blocks — Hungarian coupling and the Kalman filter — are classics, taught in the Refresher in Computer Science (section 7.7) and in Signal Processing (theorem 7.7); the modernity lies in the learned descriptors.
6. Applied 3D vision: stereo and LiDAR
A robot or a vehicle needs to know how far objects are, which a single image does not tell. This chapter shows how depth is recovered from two cameras (stereo) or measured directly (LiDAR), how networks process the resulting point clouds, and how sensors are fused.
6.1. The pinhole model (reminder)
L3 reminder — perspective projection
A pinhole camera projects a 3D point X = (X, Y, Z), given in a world frame, to (u, v) in the image: \lambda \begin{pmatrix} u \\ v \\ 1 \end{pmatrix} = K \,[\,R \mid t\,] \begin{pmatrix} X \\ Y \\ Z \\ 1 \end{pmatrix}, \qquad K = \begin{pmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix}, with K the intrinsics (focal lengths in pixels, optical center) and [R \mid t] the extrinsics, the rigid motion from the world frame to the camera frame, whose z axis points forward.
The scale \lambda is the depth of the point in the camera frame, the third coordinate of RX + t; it equals Z only when the world frame is the camera frame (R = I, t = 0), the setting of the stereo section below.
Calibration (OpenCV) estimates K and the distortion (radial-tangential model) — cf. Image Analysis and Computer Vision, ch. 1 and 5 for the complete geometry (Hartley & Zisserman).
6.2. Stereo: disparity as a depth measurement
Definition 6.1 — Disparity For a rectified stereo pair (coplanar images, horizontal epipolar lines, common focal length f, baseline B), a 3D point projects to (u_L, v) on the left and (u_R, v) on the right; the disparity is d = u_L - u_R \geq 0, measured in pixels.
Recall — proved in Image Analysis and Computer Vision, Theorem 6.3 and Example 6.4
Proposition 6.2 — Depth from disparity (Image Analysis and Computer Vision, Theorem 6.3, the reference statement). In the rectified setting, the depth of the point is Z = \frac{f \, B}{d}.
Proof idea: the point projects to u_L = fX/Z on the left and to u_R = f(X - B)/Z on the right, whose difference fB/Z no longer depends on X. Differentiating Z = fB/d gives the error law of Example 6.4 there.
Key result — stereo depth error (recalled) \frac{\partial Z}{\partial d} = -\frac{fB}{d^2} = -\frac{Z^2}{fB}
The depth uncertainty grows quadratically with distance — stereo is precise up close, coarse far away; increasing B or f improves range at the price of the visible field and harder matchings.
Example 6.3 — Stereo or LiDAR at 40 m? A KITTI-like rig has f = 721 px and B = 0.54 m, so fB \approx 389 px·m, and matching is accurate to ±0.25 px.
- At 10 m the depth error is about 100 \times 0.25 / 389 \approx 0.06 m; at 40 m it is about 1600 \times 0.25 / 389 \approx 1.03 m.
- A LiDAR measures range to about ±2 cm at any distance its returns reach. Stereo matches that precision only while Z^2 \times 0.25 / 389 \leq 0.02, that is below Z = \sqrt{0.02 \times 389 / 0.25} \approx 5.6\ \text{m}.
Cameras bring the semantics and the near range, LiDAR the geometry at range: this is why section 6.4 fuses them.
The classical stereo pipeline:
- rectification;
- cost volume — for every left pixel and every candidate disparity d, a matching cost (census, SSD of descriptors) — this is an H \times W \times D_{\max} volume;
- aggregation and regularization: SGM (Hirschmüller, 2008) aggregates costs along several directions (per-path dynamic programming) with discontinuity penalties — the industrial standard (baked into GPUs!);
- disparity map.
Deep methods (PSM-Net, Chang and Chen 2018, and successors) learn the cost volume: the learned descriptors of the left image and of the shifted right image are stacked for every candidate disparity into a 4D volume (height, width, disparity, features), regularized by 3D convolutions; a soft argmin over the disparities then gives a sub-pixel estimate.
6.3. LiDAR: point clouds
LiDAR emits pulses and measures time of flight: the output is a 3D point cloud (x, y, z, reflectivity), ~100k–2M points/s, accurate in distance (~2 cm), sparse and irregular — unstructured: grid convolutions do not apply directly. Families of methods:
- PointNet (2017): per point, a shared MLP; aggregation by global max; then an MLP. Permutation invariance comes from the max: the global descriptor does not depend on the order of the points — cf. the proposition below;
- Voxels / pillars: discretize space (VoxelNet) or only the ground plane (PointPillars: vertical columns), aggregate the point features there, then run a 2D/3D CNN on the resulting grid;
- Center detection: CenterPoint projects everything into bird’s eye view (BEV) and detects objects by their center (heatmap + size/rotation regression) — the anchor-free formulation of chapter 2, transposed to a 2D “top-down view”.
Proposition 6.4 — The global max is permutation invariant Let h(X) = \mathrm{max}_{i=1..n} \mathrm{MLP}(x_i) be PointNet’s global descriptor. For every permutation \pi of \{1, \dots, n\}: h(x_{\pi(1)}, \dots, x_{\pi(n)}) = h(x_1, \dots, x_n).
Proof. The MLP is applied pointwise: the set \{\mathrm{MLP}(x_i)\} is unchanged by permutation (only the enumeration order changes). The per-coordinate maximum of a set does not depend on the enumeration order, hence the equality. Note that a sum or an average would have the same property; the max is preferred because it selects one “witness” per coordinate and avoids the information smoothing of averages. ∎
6.4. Multi-sensor fusion in bird’s eye view
Cameras provide semantics (classes, traffic lights, signs) but only indirect depth; LiDAR provides geometry but poor semantics. Modern architectures fuse in BEV: every sensor is brought into a common top-down frame where detection, tracking and trajectory prediction combine.
BEVFormer (2022): image features are “queried” in BEV space by spatial cross-attention (every BEV cell queries the pixels along its view pillar), with temporal attention toward the previous BEV map — tracking becomes implicit. The following table summarizes the sensor trade-offs:
| Sensor | Output | Density | Weather/light | Cost | Role |
|---|---|---|---|---|---|
| Camera | dense RGB | high | sensitive | low | semantics |
| LiDAR | 3D cloud | medium, sparse | robust | high | geometry |
| Radar (4D) | targets + velocity | low | very robust | medium | motion, bad weather |
7. Industrial case studies
The previous chapters provide building blocks; a product combines them under constraints of cost, cadence and regulation. This chapter walks through four application domains and, for each, the constraint that changes the engineering choices.
7.1. Industrial inspection (quality control)
Inspecting parts (scratches, cracks, contamination) on a production line: controlled lighting (strobe, dark background), imposed cadence (decisions per second), and — the major specificity — very few defect examples.
Hence the move to unsupervised methods: learn normality (autoencoders, feature distances; cf. Deep Learning, ch. 9 for autoencoders) and raise an alert on deviation; the MVTec AD dataset is the reference benchmark (15 categories: screws, textiles, wood, bottles…, with pixel-level defect masks).
Metrics: image-level detection (AUROC) and defect segmentation (pixel AUROC, PRO). Constraints: an error is asymmetrically costly (false rejection = yield loss; missed defect = product recall); the threshold is tuned on business cost, not on 0.5.
Example 7.1 — Tuning a threshold on costs Let an anomaly score s \in [0,1]; false rejection costs €1 (manual re-inspection), missed defect costs €100 (product recall). At the operating point (FP rate = 4\,\% on healthy parts, FN rate = 2\,\% on defective parts, real defect rate 0.5 %): expected cost for 10,000 parts 10\,000 \times \big[0.995 \times 0.04 \times 1 + 0.005 \times 0.02 \times 100\big] = 10\,000 \times (0.0398 + 0.01) \approx 498\ \text{euros}.
Lowering the threshold (more sensitive) increases FPs but reduces FNs: redo the computation and choose the threshold at the cost minimum — the right engineering metric is a cost, not an accuracy.
7.2. Autonomous driving
The typical perception pipeline of a SAE level 2+ to 4 vehicle:
- multi-camera detection/segmentation (chapters 1–3);
- camera/LiDAR/radar fusion in BEV (chapter 6);
- tracking and prediction of agents (chapter 5 + trajectory models);
- planning (out of scope — cf. Reinforcement Learning, ch. 1 for the MDP formalization);
- system monitoring: redundancy, diagnostics, degraded mode.
Engineering lessons: corner cases dominate the cost (roadworks, flashing lights, overturned trailers); closed benchmarks (nuScenes) are saturated and correlate poorly with real kilometers; safety imposes latency guarantees (chapter 8) and traceability (version of the model, the dataset, the threshold).
7.3. Medical imaging
Organ/lesion segmentation (U-Net is still the backbone, chapter 3), cell counting, fracture detection. Specificities: rare and costly data (clinicians), DICOM formats (metadata, windowing), strict clinical validation, regulation (medical CE marking); the metric is per-structure Dice and inter-observer consistency is the reachable ceiling — a Dice above human agreement is suspicious; the models are assistance tools (CAD — computer-aided diagnosis), not decision makers.
7.4. Other domains (summary)
- retail: planograms (products on shelves), customer flows (anonymous counting);
- agriculture: weed detection for targeted spraying (drone, embedded);
- sports: player/ball tracking (chapter 5 at scale), tactical statistics;
- satellite: building/road detection, deforestation masks — with domain randomization and multispectral imaging as a bonus.
8. Deployment: ONNX, quantization, edge
A model trained on a workstation GPU must run within a few milliseconds on an embedded board with little memory. This chapter covers the steps that get it there — export, quantization, compression — and how to check a latency budget.
8.1. The deployment pipeline
From notebook to product, the canonical steps:
- export: the trained model (PyTorch) is exported as a frozen graph — ONNX (Open Neural Network Exchange), a common format accepted by most runtimes;
- graph optimization: operator fusion (conv + batchnorm → single conv; conv + activation), dead-layer elimination, kernel selection;
- targeted compilation: TensorRT (NVIDIA), Core ML (Apple), TF Lite / LiteRT (mobile), OpenVINO (Intel) — these generate hardware-specialized engines;
- calibration/quantization: move to INT8 (below);
- measurement: P50/P99 latency, throughput, memory, energy — on the target hardware, never on the development workstation alone.
import torch
model = DetectorWrapper() # PyTorch, eval mode
model.eval()
dummy = torch.randn(1, 3, 640, 640)
torch.onnx.export(
model, dummy, "detector.onnx",
input_names=["image"], output_names=["boxes", "scores", "labels"],
dynamic_axes={"image": {0: "batch"}, # variable batch
"boxes": {0: "batch", 1: "num_boxes"}}, # variable N
opset_version=17) # recent opset for special ops
# runtime side: onnxruntime (CPU/GPU), TensorRT, Core ML...
import onnxruntime as ort
sess = ort.InferenceSession("detector.onnx", providers=["CPUExecutionProvider"])
boxes, scores, labels = sess.run(None, {"image": dummy.numpy()})8.2. INT8 quantization
Definition 8.1 — Affine quantization scheme To a floating tensor x we associate a signed 8-bit integer via Q(x) = \mathrm{clip}\!\left(\mathrm{round}\!\left(\frac{x}{s}\right) + z,\; -128,\; 127\right), \qquad x \approx s\,(Q(x) - z), with the scale s > 0 and the zero point z chosen by calibration (min-max of the activations on a representative sample, or percentile to limit the effect of extreme values). The weights are quantized once and for all; the activations are quantized at runtime.
Note — PTQ vs QAT
- Post-training quantization (PTQ): fast, no retraining, sufficient for many CNNs.
- Quantization-aware training (QAT, Jacob et al. 2018): during training the quantization is simulated with fake operations. The forward pass rounds; on the backward pass the derivative of the rounding, zero almost everywhere, is replaced by 1 (the straight-through estimator), so the gradients are full-precision approximations, not exact ones. The model learns to be robust to rounding; this is the solution when PTQ degrades too much (sensitive architectures, small models).
Typical benefit: memory ÷4 (FP32→INT8) and throughput ×2–4 on targets with INT8 kernels — at the price of a few tenths of a mAP point to monitor.
8.3. Compressing: pruning and distillation
- pruning: zero out the lowest-magnitude weights (unstructured pruning — no gain without a sparse library) or whole channels (structured — actually accelerates); follow the accuracy/size curve;
- knowledge distillation (Hinton et al., 2015): a small student imitates the output distribution of a large teacher — the loss combines the ground truth and the KL divergence with the teacher’s logits “softened” by a temperature T, with \lambda \in [0, 1] the weight of the teacher term: \mathcal{L}_{\mathrm{KD}} = (1 - \lambda)\, \mathrm{CE}(y, z_s) + \lambda\, T^2\, \mathrm{KL}\!\big(\mathrm{softmax}(z_t / T)\,\|\,\mathrm{softmax}(z_s / T)\big) — the convention of the site’s notation page, covered in detail in Advanced Deep Learning, Definition 3.2.
8.4. Latency budgets and profiling
Example 8.2 — Budget of a “real-time detection” application 30 fps camera → 33.3 ms per-frame budget.
Typical breakdown on an embedded module (Jetson Orin class): acquisition + decoding 3 ms; preprocessing (resizing, normalization, NV12→RGB) 4 ms; INT8 inference 18 ms; post-processing (NMS + rendering) 3 ms; margin 5 ms.
Three lessons:
- pre/post-processing is not negligible — keep it on the GPU (DALI/TensorRT-PLUGIN pipeline) if possible;
- target P99 latency (worst frame, with numerous detection batches), not the average;
- if the budget bursts, the levers in industrial order: input resolution ↓, smaller model (distillation), INT8, skip-frame + interpolation (detection at 15 Hz, tracking at 30 Hz — chapter 5 exists precisely for that).
8.5. Operations, drift and privacy
- monitoring: log score distributions, detection rates, “world” alerts (dirty camera, night); detect domain drift and plan retraining (the data loop of chapter 4);
- privacy: process on-device as much as possible (no image leaves the sensor); if a stream is sent: blurring/anonymization of faces and plates (…detected by… the models of chapter 3!), minimal retention;
- versioning: model + code + data + thresholds = a reproducible artifact — the methodology of Advanced Deep Learning, ch. 1 applies mutatis mutandis.
9. Ethics, robustness and limits
A deployed vision system can be fooled on purpose, can work worse for some groups of people, and can be used for surveillance. This chapter reviews these three risks and the limits that no current model overcomes.
9.1. Adversarial examples
Small imperceptible perturbations change the prediction. The simplest attack — FGSM — moves the input one step in the direction of the loss gradient: x_{\mathrm{adv}} = x + \varepsilon\, \mathrm{sign}\!\left(\nabla_x \mathcal{L}(\theta, x, y)\right), with \varepsilon on the order of 2–8/255.
Physical attacks exist too: stickers on a stop sign make a classifier read a speed limit (Eykholt et al., 2018), and a printed patch held by a person hides that person from a detector (Thys et al., 2019). Defenses range from adversarial training (min-max over perturbations) to bound-based certification.
FGSM, PGD and adversarial training are treated in Advanced Deep Learning, section 4.5 and in Deep Learning (P2 variant), section 7.1, certification and attacks on deployed systems in Security and Robustness (M2). The engineer mainly remembers: a model embedded in a product can be targeted, and robustness is tested (attack toolboxes) before deployment.
9.2. Bias and fairness of vision systems
- representation bias: mostly North American/European datasets → performance drops in other contexts (streets, clothing, objects). The “Gender Shades” audit (Buolamwini and Gebru, 2018) found that commercial gender-classification systems misclassified darker-skinned women far more often than lighter-skinned men (error rates up to about 35 %, against under 1 %). In practice: break the evaluation down by subgroup, as in Machine Learning, section 4.8 and Example 9.1 below;
- surveillance and biometrics: mass facial recognition is restricted/banned in several jurisdictions; the European AI regulation (AI Act, 2024) classifies remote biometric identification among high-risk or prohibited uses; anonymize before storage;
- consent: scraped data (LAION etc.) and image rights; prefer clearly licensed datasets and document provenance (data cards).
Example 9.1 — Per-subgroup recall of a pedestrian detector A test set holds 2,000 annotated pedestrians: 1,600 by day, of which 1,520 are detected at the operating threshold, and 400 by night, of which 280 are detected.
- Aggregate: the recall is 1,800 / 2,000 = 0.90.
- Per group: 0.95 by day and 0.70 by night; the night miss rate (30 %) is six times the day one (5 %).
- Noise or gap? A 95 % interval for a recall \hat r measured on n pedestrians is \hat r \pm 1.96\sqrt{\hat r(1 - \hat r)/n}, that is 0.95 ± 0.011 by day and 0.70 ± 0.045 by night: the 25-point gap is far beyond the noise.
- Mix: if half of the operating hours are at night, the recall seen in service is 0.5 × 0.95 + 0.5 × 0.70 = 0.825, not 0.90.
The same table with groups defined by a sensitive attribute (apparent skin tone, age) is the equal-opportunity check of the Machine Learning module: equal true-positive rates across groups.
9.3. Fundamental limits to know
Note — What models do not “understand”
- Compositionality: a detector can see “a person” and “a bicycle” without inferring “a person on a bicycle”. Relations require other formalisms, such as a scene graph whose nodes are the detected objects and whose edges are their relations: Image Analysis and Computer Vision, ch. 9 builds one from detections, and the Year 1 project Y1.5 reasons on it.
- Multimodal hallucination: captioners and vision-language models describe objects that are absent from the image; the language side of hallucination is treated in Large Language Models, section 9.3.
- Out of distribution: snow, night, a new sensor — the displayed confidence is not calibrated outside the training distribution.
- Causality: vision correlates, it does not explain — a decision system must separate perception from decision (autonomous driving, chapter 7).
Exercises
- ★ IoU and thresholds. Compute the IoU between g = (10, 10, 40, 60) and p = (20, 5, 55, 50); determine the maximum offset \delta in x of a prediction identical to g to stay above \tau = 0.75.
- ★ NMS by hand. Five detections of the same class, scores 0.9; 0.85; 0.8; 0.75; 0.7, box 2 overlapping box 1 (IoU 0.6), box 3 overlapping box 1 (IoU 0.3) and box 5 overlapping box 3 (IoU 0.8). Give the boxes kept at \tau = 0.5 then at \tau = 0.7 with linear Soft-NMS (s \leftarrow s(1 - \mathrm{IoU})); comment on the “two objects stuck together” case.
- ★ AP. With 4 ground truths and the sorted detections (TP, TP, FP, FP, TP, TP): draw the precision-recall curve, compute the all-points interpolated AP, then verify that moving the two FPs to the head of the list (FP, FP, TP, …) makes AP drop — why does the order of the scores matter?
- ★ Focal loss. Show that for \gamma = 2, an easy anchor (p_t = 0.95) receives a modulating weight (1-p_t)^\gamma that is 196 times smaller than that of a hard anchor (p_t = 0.3); compute the ratio for plain cross-entropy and conclude.
- ★ Hungarian coupling. Three tracks T_1, T_2, T_3, three detections D_1, D_2, D_3, costs 1-\mathrm{IoU}: T_1\!: (0.1,\ 0.8,\ 0.9), T_2\!: (0.9,\ 0.2,\ 0.7), T_3\!: (0.8,\ 0.9,\ 0.3). Solve the minimum-cost assignment by hand and compare with the greedy assignment — in which case do they differ?
- ★ Stereo depth. Camera f = 700 px, baseline B = 0.5 m; compute the disparity of an object at 10 m, then the depth uncertainty if disparity is measured to ±0.25 px; at what distance does the uncertainty exceed 1 m?
- ★ PQ. One image: 4 ground-truth segments, 3 predicted with matched IoUs 0.9; 0.8; 0.6 plus one FP; one FN. Compute SQ, RQ then PQ; redo with IoU 0.7 everywhere and comment on the decomposition.
- ★ Quantization. A weight tensor has min −0.82 and max 0.55; give the scale and zero point (asymmetric 8-bit min-max scheme), quantize −0.1 and 0.3, dequantize, compute the relative error — why can a 99.9th percentile help?
- ★★ PointNet. Replace the max by an average in proposition 6.4: does the invariance hold? Build two clouds with the same average but very different contents and conclude on the “selectivity” of the max.
- ★★ Real-time budget. An application must detect at 25 fps on hardware where FP32 inference takes 58 ms and INT8 21 ms; preprocessing 5 ms, post-processing 4 ms. Does a single inference per frame fit? Propose two strategies (skip-frame + tracking; resolution reduction ÷1.4 with cost in s^2) and quantify their trade-offs.
- ★★ Data choice. For a vehicle-counting system on a European road (day/night, rain), propose: a starting training set, a splitting protocol, an augmentation plan, a subgroup evaluation method, and two monitoring metrics in production.
- ★★ MOTA versus IDF1. Two pedestrians A and B are visible in all 6 frames of a clip, so there are 12 ground-truth boxes. Compute MOTA and IDF1 (Definition 5.2) for two trackers, then say which one you would deploy to count the people entering a shop, and why.
- Tracker 1 detects every box but swaps the two identities when the pedestrians cross at frame 4: its track 1 follows A then B, its track 2 follows B then A.
- Tracker 2 follows A with one track throughout, follows B with track 2 on frames 1–3, misses B on frames 4–5 (occlusion) and restarts it as a new track 3 on frame 6.
- ★★★ Project. Complete pipeline on a free set (a COCO subset or public drone images): fine-tuning of a modern YOLO, ONNX export, INT8 quantization, latency/mAP measurement before/after, then a one-page report in “industrial datasheet” format (error costs included, cf. example 7.1).
Projects and assessment
No official assessment is published for this module: it has no SynapseS sheet of its own, and the MSc&T brochure that announces it states no modality (fiche: “not displayed”). The subjects below are proposals of these notes, not official rules. If the module opens with a project-based assessment, Ex. 13 or one solo or group subject stands for the project; the written exam is only a proposal, for instance for a resit.
The projects exercise mainly O7 (end-to-end pipelines measured on the target hardware and reported as a datasheet), O8 (robustness, subgroup and provenance audits) and O6 (the perception side of multimodal systems), with O4 in the tracking-graph subject and O1 in training and quantization. Their detection and segmentation work can serve as the perception front end of the end-of-year project Y1.5 (scene-graph question answering), and their deployment measurements (ONNX, INT8, latency percentiles) carry over to the latency budget of Y2.3.
Solo projects
- [Solo · ≈ 20 h] Edge detector datasheet under domain shift. How much accuracy does INT8 cost on night and rain images, and when is quantization-aware training worth it? The subject extends Ex. 13.
- Work: fine-tune a small detector (YOLOv8n, or torchvision’s SSDlite320-MobileNetV3) on three classes; export it to ONNX; compare post-training static quantization in ONNX Runtime with quantization-aware training (Definition 8.1, Note PTQ vs QAT); set the decision threshold on costs as in Example 7.1.
- Data: COCO 2017 for pretraining; the BDD100K driving dataset (Yu et al., CVPR 2020; free registration), whose images are tagged by time of day and weather, with day images for fine-tuning and night and rainy images as the shifted test splits.
- Success criterion: mAP@[0.5:0.95] with its small, medium and large breakdown for FP32, PTQ and QAT on each split, and P50/P99 latency on a laptop CPU or a Jetson measured as in Example 8.2; the INT8 loss and the night gap explained with chapters 2 and 4.
- Deliverables: code, a one-page industrial datasheet plus a 4-page report, a 10-minute talk; chapters 1, 2, 4, 7 and 8. The export, versioning and monitoring steps lead to ML Ops and LLM Engineering Principles (M2).
- [Solo · ≈ 20 h] Paper study: stereo depth against LiDAR and the quadratic error law (Hirschmüller, TPAMI 2008; Chang and Chen, CVPR 2018). Does the depth error of semi-global matching and of PSM-Net grow like Z^2/(fB), as the key result of chapter 6 predicts, and which disparity error does each method imply?
- Work: disparities from OpenCV’s semi-global matcher (
StereoSGBM) and from the authors’ PSM-Net weights — the KITTI 2015 ones, fine-tuned on these training pairs and therefore optimistic here, and the Scene Flow ones as the cross-domain contrast; depth by Z = fB/d with the calibration files; median depth error per 5 m distance bin; a straight-line fit of the log error against the log distance. - Data: the 200 training pairs of KITTI Stereo 2015 (Menze and Geiger, CVPR 2015), whose ground-truth disparities come from accumulated LiDAR scans, with 3D models fitted to the moving cars; as a stretch, point crops of the KITTI 3D object benchmark to test the max-versus-mean claim of Ex. 9 with a small PointNet.
- Success criterion: the fitted slope with a confidence interval, compared with 2; the implied disparity error of each method; their D1-all error rates (disparity wrong by more than 3 px and 5 %), with PSM-Net’s set beside the 2.32 % its paper reports on the KITTI 2015 test set — SGM’s 2008 paper predates KITTI.
- Deliverables: code, a 4–6 page report, a 10-minute talk; chapter 6, with Example 6.3 as the starting point.
- Work: disparities from OpenCV’s semi-global matcher (
Group projects
- [Group of 3 · ≈ 30 h each] From tracks to interaction graphs. Does a better association (a higher IDF1) give better short-term trajectory forecasts when the tracks feed a graph network? The subject links the Kalman–Hungarian pipeline of chapter 5 to the message passing of Graph Machine and Deep Learning, ch. 5.
- Work: SORT written from section 5.1, against the public DeepSORT and ByteTrack code, all fed with the same detections; per frame, a graph whose nodes are the tracked people (Kalman position and velocity) and whose edges join people closer than a radius; a message-passing GNN that predicts the next 12 positions from the last 8, against the constant-velocity Kalman forecast.
- Data: the MOT17 training sequences (Milan et al., “MOT16: A Benchmark for Multi-Object Tracking”, 2016) with their public detections; the ETH and UCY pedestrian sequences (Pellegrini et al., ICCV 2009; Lerner et al., Eurographics 2007) for forecasting in world coordinates.
- Split: the trackers and their evaluation; the graph construction and the GNN; the forecasting study and the propagation of tracking errors.
- Success criterion: MOTA, IDF1 and HOTA of the three trackers computed with the official TrackEval code, and their differences explained by the association rules of chapter 5; average and final displacement errors (ADE, FDE) of the GNN against constant velocity on ETH and UCY; the forecast error on tracker output plotted against IDF1.
- Deliverables: code, an 8–10 page joint report, a 20-minute talk; chapters 1, 2 and 5.
- [Group of 3 · ≈ 30 h each] SAM in the loop: an annotation engine for industrial defects. How much annotation time does a promptable segmenter save on defect masks, and do the saved seconds cost downstream accuracy?
- Work: an annotation tool in which point or box prompts give SAM masks (Example 3.3) that the annotator corrects with a brush, every action timed; an active-learning loop that sends the most uncertain images next (section 4.2); a U-Net trained once on assisted masks and once on manual masks; PatchCore (Roth et al., CVPR 2022) as the label-free baseline of section 7.1.
- Data: MVTec AD (Bergmann et al., CVPR 2019), three to five categories with their pixel-level masks; its training set holds no defect, so the defective test images are split in two halves.
- Split: the tool and a timing study with at least two annotators; active learning and U-Net training; the anomaly baseline and the evaluation.
- Success criterion: seconds and clicks per mask, and mask IoU and Dice against the ground truth, for manual and assisted annotation of the same 100 defects; pixel AUROC and PRO of both U-Nets and of PatchCore; the time saved weighed against the accuracy lost.
- Deliverables: code, a joint report, a talk; chapters 3, 4 and 7.
- [Group of 3 · ≈ 30 h each] Paper study: robustness and fairness audit of a deployed detector (Thys, Van Ranst and Goedemé, CVPR Workshops 2019). Can a printed patch hide a person from your detector, does the detector work equally well for every group, and what do the fixes cost after INT8?
- Work: FGSM and PGD on the inputs (section 9.1); the person-hiding patch of the paper, optimized against your detector and compared with a random patch; per-group recall as in Example 9.1, by lighting, weather, scene type and box size; augmentation or adversarial training as mitigation; a model card (Mitchell et al., FAT* 2019).
- Data: the INRIA Person dataset (Dalal and Triggs, CVPR 2005) used by the paper, available from public mirrors; BDD100K night and rain images; the detector of Ex. 13 or of solo subject 1.
- Split: the attacks; the domain-shift and subgroup evaluation; the mitigation, the INT8 re-audit and the model card.
- Success criterion: the fraction of people no longer detected at the operating threshold with the patch, with the random patch and with no patch; per-group recall with 95 % intervals; mAP, worst-group recall and latency before and after mitigation and INT8.
- Deliverables: code, a joint report with the model card, a talk; chapters 2, 4, 8 and 9. It prepares Security and Robustness (M2) and applies the subgroup evaluation of Machine Learning, section 4.8.
Written exam (proposal)
Two hours, one handwritten A4 sheet allowed, a simple calculator allowed; four exercises.
- Question (4 points). (a) Why does a one-stage detector over dense anchors need the focal loss, or another way to tame the background? (b) Why does DETR need neither anchors nor NMS? (c) What does COCO’s mAP@[0.5:0.95] reward that AP@0.5 does not, and why does COCO also report results by object size?
- Expected: (a) about 10^5 anchors per image, almost all easy background: their summed cross-entropy dominates the loss and its gradient; the factor (1-p_t)^\gamma divides the loss of an anchor at p_t = 0.9 by 100 (Definition 1.4).
- (b) DETR predicts a set of N queries matched one-to-one with the ground truths by the Hungarian algorithm: a duplicate is matched with “no object” and penalized, so the model learns not to emit duplicates (Definition 2.3).
- (c) Averaging over ten IoU thresholds rewards precise localization; the size breakdown exposes small objects, where a few pixels of offset destroy the IoU (Example 0.3).
- Question (5 points). Activations measured on a calibration set lie in [-1, 3]; they are quantized to signed 8 bits by the min-max affine scheme of Definition 8.1. (a) Give the scale s and the zero point z. (b) Quantize and dequantize 1 and 0.01; give the absolute and relative errors. (c) One calibration image produces an outlier activation of 30: give the new scale and the new error bound, and say what a 99.9th-percentile calibration changes.
- Expected: (a) s = 4/255 \approx 0.01569, and z is set so that Q(-1) = -128: z = \mathrm{round}(-128 + 1/s) = \mathrm{round}(-64.25) = -64 , and indeed Q(3) = 191 - 64 = 127.
- (b) For 1: 1/s = 63.75 rounds to 64, so Q = 0, dequantized to 64s \approx 1.0039; the absolute error is 0.0039, the relative error 0.4 %.
- For 0.01: 0.01/s \approx 0.64 rounds to 1, so Q = -63, dequantized to s \approx 0.0157; the absolute error is 0.0057, the relative error 57 %. The bound s/2 is absolute, so small values suffer most.
- (c) The scale becomes 31/255 \approx 0.1216 and the bound s/2 grows from 0.0078 to 0.061, almost 8 times, for every activation. Percentile calibration keeps s \approx 4/255 and clips the rare outlier to 3: one large error instead of a coarse grid for all.
- Question (5 points). For a positive anchor (y = 1) with logit z and p = \sigma(z), prove the focal-loss gradient of chapter 1,
\frac{\partial \mathrm{FL}}{\partial z} = -\alpha\,(1-p)^{\gamma}\big(1 - p - \gamma\, p \log p\big).
Deduce the cross-entropy gradient for \gamma = 0, \alpha = 1. For \gamma = 2, compute the ratio of the gradient magnitudes at p = 0.3 and at p = 0.9, and compare it with the cross-entropy.
- Expected: \sigma'(z) = p(1-p) and, from \mathrm{FL} = -\alpha(1-p)^\gamma \log p, \frac{\partial \mathrm{FL}}{\partial p} = -\alpha\Big(\frac{(1-p)^{\gamma}}{p} - \gamma\,(1-p)^{\gamma-1}\log p\Big).
- Multiplying by p(1-p) gives the formula; at \gamma = 0, \alpha = 1 it reduces to -(1-p), the cross-entropy gradient.
- With g(p) = (1-p)^2(1 - p - 2p\log p): g(0.3) \approx 0.697 and g(0.9) \approx 0.0029, a ratio of about 241, against 0.7/0.1 = 7 for the cross-entropy: the focal loss moves the gradient onto the hard anchors.
- Question (6 points). For a predicted mask p and a ground truth g, write I = |p \cap g| and U = |p \cup g|, and let t = I/U be the IoU. (a) Prove that \mathrm{Dice} = 2t/(1+t), and that Dice is at least the IoU, with equality only when the IoU is 0 or 1. (b) A paper reports a Dice of 0.90: what IoU is that? (c) Two radiologists agree with each other at a Dice of 0.85 on the same lesions, and a model reaches 0.92 against one of them: what do you conclude (section 7.3)?
- Expected: (a) |p| + |g| = I + U, so \mathrm{Dice} = 2I/(I + U) = 2t/(1+t), an increasing function of t (derivative 2/(1+t)^2 > 0): both metrics rank models identically. Moreover \mathrm{Dice} - t = \frac{t(1-t)}{1+t} \geq 0 , with equality only at t = 0 or t = 1.
- (b) Inverting, t = D/(2 - D) = 0.9/1.1 \approx 0.818.
- (c) The inter-observer agreement is the reachable ceiling: 0.92 above 0.85 suggests that the model fits one annotator’s habits, or a leak between training and test (section 4.3); evaluate against several annotators or their consensus.
Grading rubric (proposal)
| Criterion | Weight | What earns the marks |
|---|---|---|
| Question and protocol | 15 % | the question tied to a statement of the chapters (Definition 1.4, the stereo error law, Definition 5.2, Definition 8.1); splits by scene or video, never by image (section 4.3) |
| Correct implementation | 20 % | code checked against a reference (pycocotools, TrackEval, ONNX Runtime, OpenCV) with a stated tolerance |
| Measurement | 20 % | accuracy with its size or subgroup breakdown, and P50/P99 latency on the target hardware, not only on the development workstation |
| Analysis tied to the course | 25 % | each result, failures included, explained by the course: small-object IoU, focal weighting, identity switches, the Z^2/(fB) law, the quantization step |
| Trust and documentation | 10 % | per-group results with intervals, licences and data provenance, a model card or a datasheet |
| Communication | 10 % | figures that show the images and the failure cases, a talk on time, honest limits |
References
- R. Szeliski, Computer Vision: Algorithms and Applications, 2nd ed., Springer, 2022 — the reference textbook, free online.
- O. Ronneberger, P. Fischer, T. Brox, U-Net: Convolutional Networks for Biomedical Image Segmentation, MICCAI 2015.
- S. Ren, K. He, R. Girshick, J. Sun, Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks, NeurIPS 2015.
- J. Redmon, S. Divvala, R. Girshick, A. Farhadi, You Only Look Once: Unified, Real-Time Object Detection, CVPR 2016.
- W. Liu et al., SSD: Single Shot MultiBox Detector, ECCV 2016.
- T.-Y. Lin, P. Goyal, R. Girshick, K. He, P. Dollár, Focal Loss for Dense Object Detection (RetinaNet), ICCV 2017; T.-Y. Lin et al., Feature Pyramid Networks for Object Detection, CVPR 2017.
- K. He, G. Gkioxari, P. Dollár, R. Girshick, Mask R-CNN, ICCV 2017.
- N. Bodla et al., Soft-NMS — Improving Object Detection with One Line of Code, ICCV 2017.
- N. Carion et al., End-to-End Object Detection with Transformers (DETR), ECCV 2020; X. Zhu et al., Deformable DETR, ICLR 2021.
- Z. Tian, C. Shen, H. Chen, T. He, FCOS: Fully Convolutional One-Stage Object Detection, ICCV 2019.
- A. Kirillov et al., Panoptic Segmentation, CVPR 2019.
- A. Kirillov et al., Segment Anything (SAM), ICCV 2023.
- T.-Y. Lin et al., Microsoft COCO: Common Objects in Context, ECCV 2014 — mAP protocol.
- A. Bewley, Z. Ge, L. Ott, F. Ramos, B. Upcroft, Simple Online and Realtime Tracking (SORT), ICIP 2016; N. Wojke, A. Bewley, D. Paulus, Simple Online and Realtime Tracking with a Deep Association Metric (DeepSORT), ICIP 2017.
- Y. Zhang et al., ByteTrack: Multi-Object Tracking by Associating Every Detection Box, ECCV 2022.
- H. Hirschmüller, “Stereo Processing by Semiglobal Matching and Mutual Information”, IEEE TPAMI 30(2), 2008 (SGM); J. Chang, Y. Chen, Pyramid Stereo Matching Network (PSM-Net), CVPR 2018.
- C. R. Qi et al., PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation, CVPR 2017; Y. Zhou, O. Tuzel, VoxelNet, CVPR 2018; A. Lang et al., PointPillars, CVPR 2019.
- T. Yin, X. Zhou, P. Krähenbühl, Center-based 3D Object Detection and Tracking (CenterPoint), CVPR 2021; Z. Li et al., BEVFormer, ECCV 2022.
- H. Caesar et al., nuScenes: A Multimodal Dataset for Autonomous Driving, CVPR 2020; A. Geiger, P. Lenz, R. Urtasun, “Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite”, CVPR 2012.
- P. Bergmann, M. Fauser, D. Sattlegger, C. Steger, “MVTec AD — A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection”, CVPR 2019 — dataset page.
- B. Jacob et al., Quantization and Training of Neural Networks for Integer-Arithmetic-Only Inference, CVPR 2018.
- G. Hinton, O. Vinyals, J. Dean, Distilling the Knowledge in a Neural Network, 2015.
- I. Goodfellow, J. Shlens, C. Szegedy, Explaining and Harnessing Adversarial Examples (FGSM), ICLR 2015.
- D. Bolya, S. Foley, J. Hays, J. Hoffman, TIDE: A General Toolbox for Identifying Object Detection Errors, ECCV 2020.
- A. Milan, L. Leal-Taixé, I. Reid, S. Roth, K. Schindler, MOT16: A Benchmark for Multi-Object Tracking, 2016; J. Luiten et al., HOTA: A Higher Order Metric for Evaluating Multi-Object Tracking, IJCV 2021.
- M. Menze, A. Geiger, “Object Scene Flow for Autonomous Vehicles”, CVPR 2015 (KITTI Stereo 2015); F. Yu et al., BDD100K: A Diverse Driving Dataset for Heterogeneous Multitask Learning, CVPR 2020.
- K. Roth et al., Towards Total Recall in Industrial Anomaly Detection (PatchCore), CVPR 2022.
- K. Eykholt et al., Robust Physical-World Attacks on Deep Learning Visual Classification, CVPR 2018; S. Thys, W. Van Ranst, T. Goedemé, Fooling Automated Surveillance Cameras: Adversarial Patches to Attack Person Detection, CVPR Workshops 2019.
- J. Buolamwini, T. Gebru, Gender Shades: Intersectional Accuracy Disparities in Commercial Gender Classification, FAT* 2018; M. Mitchell et al., Model Cards for Model Reporting, FAT* 2019.
- Lab tools: torchvision, ONNX and ONNX Runtime, TensorRT, Roboflow/supervision — the annotation and metrics ecosystem.
- Instructor note: course announced in the MSc&T brochure (period 2), not in the 2026–27 LLGA lists; no instructor or official syllabus is published — the references above constitute the standard foundation of the field.