Simple Algorithm
Deep Learning · Representation · 24 min

Detection, Segmentation & Video

From one label per image to boxes and masks for every object, and actions over time.

A classifier answers one question about a photo: what is in it? A car's driver-assistance system needs a box around every pedestrian, a radiologist the outline of every lesion, a sports analyst the action unfolding over a hundred frames. Dense prediction asks for many outputs per image, an unknown number of them, and that single change forces new heads, new losses, a way to remove duplicates and a new way to keep score.

What you’ll learn

  • Define the outputs of detection, semantic, instance and panoptic segmentation and the main video tasks, and compute IoU, average precision and mean IoU.
  • Trace two-stage detectors from R-CNN to Faster R-CNN, derive the anchor-offset box parametrization, and contrast them with one-stage detectors and feature pyramids.
  • Run non-maximum suppression by hand and in code, and explain how DETR does without it.
  • Explain how fully convolutional networks, U-Net, dilated convolutions and Mask R-CNN produce per-pixel outputs at high resolution.
  • Compare per-frame 2-D CNNs, 3-D convolutions and space–time attention for video by what they model and what they cost.

What dense tasks output

An image classifier maps a picture to one of CC labels. Most real uses need more: where each object is, which pixels belong to it and, in video, what happens over time. The tasks differ above all in the shape of their output:

TaskOutput for one image or clipUsual score
Classificationone label out of CCtop-1 or top-5 accuracy
Localizationone label and one boxcorrect if the label is right and the box overlaps the true one enough
Object detectiona set {(bi,ci,si)}\{(b_i,c_i,s_i)\} of boxes, classes and confidence scores, of any sizeaverage precision (AP), averaged over classes (mAP)
Semantic segmentationan H×WH\times W map of class labels; two touching cars merge into one "car" regionmean intersection over union (mIoU)
Instance segmentationa set of (mask, class, score), one per objectAP computed on masks
Panoptic segmentationa class for every pixel, plus an instance identity for countable "things"; "stuff" such as sky or road gets a class onlypanoptic quality (PQ)
Video: action recognition, temporal localization, trackinga label per clip; labeled time intervals; boxes linked into identities across framesaccuracy; AP over time intervals; identity-aware tracking scores

Two things make detection harder than classification. The number of outputs is not fixed, so the network must propose many candidates and some rule must decide which survive. And to train or score a predicted box you must decide which true object it is aiming at, which needs a measure of how well two regions overlap.

Predict before you look

A ground-truth box is 50 pixels wide and 100 pixels tall. A predicted box of exactly the same size is shifted 10 pixels to the right and 20 pixels down. What is its IoU, in percent?

Show the answer

47 %

The overlap is (50−10)×(100−20)=3,200(50-10)\times(100-20)=3{,}200 pixels and the union 2×5,000−3,200=6,8002\times5{,}000-3{,}200=6{,}800, so IoU ≈0.47\approx0.47. A box off by a fifth of the object's width and height misses the usual 0.5 threshold. In general, a same-size box shifted by a fraction ff of each side has IoU (1−f)2/(2−(1−f)2)(1-f)^2/\big(2-(1-f)^2\big): 0.68 at f=0.1f=0.1, 0.47 at f=0.2f=0.2.

Two stages: propose, then classify

The oldest recipe turns detection into many classifications: slide a classifier over windows of every position, size and shape. A CNN is far too expensive for that brute force, so the first deep detectors classified a short list of candidate regions instead.

R-CNN (Girshick et al., 2014) took about 2,000 region proposals per image from selective search, a classical bottom-up grouping algorithm, warped each to 227×227227\times227 pixels, ran a CNN on each, and scored the features with one linear SVM per class, plus a regression that nudged each box. It raised mAP on PASCAL VOC 2012 by more than 30% relative, to 53.3%, but ran the CNN 2,000 times per image.

Fast R-CNN (Girshick, 2015) runs the CNN once. Each proposal is projected onto the shared feature map, and RoI pooling max-pools the region into a fixed 7×77\times7 grid that fully connected layers turn into class scores and box offsets, trained together by one multi-task loss. With VGG-16, training became 9 times and testing 146 times faster than R-CNN, 0.32 s per image instead of 47 s (213 times, at 0.22 s, once a truncated SVD had compressed the fully connected layers), not counting the proposals, which were now the bottleneck.

