Class YOLOv9<T>
- Namespace
- AiDotNet.ComputerVision.Detection.ObjectDetection.YOLO
- Assembly
- AiDotNet.dll
YOLOv9 object detector with Programmable Gradient Information (PGI).
public class YOLOv9<T> : ObjectDetectorBase<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
YOLOv9<T>
- Inherited Members
Remarks
For Beginners: YOLOv9 introduces Programmable Gradient Information (PGI) and Generalized Efficient Layer Aggregation Network (GELAN) to address information loss during feature transformation, achieving state-of-the-art performance.
Key features: - PGI: Programmable Gradient Information for better gradient flow - GELAN: Generalized ELAN for efficient feature aggregation - Auxiliary reversible branch for improved training - Better information preservation through the network
Reference: Wang et al., "YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information", 2024
Constructors
YOLOv9(ObjectDetectionOptions<T>)
Creates a new YOLOv9 detector.
public YOLOv9(ObjectDetectionOptions<T> options)
Parameters
optionsObjectDetectionOptions<T>Detection options.
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.