ObjectDetectorBase<T>
Base Classes · AiDotNet.ComputerVision.Detection.ObjectDetection
Base class for all object detection models.
Inheritance: ModelBase<T, Tensor<T>, Tensor<T>> → VisionTaskModelBase<T> → ObjectDetectorBase<T>
Implements: IGeneratedParameterRegistrar<T>
Known derived types: CascadeRCNN<T>, DETR<T>, DINO<T>, FasterRCNN<T>, RTDETR<T>, YOLOv10<T>, YOLOv11<T>, YOLOv8<T>, YOLOv9<T>
For Beginners
An object detector takes an image and finds all objects in it, returning their locations (bounding boxes), types (class labels), and confidence scores. This base class provides the common structure and methods that all detection models share.
How It Works
A typical detector has three parts:
- Backbone: Extracts features from the image
- Neck: Combines features at multiple scales
- Head: Produces final predictions (boxes, classes, scores)
Properties
| Property | Summary |
|---|---|
double ConfidenceThreshold { get; } |
Gets the default minimum confidence a detection needs to be reported. |
double NmsThreshold { get; } |
Gets the default IoU threshold used by non-maximum suppression. |
int MaxDetections { get; } |
Gets the maximum number of detections kept for a single image after non-maximum suppression. |
int NumClasses { get; } |
Gets the number of object classes this detector was configured for. |
string Name { get; } |
Name of this detector architecture. |
string[] ClassNames { get; set; } |
Class names for detection labels. |
Methods
| Method | Summary |
|---|---|
BatchDetectionResult<T> DetectBatch(Tensor<T> images) |
Detects objects in a batch of images. |
BatchDetectionResult<T> DetectBatch(Tensor<T> images, double confidenceThreshold, double nmsThreshold) |
Detects objects in a batch of images with custom thresholds. |
DetectionResult<T> Detect(Tensor<T> image) |
Detects objects in an image. |
DetectionResult<T> Detect(Tensor<T> image, double confidenceThreshold, double nmsThreshold) |
Detects objects in an image with custom thresholds. |
Task LoadPretrainedWeightsAsync(CancellationToken cancellationToken) |
Loads default pre-trained weights for this architecture and size. |
Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken) |
Loads pre-trained weights from a file or URL. |
Tensor<T> Predict(Tensor<T> input) |
Predicts by running the forward pass and returning raw network outputs concatenated. |
double EffectiveNmsThreshold(double requested) |
Gets the IoU threshold non-maximum suppression actually applies for a requested threshold. |
long GetParameterCount() |
Gets the total number of parameters in the model. |
void SaveWeights(string path) |
Saves model weights to a file. |
void SetTrainingMode(bool training) |
Sets the model to training or inference mode. |