Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Propose, then recognise each proposal
R-CNN’s recipe is simple:
- Take about 2,000 candidate boxes from selective search.
- Stretch each one to a fixed size.
- Run it through a CNN pretrained on ImageNet.
- Ask a classifier per object class whether this box contains that object.
- Nudge the box to fit the object better.
It was slow, because each image needs 2,000 CNN passes, but it was far more accurate than anything before. It began the era of deep object detection.
R-CNN’s ideas live on in every modern detector: transfer learning from ImageNet, IoU-based training labels, and bounding-box regression. Its slowness is why later detectors share computation.
- 1. R-CNN classifies…
- 2. Its proposals come from…
- 3. Box regression…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Warping: each proposal, enlarged by 16 pixels of context, is resized to 227 × 227 regardless of aspect ratio. A 100 × 50 crop is stretched by 2.27 horizontally and 4.54 vertically.
- Labels by IoU:
- fine-tuning treats a proposal as positive if its IoU with a ground-truth box is ≥ 0.5, else background;
- the SVMs use the ground-truth boxes as positives and proposals with IoU < 0.3 as negatives, ignoring those in between.
- Box regression targets for proposal P and object G:
- t_x = (G_x − P_x)/P_w and t_y = (G_y − P_y)/P_h for the centre shift in proposal units;
- t_w = log(G_w/P_w) and t_h = log(G_h/P_h) for the size change.
- For P = (10, 10, 30, 40) and G = (14, 8, 34, 44): t = (0.2, 0.033, 0, 0.182).
- Cost: 2,000 proposals × 4,952 VOC 2007 test images ≈ 9.9 million CNN passes, about 13 s per image on a GPU.
- 1. Fine-tuning positives have IoU at least…
- 2. t_w for a proposal half as wide as the object:
- 3. R-CNN's input size:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.R-CNN in code
Exercise 1.
- The targets for a sample proposal were (0.2, 1/30, 0, log 1.2), and applying them recovered the object box exactly.
- Proposals were labelled positive (IoU ≥ 0.5), negative (IoU < 0.3) or ignored.
Practice.
- Training stages:
- Pretrain the CNN on ImageNet.
- Fine-tune it on warped proposals (batches of 32 positives and 96 background).
- Train one linear SVM per class, with hard-negative mining.
- Train ridge regressors on pool5 features for proposals with IoU > 0.6.
- Test time: score all proposals, apply per-class non-maximum suppression (E9-14), then regress the boxes.
- Why SVMs rather than the softmax: the paper found SVMs trained on stricter labels gave higher mAP. Fast R-CNN later removed them.
for box in proposals: # ~2,000 per image: the bottleneck
crop = warp(image, expand(box, 16), (227, 227))
f = cnn(crop) # fc7 features
scores = svm_W @ f + svm_b # one linear SVM per class
box = apply(box, reg_W[cls] @ pool5(crop)) # class-specific box regression- 1. R-CNN's classifiers are…
- 2. Box regressors were trained on proposals with IoU above…
- 3. Hard-negative mining adds…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Transfer learning. Detection datasets were small (VOC had about 10,000 training images). Supervised pretraining on ImageNet classification followed by domain-specific fine-tuning gave features far better than HOG. Fine-tuning alone raised VOC 2007 mAP by about 8 points. Features from fc6 and fc7 transferred well, and pool5 alone kept much of the performance.
Why the box targets look like that.
- Normalising the centre shift by the proposal’s size makes t_x scale-invariant.
- The log of the size ratio makes the width targets symmetric for growing and shrinking and keeps predicted sizes positive.
- A linear model can then share one set of weights across boxes of all sizes.
Ridge regularisation (λ = 1,000) was essential, and only proposals near objects (IoU > 0.6) were used, so the problem stays close to linear.
Limits.
- Multi-stage training: the CNN, the SVMs and the regressors are trained separately.
- Heavy disk storage of features.
- No shared computation, so the CNN runs once per proposal.
- Proposals are fixed and not learned.
Fast R-CNN (E9-3) and Faster R-CNN (E9-4) addressed these.
- 1. Log size targets keep predicted sizes…
- 2. Fine-tuning raised VOC 2007 mAP by about…
- 3. R-CNN's main inefficiency:
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How much does box regression help?
History.
- R. Girshick, J. Donahue, T. Darrell and J. Malik (2014) introduced R-CNN at CVPR. It reached 53.3% mAP on VOC 2012, over 30% relative improvement on the previous best, and 31.4% on ILSVRC 2013 detection.
- P. Sermanet et al. (2014) proposed OverFeat, an integrated sliding-window CNN detector.
- R-CNN was followed by SPP-net (K. He et al., 2014), Fast R-CNN (2015) and Faster R-CNN (2015).
Exercise 2. The data are 500 training and 150 test scenes, each with one two-tone rectangle on a noisy 64 × 64 background. Each scene gives 4 proposals: the true box shifted by up to 25% of its size and rescaled by up to about ±30%. Each proposal is warped (with 25% context) to 16 × 16, and a ridge regressor maps its 256 pixels to the four targets:
| test proposals | mean IoU | share with IoU ≥ 0.5 | share with IoU ≥ 0.7 |
|---|---|---|---|
| before regression | 0.597 | 0.832 | 0.153 |
| after regression | 0.870 | 1.000 | 0.998 |
- A linear regressor on raw pixels fixed almost all localisation errors. Proposals that would have failed a strict IoU 0.7 criterion now pass it. A second seed and regularisation strengths from 1 to 100 gave the same picture.
- This is the easy case: one high-contrast object. Real images need learned CNN features, which is what R-CNN regressed from. There, box regression raised VOC 2007 mAP from 54.2% to 58.5%, a large but smaller gain.
R-CNN in AI, robotics and aerospace
- Transfer learning: ImageNet pretraining and fine-tuning, introduced to detection by R-CNN, is still how detectors for drones, robots and satellites are trained on small labelled sets.
- Box regression: every modern detector refines anchors or proposals with the same parameterisation.
- Offline analysis: two-stage, proposal-based pipelines remain useful where accuracy matters more than speed, for example in ground processing of aerial surveys.
References
- R. Girshick, J. Donahue, T. Darrell, J. Malik (2014). “Rich feature hierarchies for accurate object detection and semantic segmentation.” Proc. CVPR.
- P. Sermanet et al. (2014). “OverFeat: integrated recognition, localization and detection using convolutional networks.” Proc. ICLR.
- K. He, X. Zhang, S. Ren, J. Sun (2014). “Spatial pyramid pooling in deep convolutional networks for visual recognition.” Proc. ECCV.