Class CascadeRCNN<T>
- Namespace
- AiDotNet.ComputerVision.Detection.ObjectDetection.RCNN
- Assembly
- AiDotNet.dll
Cascade R-CNN - Multi-stage object detection with progressive refinement.
public class CascadeRCNN<T> : ObjectDetectorBase<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
CascadeRCNN<T>
- Inherited Members
Remarks
For Beginners: Cascade R-CNN improves upon Faster R-CNN by using multiple detection stages, each trained with progressively higher IoU thresholds. This allows the model to produce higher quality detections through progressive refinement.
Key features: - Multiple cascade stages (typically 3) for progressive refinement - Each stage uses higher IoU threshold for training - Bounding boxes are refined at each stage - Achieves higher accuracy than Faster R-CNN at slight speed cost
Reference: Cai and Vasconcelos, "Cascade R-CNN: Delving into High Quality Object Detection", CVPR 2018
Constructors
CascadeRCNN(ObjectDetectionOptions<T>, int)
Creates a new Cascade R-CNN detector.
public CascadeRCNN(ObjectDetectionOptions<T> options, int numStages = 3)
Parameters
optionsObjectDetectionOptions<T>Detection options.
numStagesintNumber of cascade stages (default 3).
Properties
Name
Name of this detector architecture.
public override string Name { get; }
Property Value
Methods
Detect(Tensor<T>, double, double)
Detects objects in an image with custom thresholds.
public override DetectionResult<T> Detect(Tensor<T> image, double confidenceThreshold, double nmsThreshold)
Parameters
imageTensor<T>Input image tensor.
confidenceThresholddoubleMinimum confidence to keep a detection.
nmsThresholddoubleIoU threshold for NMS.
Returns
- DetectionResult<T>
Detection results.
Forward(Tensor<T>)
Performs forward pass through the network.
protected override List<Tensor<T>> Forward(Tensor<T> input)
Parameters
inputTensor<T>Input image tensor.
Returns
- List<Tensor<T>>
Raw network outputs before post-processing.
GetHeadParameterCount()
Gets the number of parameters in the detection head.
protected override long GetHeadParameterCount()
Returns
- long
Number of parameters.
LoadWeightsAsync(string, CancellationToken)
Loads pre-trained weights from a file or URL.
public override Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken = default)
Parameters
pathOrUrlstringLocal file path or URL to weights.
cancellationTokenCancellationTokenCancellation token.
Returns
PostProcess(List<Tensor<T>>, int, int, double, double)
Post-processes raw network outputs into detections.
protected override List<Detection<T>> PostProcess(List<Tensor<T>> outputs, int imageWidth, int imageHeight, double confidenceThreshold, double nmsThreshold)
Parameters
outputsList<Tensor<T>>Raw network outputs.
imageWidthintOriginal image width.
imageHeightintOriginal image height.
confidenceThresholddoubleMinimum confidence threshold.
nmsThresholddoubleNMS IoU threshold.
Returns
SaveWeights(string)
Saves model weights to a file.
public override void SaveWeights(string path)
Parameters
pathstringFile path to save weights.