Table of Contents

Class ObjectDetectionOptions<T>

Namespace
AiDotNet.Models.Options
Assembly
AiDotNet.dll

Configuration options for object detection models.

public class ObjectDetectionOptions<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
ObjectDetectionOptions<T>
Inherited Members

Remarks

For Beginners: Object detection finds and locates objects in images. This class configures how the detection model works, including: - Which architecture to use (YOLO, DETR, Faster R-CNN, etc.) - Model size (smaller = faster, larger = more accurate) - Detection thresholds (how confident the model must be)

Properties

Architecture

The detection architecture to use.

public DetectionArchitecture Architecture { get; set; }

Property Value

DetectionArchitecture

Remarks

For Beginners: Different architectures have different trade-offs: - YOLO: Very fast, good accuracy, great for real-time applications - DETR: Transformer-based, no anchors, cleaner but slower - Faster R-CNN: Two-stage, highest accuracy but slower

Backbone

The backbone network type for feature extraction.

public BackboneType Backbone { get; set; }

Property Value

BackboneType

ClassNames

Class names for the detection classes.

public string[]? ClassNames { get; set; }

Property Value

string[]

Remarks

If null, uses COCO class names by default.

ConfidenceThreshold

Minimum confidence score for a detection to be kept.

public double ConfidenceThreshold { get; set; }

Property Value

double

Remarks

For Beginners: Higher values mean fewer but more confident detections. Typical range: 0.25 to 0.5. Start with 0.25 and increase if you get too many false positives.

FreezeBackbone

Whether to freeze the backbone during fine-tuning.

public bool FreezeBackbone { get; set; }

Property Value

bool

InputSize

Input image size [height, width] the model expects.

public int[] InputSize { get; set; }

Property Value

int[]

Remarks

Images will be resized to this size before detection. Common sizes: 320 (fast), 640 (balanced), 1280 (high accuracy).

MaxDetections

Maximum number of detections to return per image.

public int MaxDetections { get; set; }

Property Value

int

Neck

The neck architecture for multi-scale feature fusion.

public NeckType Neck { get; set; }

Property Value

NeckType

NmsThreshold

IoU threshold for Non-Maximum Suppression (NMS).

public double NmsThreshold { get; set; }

Property Value

double

Remarks

For Beginners: NMS removes duplicate detections of the same object. Lower values are more aggressive at removing overlapping boxes. Typical range: 0.4 to 0.6.

NumClasses

Number of object classes to detect.

public int NumClasses { get; set; }

Property Value

int

Remarks

Default is 80 (COCO dataset classes).

RandomSeed

Random seed for reproducibility.

public int? RandomSeed { get; set; }

Property Value

int?

Size

The model size variant.

public ModelSize Size { get; set; }

Property Value

ModelSize

Remarks

For Beginners: Larger models are more accurate but slower: - Nano: Fastest, lowest accuracy, good for edge devices - Small: Fast with reasonable accuracy - Medium: Balanced speed and accuracy (recommended) - Large: High accuracy, slower inference - XLarge: Highest accuracy, slowest

UseMultiScale

Whether to use multi-scale inference for better accuracy.

public bool UseMultiScale { get; set; }

Property Value

bool

Remarks

For Beginners: Multi-scale runs detection at multiple resolutions and combines results. More accurate but 2-3x slower.

UsePretrained

Whether to use pre-trained weights (COCO dataset).

public bool UsePretrained { get; set; }

Property Value

bool

WeightsUrl

Custom URL to download weights from.

public string? WeightsUrl { get; set; }

Property Value

string

Remarks

If null, uses the default weights URL for the selected architecture and size.