Table of Contents

Class YOLOv11<T>

Namespace
AiDotNet.ComputerVision.Detection.ObjectDetection.YOLO
Assembly
AiDotNet.dll

YOLOv11 object detector with enhanced feature extraction and attention mechanisms.

public class YOLOv11<T> : ObjectDetectorBase<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
YOLOv11<T>
Inherited Members

Remarks

For Beginners: YOLOv11 is the latest YOLO version with improved feature extraction using attention mechanisms and more efficient architecture. It builds upon YOLOv8-v10 innovations while adding new enhancements.

Key features: - C3k2 blocks with attention for enhanced feature extraction - Spatial Pyramid Pooling Fast (SPPF) with larger kernel - Multi-head self-attention in neck - Improved small object detection

Reference: Ultralytics, "YOLOv11" 2024

Constructors

YOLOv11(ObjectDetectionOptions<T>)

Creates a new YOLOv11 detector.

public YOLOv11(ObjectDetectionOptions<T> options)

Parameters

options ObjectDetectionOptions<T>

Detection options.

Properties

Name

Name of this detector architecture.

public override string Name { get; }

Property Value

string

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

image Tensor<T>

Input image tensor.

confidenceThreshold double

Minimum confidence to keep a detection.

nmsThreshold double

IoU 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

input Tensor<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

pathOrUrl string

Local file path or URL to weights.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

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

outputs List<Tensor<T>>

Raw network outputs.

imageWidth int

Original image width.

imageHeight int

Original image height.

confidenceThreshold double

Minimum confidence threshold.

nmsThreshold double

NMS IoU threshold.

Returns

List<Detection<T>>

List of detections after NMS.

SaveWeights(string)

Saves model weights to a file.

public override void SaveWeights(string path)

Parameters

path string

File path to save weights.