Faster R-CNN

Machine Learning
Introduced by
Ren, S.; He, K.; Girshick, R.; Sun, J. (Microsoft Research)
Year
2015
Type
Two-stage object detection CNN

What does it do?

Faster R-CNN is a two-stage deep convolutional object detector introduced by Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun (Microsoft Research) and presented at NeurIPS 2015.

It replaces the selective-search proposal step used by its predecessors R-CNN and Fast R-CNN with a learned Region Proposal Network (RPN) that shares convolutional features with the detection head. Because the proposal and detection stages are trained together, the full pipeline is end-to-end trainable, and the method was reported to reach state-of-the-art accuracy on PASCAL VOC and MS COCO.

The intuition behind the method

Earlier object detectors used two disconnected stages: an external algorithm proposed where objects might be, and a second network classified and refined those proposals. The external proposal step (selective search) was slow and was not learned from data. Faster R-CNN replaces it with a small convolutional network, the RPN, that runs on the same shared feature map already computed by the backbone. The RPN slides over that feature map and, at each location, scores and adjusts a set of pre-defined anchor boxes of different scales and aspect ratios. Because the RPN and the detection head read the same feature map, the extra cost of generating proposals is small, and the whole system can be trained jointly with a single objective. The result is a detector that is accurate and fast enough for many practical uses.

History

Faster R-CNN was presented at NeurIPS 2015 (Advances in Neural Information Processing Systems 28, pp. 91–99). The same work also appeared in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 39, no. 6, pp. 1137–1149, dated 2017 with online availability in 2016. It belongs to the R-CNN lineage: R-CNN (Girshick et al., 2014) introduced region-based CNN detection but classified each proposal separately, and Fast R-CNN (Girshick, 2015) introduced RoI Pooling and end-to-end training of the classification head while still relying on external selective-search proposals. Faster R-CNN replaced those external proposals with a learned RPN that shares convolutional features with the detector, which the abstract describes as making proposals nearly cost-free. The authors reported state-of-the-art accuracy on PASCAL VOC and MS COCO, and later designs such as Mask R-CNN, Cascade R-CNN and DetectoRS build on its framework.

When to use it

Choose Faster R-CNN when detection accuracy is the primary requirement and moderate per-image latency on a GPU is acceptable, for example in medical imaging, satellite image analysis, industrial inspection, or semi-automated annotation. In the original paper, the full system with the VGG-16 backbone, including all steps, ran at about 5 fps on a GPU; newer GPUs and backbones change this figure, so benchmark on your own hardware before committing. The method is well suited to small or densely packed objects, where the RPN's multi-scale anchors help provide coverage. A labelled dataset with bounding-box annotations is required; the model is normally initialised from an ImageNet-pretrained backbone and fine-tuned, so a few thousand annotated images can be enough with transfer learning. Do not choose it when real-time throughput is the constraint: for applications needing 30+ FPS on a single GPU, single-stage detectors such as YOLO or SSD are more appropriate. CPU-only deployment is generally impractical.

Limitations and considerations

  • Inference is slower than single-stage detectors (YOLO, SSD, RetinaNet) at comparable accuracy, limiting use in strict real-time applications.
  • The two-stage pipeline adds implementation complexity and more hyperparameters (anchor sizes, NMS thresholds, RPN sampling ratios) compared to single-stage methods.
  • RoI Pooling introduces quantisation artefacts for small regions; RoI Align (introduced in Mask R-CNN) corrects this but requires replacing the pooling layer.
  • Memory and compute requirements are substantial; training from scratch without a pretrained backbone is impractical for most practitioners.
  • Performance degrades on very densely overlapping objects where NMS may suppress true detections.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Reported state-of-the-art accuracy on PASCAL VOC 2007, 2012 and MS COCO at its introduction, using 300 proposals per image.
  • End-to-end trainable: the RPN and the detection head share features and are optimised jointly, removing the separate external proposal step used by its predecessors.
  • Multi-scale, multi-aspect-ratio anchors let the RPN propose objects across a wide range of sizes without resizing the image several times.
  • Modular backbone: an ImageNet-pretrained CNN such as VGG or ResNet can be substituted as the feature extractor.
  • Faster R-CNN and the RPN were the foundation of first-place entries in several ILSVRC and COCO 2015 tracks, and later designs such as Mask R-CNN and Feature Pyramid Networks build on the same framework.

Applications

  • Autonomous driving: pedestrian, vehicle, and sign detection in dashcam or lidar-fused image streams.
  • Medical imaging: lesion, tumour, and anatomical landmark detection in radiology and pathology images.
  • Remote sensing: building, road, and vehicle detection in aerial and satellite imagery.
  • Industrial quality control: defect detection and foreign-object inspection on production lines.
  • Retail analytics: shelf-product detection and inventory monitoring from store cameras.
  • Dataset annotation: semi-automated bounding-box generation to accelerate human labelling workflows.

How it works

How it works

1

An image is passed through a deep convolutional backbone (originally VGG-16; later ResNet-50/101) to produce a shared feature map. This map is a spatial encoding of the image content that both the RPN and the detection head use, so its computation is shared rather than repeated for each stage.

2

