RPN<T>

Models & Types · AiDotNet.ComputerVision.Detection.ObjectDetection.RCNN

Region Proposal Network (RPN) - Generates object proposals for two-stage detectors.

Implements: IParameterChunkSource<T>, IParameterLayoutSource, IParameterSource<T>

For Beginners

RPN is a neural network that scans an image and proposes regions that likely contain objects. It’s the first stage in two-stage detectors like Faster R-CNN, enabling end-to-end training.

How It Works

Key features:

  • Slides a small network over the feature map
  • Generates proposals at multiple scales and aspect ratios via anchors
  • Predicts objectness scores and bounding box refinements
  • Shared features with detection network for efficiency

Reference: Ren et al., “Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks”, NeurIPS 2015

Constructors

Constructor Summary
RPN(int inChannels, int hiddenDim, int[] anchorSizes, double[] aspectRatios, int? featureLevel) Creates a new Region Proposal Network.

Properties

Property Summary
AnchorGenerator<T> AnchorGenerator { get; } Gets the anchor generator used by this RPN.
int LevelCount { get; } Gets the number of pyramid levels the RPN has anchors for (one per anchor size).

Methods

Method Summary
List<ValueTuple<Tensor<T>, Tensor<T>>> GenerateProposals(Tensor<T> objectness, Tensor<T> bboxDeltas, List<BoundingBox<T>> anchors, int imageHeight, int imageWidth, int preNmsTopK, int postNmsTopK, double nmsThreshold, int[] levelAnchorCounts) Generates proposals from RPN outputs.
ValueTuple<Tensor<T>, Tensor<T>, List<BoundingBox<T>>, int[]> ForwardLevels(IReadOnlyList<Tensor<T>> levels) Runs the shared RPN head over every level of a feature pyramid.
ValueTuple<Tensor<T>, Tensor<T>, List<BoundingBox<T>>> Forward(Tensor<T> features) Forward pass through the RPN.
long GetParameterCount() Gets the total parameter count for this RPN.
void ReadParameters(BinaryReader reader) Reads the RPN parameters from a binary stream.
void WriteParameters(BinaryWriter writer) Writes the RPN parameters to a binary stream.