Faster R-CNN (Ren et al., 2015) makes the proposals with the network too. A small region proposal network (RPN) slides a 3×33\times3 window over the same feature map and, at every position, scores k=9k=9 reference boxes, the anchors, with three areas (1282128^2, 2562256^2 and 5122512^2 pixels) and three aspect ratios (1:1, 1:2, 2:1): an "object or not" score and four offsets for each. At stride 16, a 1000×6001000\times600 image has about 60×40×9≈20,00060\times40\times9\approx20{,}000 anchors. The 300 best proposals, after duplicates are removed, go to a Fast R-CNN head, and the whole detector ran at 5 frames per second on a GPU.

DerivationBoxes as offsets from an anchor
  1. tx=x−xawa,ty=y−yaha,tw=log⁡wwa,th=log⁡hhat_x=\frac{x-x_a}{w_a},\qquad t_y=\frac{y-y_a}{h_a},\qquad t_w=\log\frac{w}{w_a},\qquad t_h=\log\frac{h}{h_a}

    An anchor (or a proposal) has center (xa,ya)(x_a,y_a), width waw_a and height hah_a. The network does not output a box directly; it outputs four numbers relative to the anchor, whose targets for a true box (x,y,w,h)(x,y,w,h) are

  2. x^=xa+wat^x,y^=ya+hat^y,w^=wa et^w,h^=ha et^h\hat x=x_a+w_a\hat t_x,\qquad \hat y=y_a+h_a\hat t_y,\qquad \hat w=w_a\,e^{\hat t_w},\qquad \hat h=h_a\,e^{\hat t_h}

    Decoding inverts the map. Whatever the network outputs, the exponential keeps the predicted width and height positive:

  3. (sx+c)−(sxa+c)s wa=x−xawa,log⁡s ws wa=log⁡wwa\frac{(sx+c)-(sx_a+c)}{s\,w_a}=\frac{x-x_a}{w_a},\qquad \log\frac{s\,w}{s\,w_a}=\log\frac{w}{w_a}

    Rescale the image by s>0s>0 and shift it by cc: the anchor and the box move together and the targets do not change. A 30-pixel object and a 300-pixel object present the same regression problem relative to their anchors, so one regressor serves all sizes:

  4. L=1Ncls∑iℓcls(pi,pi∗)+λNreg∑ipi∗smooth⁡L1(ti−ti∗),smooth⁡L1(u)={12u2,∣u∣<1∣u∣−12,otherwise\loss=\frac1{N_{\text{cls}}}\sum_i\ell_{\text{cls}}(p_i,p_i^*)+\frac{\lambda}{N_{\text{reg}}}\sum_ip_i^*\operatorname{smooth}_{L_1}(\mathbf t_i-\mathbf t_i^*),\qquad \operatorname{smooth}_{L_1}(u)=\begin{cases}\tfrac12u^2,&|u|<1\\|u|-\tfrac12,&\text{otherwise}\end{cases}

    Training adds a classification loss over the sampled anchors to a regression loss on the positives only (pi∗=1p_i^*=1). The smooth-L1L_1 loss, summed over the four coordinates, is quadratic near zero and linear beyond, so badly matched boxes do not dominate the gradient:

Which anchors are positives? The RPN labels an anchor positive if its IoU with some true box exceeds 0.7, or if it is the best-overlapping anchor of some box (so that no object is left without one), negative if its IoU is below 0.3 with every box, and ignores the rest. Each training image contributes 256 sampled anchors, at most half of them positive. Which candidates count as positives, the label assignment, turns out to matter as much as the architecture, a theme Real-Time & Anchor-Free Detectors pursues.

Think first Fast R-CNN made testing 146 times faster than R-CNN with the same VGG-16 network and the same proposals, before any compression. Where did that come from?

From sharing the convolutions. R-CNN ran the whole network on each of about 2,000 warped crops; Fast R-CNN runs it once per image and then does only cheap work per proposal: pooling a 7×77\times7 grid from the shared feature map and two fully connected layers. The per-proposal cost moved from the expensive part of the network to the cheap part. Those fully connected layers then took most of the remaining time, and compressing them with a truncated SVD raised the speedup to 213 times.

One stage, many scales, no duplicates

One-stage detectors skip the proposal step and predict classes and boxes directly at every position of a feature map, in a single pass:

  • YOLO (Redmon et al., 2016) lays a 7×77\times7 grid over the image, and every cell outputs two boxes, a confidence for each and 20 class probabilities that the two share: a 7×7×307\times7\times30 tensor in all. It ran at 45 frames per second with 63.4% mAP on PASCAL VOC 2007, against 70.0% at 0.5 frames per second for Fast R-CNN.
  • SSD (Liu et al., 2016) predicts offsets for several default boxes at every position of several feature maps of decreasing resolution, 8,732 boxes for a 300×300300\times300 input, and reached 74.3% mAP at 59 frames per second.
  • RetinaNet (Lin et al., 2017) places 9 anchors per position on five pyramid levels, about 100,000 per image, nearly all of them easy background. Its focal loss −(1−pt)γlog⁡pt-(1-p_t)^\gamma\log p_t with γ=2\gamma=2 shrinks the loss of well-classified anchors so that the rare hard ones dominate training, and it surpassed the accuracy of the two-stage detectors of its day (Reshaping Cross-Entropy analyzes this loss).

Objects come in all sizes, and one feature map serves them badly. The last stage of a backbone has strong features but a stride of 32, so a small object covers a cell or two; early stages are fine-grained but semantically weak. A feature pyramid network (FPN; Lin et al., 2017) gets both. Starting from the coarsest stage it upsamples by 2, adds the next finer stage after a 1×11\times1 convolution, and smooths each sum with a 3×33\times3 convolution:

P5=conv⁡1×1(C5),Pℓ=Up⁡2(Pℓ+1)+conv⁡1×1(Cℓ),ℓ=4,3,2P_5=\operatorname{conv}_{1\times1}(C_5),\qquad P_\ell=\operatorname{Up}_2(P_{\ell+1})+\operatorname{conv}_{1\times1}(C_\ell),\quad \ell=4,3,2
CℓC_\ell is backbone stage ℓ\ell, with stride 2ℓ2^\ell (4 to 32 pixels); every level has 256 channels. Anchors of area 32232^2 to 5122512^2 sit on levels P2P_2 to P6P_6 (P6P_6 subsamples P5P_5), and a two-stage head pools a w×hw\times h region from level k=⌊4+log⁡2(wh/224)⌋k=\lfloor4+\log_2(\sqrt{wh}/224)\rfloor: a 224×224224\times224 region from P4P_4, one half as large from P3P_3.

Every detector so far predicts the same object many times, from neighboring positions and overlapping anchors. Non-maximum suppression (NMS) cleans up, one class at a time. Take the highest-scoring box as a detection, drop every other box that overlaps it with an IoU above a threshold (often 0.5), and repeat on the boxes that remain until none are left.

python
import torch

def box_iou(a, b):
    """IoU of every box in a (N, 4) with every box in b (M, 4); boxes are (x1, y1, x2, y2)."""
    area_a = (a[:, 2] - a[:, 0]) * (a[:, 3] - a[:, 1])
    area_b = (b[:, 2] - b[:, 0]) * (b[:, 3] - b[:, 1])
    top_left = torch.maximum(a[:, None, :2], b[None, :, :2])    # (N, M, 2)
    bottom_right = torch.minimum(a[:, None, 2:], b[None, :, 2:])
    inter = (bottom_right - top_left).clamp(min=0).prod(dim=2)   # zero when the boxes are disjoint
    return inter / (area_a[:, None] + area_b[None, :] - inter)

def nms(boxes, scores, iou_threshold=0.5):
    """Greedy non-maximum suppression: indices of the kept boxes, best first."""
    order = scores.argsort(descending=True)
    keep = []
    while order.numel() > 0:
        best, rest = order[0], order[1:]
        keep.append(best.item())
        overlap = box_iou(boxes[best].unsqueeze(0), boxes[rest])[0]
        order = rest[overlap <= iou_threshold]                    # drop the winner's duplicates
    return keep

boxes = torch.tensor([[0., 0, 10, 10], [3, 0, 13, 10], [6, 0, 16, 10], [20, 20, 30, 30]])
print(nms(boxes, torch.tensor([0.9, 0.8, 0.7, 0.6])))             # [0, 2, 3]

Greedy NMS as detectors run it; torchvision.ops.nms(boxes, scores, iou_threshold) implements the same rule. The loop is sequential and its cost grows with the number of candidate boxes, which matters for real-time detectors.

Check your understanding

The four boxes in the code have scores 0.9, 0.8, 0.7 and 0.6. Box BB overlaps AA with IoU 0.54 and overlaps CC with IoU 0.54; AA and CC overlap with IoU 0.25; DD overlaps nothing. Which boxes survive NMS at threshold 0.5?

  1. AA and DD only
  2. AA, BB, CC and DD
  3. AA only
  4. AA, CC and DD
Show the answer

D. AA, CC and DD

AA wins first and removes BB (IoU 0.54 > 0.5) but not CC (0.25). BB is gone, so its overlap with CC no longer matters: CC is the best of what remains and is kept, and so is DD. A suppressed box never suppresses anything itself.

NMS is a hand-tuned step outside training, and its threshold trades duplicates kept against true neighbors deleted in crowds. DETR (Carion et al., 2020) removed it. A transformer decoder turns N=100N=100 learned object queries into 100 predictions, each a class (possibly "no object") and a box. During training, the Hungarian algorithm pairs every true object with exactly one prediction, choosing the pairing of lowest total cost, and the loss compares each prediction with its partner. A second prediction on an object that is already paired is trained toward "no object", so the network learns not to emit duplicates. DETR needs no anchors either. It beat a strong Faster R-CNN on large objects but not on small ones, and needed a much longer training schedule, hundreds of epochs.

Keeping score: precision, recall and AP

A detector outputs boxes with confidence scores, and whoever deploys it chooses a threshold. To compare detectors without fixing one, benchmarks score the whole ranked list. For one class, sort all detections over the test set by score and go down the list. Each detection claims the best-overlapping true box that no earlier detection has claimed, provided their IoU reaches the threshold, and is then a true positive; otherwise it is a false positive, as is a second box on an object already claimed. After the top kk detections,

P(k)=TP(k)k,r(k)=TP(k)R,AP=1R∑k: detection k is a true positiveP(k)P(k)=\frac{\mathrm{TP}(k)}{k},\qquad r(k)=\frac{\mathrm{TP}(k)}{R},\qquad \mathrm{AP}=\frac1R\sum_{k:\ \text{detection }k\text{ is a true positive}}P(k)
RR is the number of true objects of the class. Precision PP is the fraction of kept detections that are right, recall rr the fraction of objects found. Each true positive moves recall one step of 1/R1/R to the right and false positives leave it where it is, so the precision–recall curve is a staircase whose area is the sum of the precisions at the hits divided by RR; an object that no detection finds contributes a zero term.

Benchmarks first replace precision by its running maximum from the right, Pinterp(r)=max⁡r′≥rP(r′)P_{\text{interp}}(r)=\max_{r'\ge r}P(r'), so the curve never rises again, then average it over recall: PASCAL VOC originally at 11 recall levels, COCO at 101. The mean over classes is the mAP. COCO's headline number also averages over ten IoU thresholds, 0.50,0.55,…,0.950.50, 0.55,\dots,0.95, which rewards tight boxes, and it reports AP50_{50}, AP75_{75} and AP for small, medium and large objects separately. A detector can rank differently on AP50_{50} and on the averaged AP.

Predict before you look

A class has 4 true objects in the test set. The detector's ranked detections for it are TP, TP, FP, TP, FP, FP; the fourth object is never detected. What is the AP without interpolation, in percent?

Show the answer

68.75 %

The hits come at ranks 1, 2 and 4, where precision is 11, 11 and 3/43/4; their sum divided by the 4 objects gives AP =2.75/4=0.6875=2.75/4=0.6875. Interpolating would not raise it, since no later rank has a higher precision than these. The missed object costs a full quarter of the AP, and the two false positives after the last hit cost nothing at all.

Segmentation is scored per pixel. For each class cc, count over the whole test set the pixels predicted cc that are cc (TPc\mathrm{TP}_c), predicted cc but not (FPc\mathrm{FP}_c) and cc but missed (FNc\mathrm{FN}_c); then mIoU=1C∑cTPc/(TPc+FPc+FNc)\mathrm{mIoU}=\frac1C\sum_c\mathrm{TP}_c/(\mathrm{TP}_c+\mathrm{FP}_c+\mathrm{FN}_c). Averaging over classes keeps rare classes from being drowned by sky and road. Panoptic segmentation matches predicted and true segments at IoU above 0.5 and reports PQ=∑TPIoU / (∣TP∣+12∣FP∣+12∣FN∣)\mathrm{PQ}=\sum_{\mathrm{TP}}\mathrm{IoU}\,/\,\big(|\mathrm{TP}|+\tfrac12|\mathrm{FP}|+\tfrac12|\mathrm{FN}|\big).

A label for every pixel

Segmentation needs an output as large as the input, yet classification backbones shrink the image 32 times. A fully convolutional network (FCN; Long, Shelhamer & Darrell, 2015) first convolutionalizes a classifier: a fully connected layer applied to a 7×77\times7 map is a 7×77\times7 convolution, and the layers after it are 1×11\times1 convolutions, so the network accepts any input size and returns class scores on a coarse grid, one score vector per 32×3232\times32 block of pixels. Transposed convolutions initialized to bilinear interpolation upsample the map, and skip connections add score maps predicted from the finer pool4 and pool3 features. On their PASCAL validation subset, mean IoU rose from 59.4 (FCN-32s) to 62.4 (FCN-16s) and 62.7 (FCN-8s). Training is per-pixel cross-entropy.

U-Net (Ronneberger, Fischer & Brox, 2015) gives the decoder the encoder's shape in reverse: four downsampling steps, four upsampling steps, and at every scale a skip connection that concatenates the encoder's features with the decoder's, restoring the detail that downsampling threw away. Trained on very few annotated microscopy images, with heavy elastic-deformation augmentation and a loss that up-weights the thin borders between touching cells, it won the ISBI cell tracking challenge 2015. It became a standard architecture for medical segmentation, and later the denoiser inside many diffusion models.

DeepLab (Chen et al., 2018) keeps the resolution instead. It removes the stride from the backbone's last downsampling steps and dilates every later convolution by the total stride removed before it: by 2 after the first such step, by 4 after the second. Without the dilation, each later 3×33\times3 filter would read neighbors half as far apart as in training and every later receptive field would shrink; with it, the filters keep their pretrained weights and exactly the taps they had, now evaluated at every position. Features come every 8 pixels instead of every 32 (output stride 8), and bilinear upsampling recovers the rest. Parallel branches with dilation rates 6, 12, 18 and 24, atrous spatial pyramid pooling, look at several scales of context at once. The price is compute and memory: every stride-2 step removed quadruples the size of the feature maps after it.

Instance segmentation needs both separate objects and exact pixels. Mask R-CNN (He et al., 2017) gives Faster R-CNN with an FPN a third branch: a small FCN that predicts, for every region, a 28×2828\times28 mask per class with a per-pixel sigmoid. Only the predicted class's mask is used, so classes do not compete for pixels. Its RoIAlign reads each region's features at exact, fractional positions by bilinear interpolation, where RoI pooling had snapped the region's borders to whole feature cells; this seemingly small change improved mask accuracy by 10–50% relative. The mask branch adds little cost: the whole system ran at 5 frames per second. Every model in this step still predicts a fixed list of classes learned from hand-drawn masks.

Adding time

A video is a stack of frames, a T×H×W×3T\times H\times W\times3 tensor: ten seconds at 30 frames per second is 300 frames. Recognizing an action in it ("opening a door", "serving in tennis") adds an axis to everything above, and three families of models handle that axis differently:

ApproachHow it handles timeExamples
2-D CNN per frame, then poolingan image network on each sampled frame; features averaged or combined late, so motion is seen only through what late layers comparesingle-frame and late-fusion baselines (Karpathy et al., 2014)
Two streamsa second CNN reads stacked optical flow, the motion between consecutive frames, alongside the RGB streamSimonyan & Zisserman (2014)
3-D convolutionkernels of size kt×k×kk_t\times k\times k slide over time as well as spaceC3D (Tran et al., 2015); I3D (Carreira & Zisserman, 2017)
Space–time attentionpatches of all frames become tokens, and self-attention relates any patch to any other, in space or timeTimeSformer (Bertasius et al., 2021); ViViT (Arnab et al., 2021)
T CoutCin k2 HW⏟2-D, every frame  vs.  T CoutCin kt k2 HW⏟3-D ;(TN)2d⏟joint attention  vs.  TN (T+N) d⏟time, then space\underbrace{T\,C_{\text{out}}C_{\text{in}}\,k^2\,HW}_{\text{2-D, every frame}}\ \ \text{vs.}\ \ \underbrace{T\,C_{\text{out}}C_{\text{in}}\,k_t\,k^2\,HW}_{\text{3-D}}\,;\qquad \underbrace{(TN)^2d}_{\text{joint attention}}\ \ \text{vs.}\ \ \underbrace{TN\,(T+N)\,d}_{\text{time, then space}}
Multiply–adds of one stride-1 convolutional layer over TT frames, and the size of the attention-score computation for TNTN tokens of width dd, with N=HW/P2N=HW/P^2 patches per frame. For 8 frames of 224×224224\times224 in 16×1616\times16 patches, TN=1,568TN=1{,}568 tokens, and attending over time and then over space instead of jointly cuts the score computation by a factor TN/(T+N)≈7.7TN/(T+N)\approx7.7.

How much does motion matter? On Sports-1M, a million YouTube videos in 487 classes, the best model that fused frames over time improved video-level accuracy over a single-frame CNN only from 59.3% to 60.9% (Karpathy et al., 2014). Yet on UCF-101, a two-stream network's optical-flow stream alone beat its RGB stream, 83.7% against 73.0%, and fusing both reached 88.0% (Simonyan & Zisserman, 2014). Both findings hold because datasets differ in how much of the label a single frame already shows.

Think first A model that sees a single frame can label "playing basketball". Why can no single-frame model tell "pushing something from left to right" from "pushing something from right to left"?

In the first case the scene, a court, a hoop and a ball, all but determines the label. In the second, both classes contain the same hands, objects and backgrounds, and differ only in the order of the frames: playing a clip backward turns one into the other. Only a model that compares frames over time can separate them, which is why datasets built around such pairs became the test of temporal modeling.

Key takeaways

  • Dense tasks output sets or maps: boxes with classes and scores (detection), a class per pixel (semantic segmentation), a mask per object (instance segmentation), or both (panoptic); IoU measures how well two regions overlap.
  • Two-stage detectors propose, then classify: R-CNN ran a CNN per proposal, Fast R-CNN pooled every proposal from one shared feature map, and Faster R-CNN generated proposals with an RPN that scores 9 anchors per position. Boxes are regressed as offsets (tx,ty,log⁡wwa,log⁡hha)(t_x,t_y,\log\tfrac{w}{w_a},\log\tfrac{h}{h_a}) that do not depend on scale.
  • One-stage detectors (YOLO, SSD, RetinaNet with the focal loss) predict densely in a single pass; feature pyramids give each object a level of suitable resolution; greedy NMS removes duplicates, and DETR's one-to-one matching makes it unnecessary.
  • AP averages, over all true objects, the precision at the rank where each one is found (zero for objects never found); COCO's headline AP also averages over classes and over ten IoU thresholds from 0.50 to 0.95. Segmentation is scored by mean IoU over classes, panoptic segmentation by PQ.
  • Per-pixel outputs need resolution: FCNs upsample with skips, U-Net mirrors the encoder, DeepLab replaces late strides by dilation (output stride 8, same fields), and Mask R-CNN predicts a mask per region with RoIAlign. Video adds time through per-frame CNNs, optical flow, 3-D convolutions (ktk_t times the cost) or space–time attention.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A detector returns two boxes on the same person, with scores 0.9 and 0.8 and IoUs 0.70 and 0.85 with the person's true box. How are they counted when AP is computed at IoU 0.5?

  1. Both as true positives, since both overlap the person by more than 0.5
  2. The 0.9 box as a true positive and the 0.8 box as a false positive
  3. Both as false positives, because the person was detected twice
  4. The 0.85-IoU box as a true positive and the other as a false positive, whatever the scores
Show the answer

B. The 0.9 box as a true positive and the 0.8 box as a false positive

Matching walks down the list in score order, and each true object can be matched only once. The 0.9 box claims the person; the 0.8 box finds the person taken and counts as a false positive. Duplicates therefore cost precision, which is why NMS or one-to-one matching matters.

Question 2

What does Faster R-CNN's region proposal network output for each anchor?

  1. Probabilities for every object class, and a mask
  2. The absolute pixel coordinates of the nearest object
  3. A decision whether to run the full CNN on that region
  4. A score for "object versus background" and four offsets that turn the anchor into a box
Show the answer

D. A score for "object versus background" and four offsets that turn the anchor into a box

The RPN is class-agnostic: 2k2k scores and 4k4k offsets (tx,ty,tw,th)(t_x,t_y,t_w,t_h) for the k=9k=9 anchors at each position. The best few hundred proposals are then classified into object classes and refined by the second stage.

Question 3

Why does a feature pyramid network add a top-down pathway instead of predicting directly from each stage of the backbone?

  1. Early stages have fine resolution but weak, low-level features; the top-down pathway brings strong features from the coarse stages to every resolution
  2. It reduces the number of parameters of the backbone
  3. Early stages have larger receptive fields, which the top-down pathway shrinks
  4. It removes the need for anchors
Show the answer

A. Early stages have fine resolution but weak, low-level features; the top-down pathway brings strong features from the coarse stages to every resolution

Predicting from the raw stages (as SSD does) puts small objects on shallow, semantically weak features. FPN adds upsampled deep features to each finer stage through 1×11\times1 lateral connections, so every level is both high-resolution and semantically strong.

Question 4

DeepLab removes the strides of a classification backbone's last stages and dilates the convolutions after them. What does this achieve?

  1. Fewer parameters than the original backbone
  2. A smaller receptive field, which sharpens object boundaries
  3. Feature maps at output stride 8 instead of 32, with the pretrained weights and receptive fields unchanged, at a higher compute and memory cost
  4. An output at full resolution, so no upsampling is needed at all
Show the answer

C. Feature maps at output stride 8 instead of 32, with the pretrained weights and receptive fields unchanged, at a higher compute and memory cost

Dilating each later filter by the total stride removed before it restores exactly the taps it had in the pretrained network, so the field of view is preserved while each removed stride doubles the density of positions in each direction (four times as many). The final map is still upsampled 8 times, bilinearly.

Question 5

On Sports-1M, the best model that fused information across frames beat a single-frame CNN only from 59.3% to 60.9% video-level accuracy (Karpathy et al., 2014). What is the most defensible conclusion?

  1. Motion carries no useful information for recognizing actions
  2. Many of that dataset's labels can be read from the appearance of single frames, so it rewards recognizing scenes and objects more than modeling motion
  3. 3-D convolutions are inherently worse than 2-D convolutions
  4. Video models cannot work without optical flow
Show the answer

B. Many of that dataset's labels can be read from the appearance of single frames, so it rewards recognizing scenes and objects more than modeling motion

The result says as much about the dataset as about the models: sports are often identifiable from the court, the equipment or the clothing. On UCF-101 an optical-flow stream alone beat the RGB stream, and on datasets built so that only the order of frames distinguishes classes, single-frame models fail.

Go deeper

Further reading

  • S. Ren, K. He, R. Girshick & J. Sun, "Faster R-CNN: Towards real-time object detection with region proposal networks," NeurIPS (2015).
  • T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan & S. Belongie, "Feature pyramid networks for object detection," CVPR (2017).
  • J. Long, E. Shelhamer & T. Darrell, "Fully convolutional networks for semantic segmentation," CVPR (2015).
  • K. He, G. Gkioxari, P. Dollár & R. Girshick, "Mask R-CNN," ICCV (2017).