diff --git a/models/yolo.py b/models/yolo.py index 2f4bbe0f71d1..1cb72d5d489f 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -108,9 +108,9 @@ def __init__(self, cfg='yolov5s.yaml', ch=3, nc=None, anchors=None): # model, i m = self.model[-1] # Detect() if isinstance(m, Detect): s = 256 # 2x min stride + check_anchor_order(m) # must be in pixel-space (not grid-space) m.inplace = self.inplace m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward - check_anchor_order(m) # must be in pixel-space (not grid-space) m.anchors /= m.stride.view(-1, 1, 1) self.stride = m.stride self._initialize_biases() # only run once