pub struct AnchorGrid {
pub cx: Vec<f32>,
pub cy: Vec<f32>,
pub strides: Vec<f32>,
pub n_anchors: usize,
}Expand description
Flattened anchor descriptors for all FPN levels.
Anchors are ordered level-by-level (stride 8 first, then 16, then 32), and within each level in row-major order (y, x).
Fields§
§cx: Vec<f32>Anchor centre x in input-image pixel coordinates. Shape: [A].
cy: Vec<f32>Anchor centre y in input-image pixel coordinates. Shape: [A].
strides: Vec<f32>Stride (scale factor from feature to input). Shape: [A].
n_anchors: usizeTotal number of anchors A.
Implementations§
Source§impl AnchorGrid
impl AnchorGrid
Sourcepub fn yolo26(img_h: usize, img_w: usize) -> Self
pub fn yolo26(img_h: usize, img_w: usize) -> Self
Build the anchor grid for YOLO26 given the input image dimensions.
img_h and img_w must be divisible by 32.
Sourcepub fn new(img_h: usize, img_w: usize, strides: &[usize]) -> Self
pub fn new(img_h: usize, img_w: usize, strides: &[usize]) -> Self
Build the anchor grid for arbitrary strides.
Sourcepub fn decode_ltrb_to_xywh(&self, ltrb: &[f32]) -> Vec<f32>
pub fn decode_ltrb_to_xywh(&self, ltrb: &[f32]) -> Vec<f32>
Decode raw LTRB predictions into absolute XYWH boxes.
Input ltrb: [4, A] channels-first — (l, t, r, b) distances.
Output: [4, A] channels-first — (cx, cy, w, h) in pixel coords.
Sourcepub fn decode_backward(&self, d_xywh: &[f32]) -> Vec<f32>
pub fn decode_backward(&self, d_xywh: &[f32]) -> Vec<f32>
Backward through the LTRB → XYWH decode.
d_xywh: [4, A] gradient w.r.t. decoded (cx, cy, w, h).
Returns: [4, A] gradient w.r.t. raw (l, t, r, b) predictions.