The Region Proposal Network applies a small 3×3 convolutional window to every spatial location of the shared feature map. At each location it evaluates k anchor boxes (Ren et al. use k=9: three scales × three aspect ratios). For each anchor, a sigmoid output gives a predicted objectness score, the probability that the anchor contains an object rather than background.

Formula
p^{*} = \sigma\!\left(\mathbf{w}_{\text{cls}}^{\top}\mathbf{f}_{i}\right)
3

In parallel with objectness scoring, the RPN predicts four box-regression offsets (t_x, t_y, t_w, t_h) that move each anchor toward the ground-truth box. The offsets are expressed relative to the anchor's centre and size, so the regression targets are defined in a way that does not depend on absolute box dimensions.

Formula
\mathbf{t} = \bigl(t_x,\, t_y,\, t_w,\, t_h\bigr), \quad t_x = \tfrac{x - x_a}{w_a},\; t_y = \tfrac{y - y_a}{h_a},\; t_w = \log\!\tfrac{w}{w_a},\; t_h = \log\!\tfrac{h}{h_a}
4

The RPN is trained with a multi-task loss that combines a classification loss on objectness with a smooth-L1 regression loss on the box offsets. Anchors with IoU ≥ 0.7 against a ground-truth box are treated as positive, anchors below 0.3 as negative, and those in between are ignored. The regression term is active only for positive anchors, as the weighting by the positive label in the loss shows. The detection head uses the same multi-task structure.

Formula
\mathcal{L} = \mathcal{L}_{\text{cls}}(p_i, p_i^{*}) + \lambda\, p_i^{*}\, \mathcal{L}_{\text{reg}}(\mathbf{t}_i, \mathbf{t}_i^{*})
5

RoI (Region of Interest) Pooling maps each proposal region, whatever its size, onto a fixed-size feature grid (e.g. 7×7) by dividing the region into sub-cells and max-pooling within each cell. Every proposal therefore yields a feature vector of the same length for the fully connected layers. The proposals entering this step are the RPN outputs after non-maximum suppression (NMS) and selection of the top-N; that selection belongs to the proposal stage, not to the pooling operation itself.

6

Each RoI feature vector passes through two fully connected layers, then branches into a softmax classifier over C+1 classes (the C object classes plus background) and a bounding-box regressor. The output is the final class label and refined box for each detection.

Formula
\hat{c},\, \hat{\mathbf{b}} = \operatorname{softmax}(\mathbf{W}_c \mathbf{h}),\; \mathbf{W}_b \mathbf{h}

Common pitfalls

  • Using default anchor scales without checking them against the target dataset's object size distribution, which can lower recall for unusually large or small objects.
  • Skipping backbone pretraining and training the full network from random initialisation on a small dataset.
  • Ignoring the imbalance between background anchors (the large majority) and positive anchors; the positive and negative sampling used in RPN training should be checked, and default ratios should not be assumed to transfer to a new dataset.
  • Evaluating only at a single IoU threshold (e.g. [email protected]) when the task needs precise localisation; COCO-style mAP averaged across IoU thresholds from 0.5 to 0.95 gives a fuller picture.
  • Setting the NMS IoU threshold too high, which keeps duplicate detections, or too low, which suppresses valid detections in crowded scenes.

Frequently asked questions

What are anchors and why does Faster R-CNN use them?

Anchors are a set of fixed reference bounding boxes of different scales and aspect ratios tiled over every spatial location of the feature map. Rather than searching over all possible box positions and sizes, the RPN only needs to predict small offsets from these reference boxes, which makes the regression problem much easier and ensures coverage of objects at multiple scales without resizing the image multiple times.

How is Faster R-CNN different from YOLO or SSD?

Faster R-CNN is a two-stage detector: the RPN first generates object proposals, then a second stage classifies and refines each proposal. This two-stage process improves accuracy, especially on small objects, at the cost of speed. YOLO and SSD are single-stage detectors that predict boxes and classes directly in one forward pass, achieving higher throughput but typically lower accuracy on challenging benchmarks, particularly for small or densely packed objects.

Do I need a GPU to use Faster R-CNN?

In practice, yes. The shared convolutional backbone is computationally heavy, and per-image inference on CPU is generally far slower than on a modern GPU, which is impractical for most applications. Training is normally done on a GPU, and the memory needed depends on the backbone, input resolution and batch size.

How many annotated images are needed to train Faster R-CNN?

With a backbone pretrained on ImageNet, fine-tuning can work with a few thousand annotated images per class in many practical domains. The PASCAL VOC benchmark's training sets contain several thousand images across its 20 classes, with the exact count depending on the release used. For highly specialised domains (e.g. rare medical findings), transfer learning from a related pretrained detector and data augmentation can extend usability to a few hundred images, though performance will be lower and should be validated rigorously.

Related methods

Sources

  1. Ren, S., He, K., Girshick, R., & Sun, J. (2015). Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. Advances in Neural Information Processing Systems (NeurIPS), 28, 91–99.

    Open publication reference
  2. Ren, S., He, K., Girshick, R., & Sun, J. (2017). Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(6), 1137–1149.

    Open DOI reference
  3. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning (Ch. 9: Convolutional Networks). MIT Press.

    ISBN: 978-0-262-03561-3