DetrSetLossOptions

Options & Configuration · AiDotNet.ComputerVision.Detection.Losses

Weights and classification form for a DETR-family set prediction loss.

For Beginners

Training a set detector happens in two steps. First each real object is paired with one prediction using the matching costs. Then the paired predictions are pushed toward their objects using the loss weights. These options control both steps.

How It Works

Matching costs and loss weights are separate, because the published recipes differ between them: DINO (Zhang et al. 2022, Table 8) and RT-DETR (Zhao et al. 2023, Table A) both match with class cost 2, L1 cost 5 and GIoU cost 2, but train with class weight 1, L1 weight 5 and GIoU weight 2. The factory methods return each paper’s defaults; every value can be overridden.

Constructors

Constructor Summary
DetrSetLossOptions()

Properties

Property Summary
SetPredictionClassificationLoss ClassificationLoss { get; set; } How candidate class scores are trained.
double ClassCostWeight { get; set; } Weight of the classification term in the matching cost.
double ClassLossWeight { get; set; } Weight of the classification loss.
double FocalAlpha { get; set; } The alpha of the focal or varifocal classification loss.
double FocalGamma { get; set; } The gamma (focusing exponent) of the focal or varifocal classification loss.
double GIoUCostWeight { get; set; } Weight of the negative generalized IoU in the matching cost.
double GIoULossWeight { get; set; } Weight of the matched generalized IoU box loss.
double L1CostWeight { get; set; } Weight of the L1 box distance in the matching cost.
double L1LossWeight { get; set; } Weight of the matched center-format L1 box loss.
double MatchingFocalAlpha { get; set; } The alpha of the focal classification matching cost used with sigmoid heads.
double MatchingFocalGamma { get; set; } The gamma of the focal classification matching cost used with sigmoid heads.
double NoObjectWeight { get; set; } Relative weight of the no-object class in softmax cross-entropy (DETR uses 0.1).

Methods

Method Summary
DetrSetLossOptions ForDetr() DETR defaults: softmax cross-entropy, no-object weight 0.1, costs and weights 1/5/2.
DetrSetLossOptions ForDino() DINO defaults: sigmoid focal loss (alpha 0.25, gamma 2), costs 2/5/2, weights 1/5/2.
DetrSetLossOptions ForRtDetr() RT-DETR defaults: varifocal loss (alpha 0.75, gamma 2), costs 2/5/2, weights 1/5/2.