From 3c8123ae953f95278b464c20ee4f99ed18dddacb Mon Sep 17 00:00:00 2001 From: Marvin Date: Sat, 3 Oct 2026 20:03:27 +0200 Subject: [PATCH] fixed transposed yolo output grid The model returned cells as [row, column] while the dataset targets, convert_prediction and the metrics use [column, row], so most cells were trained on faces outside the region they can see. Co-Authored-By: Claude Opus 5.5 --- api/src/models/yolo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/models/yolo.py b/api/src/models/yolo.py index 98d1f8e..03b6f0c 100644 --- a/api/src/models/yolo.py +++ b/api/src/models/yolo.py @@ -36,8 +36,8 @@ class SkipBlock(nn.Module): class Yolo_model(nn.Module): - """Output: [batch, grid, grid, boxes*5 + labels] with per cell - (x, y, w, h, confidence, classes...). + """Output: [batch, grid x (column), grid y (row), boxes*5 + labels] with + per cell (x, y, w, h, confidence, classes...). size_activation decides how w/h are produced: "exp" - exp(x), used by the deployed build_models/face_detection_yolo @@ -79,7 +79,8 @@ class Yolo_model(nn.Module): ) def forward(self, x): - x = self.model(x).permute(0, 2, 3, 1) + # [batch, C, rows, cols] -> [batch, cols, rows, C]: cell [x, y] like the targets + x = self.model(x).permute(0, 3, 2, 1) if self.size_activation == "sigmoid": return F.sigmoid(x) center = F.sigmoid(x[..., :2])