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 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 20:03:27 +02:00
co-authored by Claude Opus 5.5
parent 8edb0a1e55
commit 3c8123ae95
+4 -3
View File
@@ -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])