Faster R-CNN detects objects by predicting tight bounding boxes and classifying the contents of each proposed region. It replaces expensive pixel-level labeling with box annotations and combines three stages: a backbone extracts feature maps, a region proposal network finds candidate objects, and an RoI network classifies each candidate. section 8.4 section 8.4.1
The processing path is:
- The backbone maps an input image of shape (C, W, H) to a feature map (C′, W′, H′), doing most of the computational work. section 8.4.1
A PyTorch detector uses a backbone with an out_channels attribute, an anchor generator, and an RoI pooler. A toy configuration uses square 32 × 32 anchors, MultiScaleRoIAlign with a 7 × 7 output, and ten object classes.
Training and inference on synthetic MNIST scenes
A detection dataset places several MNIST digits at random positions on a 100 × 100 canvas. Each target dictionary stores boxes with shape (k, 4) and integer labels with shape (k). Because images can have different sizes and object counts, a custom collate function returns a list of images and a list of dictionaries. Training calls model(inputs, labels), sums the returned losses, backpropagates, and steps AdamW. In evaluation, model([image]) returns boxes, labels, and confidence scores. section 8.4.2
For immediate use, PyTorch supplies a pretrained Faster R-CNN with a ResNet-50 FPN backbone trained on COCO. Images are normalized and reordered to channel-first tensors; score and overlap thresholds may need tuning for each application. section 8.5

