🎯 R-CNN Architecture Playground

Interactive visualization of Region-based CNN evolution

R-CNN (Region-based CNN)

Key Innovation: First successful application of CNNs to object detection by using selective search for region proposals.
1
Input Image
Original image fed into the system
Input Image H × W × 3
2
Selective Search
Generate ~2000 region proposals
Problem: Slow and CPU-based
Selective Search Box 1 Box 2 Box 3 ... ~2000 regions
3
CNN Feature Extraction (2000×)
Each region processed independently
Conv1 Conv2 Conv3 Conv4 Conv5 Feature Vector 4096-dim × 2000 regions
4
SVM Classification & Bbox Regression
Separate SVM for each class + linear regression for bbox refinement
SVM 🐕 Dog: 0.89 🚗 Car: 0.12 👤 Person: 0.05 Bbox Refine (x, y, w, h)
⚠️ Main Limitations:
• Training is multi-stage (CNN → SVM → Bbox regressor)
• Very slow: ~47 seconds per image
• 2000 CNN forward passes per image

Fast R-CNN

Key Innovation: Single CNN forward pass with RoI pooling for feature extraction.
1
🚀 Single CNN Forward Pass
Process entire image once
Input Image Shared Feature Map H/16 × W/16 × 512 ✓ Only 1 CNN pass!
2
RoI Pooling Layer
Extract fixed-size features from each proposal
Feature Map RoI 1 RoI 2 RoI 3 RoI Pool 7×7×512 RoI Pool 7×7×512 RoI Pool 7×7×512 FC Layers 4096-d
3
🎯 Multi-task Output
Simultaneous classification and bbox regression
Feature Vector Softmax (Classification) Bbox Regressor (Localization) 🐕 Dog: 0.92 (x, y, w, h) ✓ Single-stage training!
✅ Improvements: 9× faster training, 213× faster testing
⚠️ Bottleneck: Still uses Selective Search

Faster R-CNN

Key Innovation: Region Proposal Network (RPN) - neural network for proposals.
1
Shared Convolutional Layers
Backbone network processes entire image
Image Feature Map Shared for RPN & Detector

🔥 Region Proposal Network (RPN)

2a
Anchor Boxes
9 anchors per position (3 scales × 3 ratios)
Feature Map Grid 3 Scales: 128² 256² 512² 3 Ratios: 2:1 1:1 1:2 9 anchors × all positions = ~20K anchors
2b
RPN Outputs
Objectness scores + bbox refinements
Feature Map Classification (object / not object) Regression (bbox offsets) Top ~300 Proposals (after NMS)
3
Detection Network
RoI pooling + final classification & bbox refinement
RoI Pooling FC Layers Class Scores 🐕 🚗 👤 ... Bbox Refine (Δx, Δy, Δw, Δh) Final Detection
✅ Achievements:
• End-to-end training
• ~5 FPS - near real-time!
• 10× faster than Fast R-CNN
• RPN proposals are FREE (share CNN features)

Performance Comparison

R-CNN

Speed: 47 seconds/image

Proposals: Selective Search (CPU)

Training: Multi-stage

Feature Extraction: 2000× per image

mAP: ~66% (VOC 2007)

Fast R-CNN

Speed: 2 seconds/image

Proposals: Selective Search (CPU)

Training: Single-stage

Feature Extraction: 1× per image

mAP: ~70% (VOC 2007)

Faster R-CNN

Speed: 0.2 seconds/image (5 FPS)

Proposals: RPN (GPU)

Training: End-to-end

Feature Extraction: Shared

mAP: ~73% (VOC 2007)

Speed Comparison Visualization

Processing Time per Image R-CNN 47s Fast R-CNN 2s Faster R-CNN 0.2s 0s 25s 50s

Key Architectural Differences

Component R-CNN Fast R-CNN Faster R-CNN
Region Proposals Selective Search Selective Search RPN (learned)
CNN Passes ~2000 per image 1 per image 1 per image
Feature Sharing None Detection only RPN + Detection
Classification SVM Softmax Softmax
Training Multi-stage Single-stage End-to-end
Speed (FPS) 0.02 0.5 5

Evolution Timeline

R-CNN 2014 Selective Search + CNN Features Fast R-CNN 2015 RoI Pooling Single CNN pass Faster R-CNN 2015 Region Proposal Network (RPN)
📚 Key Takeaways:
R-CNN: Pioneered CNN-based object detection but was slow
Fast R-CNN: Shared CNN computation via RoI pooling, 25× speedup
Faster R-CNN: Replaced Selective Search with RPN, achieving near real-time performance
• Each iteration maintained or improved accuracy while dramatically reducing inference time