diff --git a/models/yolo.py b/models/yolo.py index ebd0e830296..d89c5da018d 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -242,13 +242,14 @@ def __init__(self, cfg="yolov5s.yaml", ch=3, nc=None, anchors=None): # Build strides, anchors m = self.model[-1] # Detect() if isinstance(m, (Detect, Segment)): - s = 256 # 2x min stride - m.inplace = self.inplace - def forward(x): + def _forward(x): + """Passes the input 'x' through the model and returns the processed output.""" return self.forward(x)[0] if isinstance(m, Segment) else self.forward(x) - m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward + s = 256 # 2x min stride + m.inplace = self.inplace + m.stride = torch.tensor([s / x.shape[-2] for x in _forward(torch.zeros(1, ch, s, s))]) # forward check_anchor_order(m) m.anchors /= m.stride.view(-1, 1, 1) self.stride = m.stride diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 1c2f4ccfb99..2bd8583d2ad 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -23,6 +23,7 @@ except ImportError: def SummaryWriter(*args): + """Fall back to SummaryWriter returning None if TensorBoard is not installed.""" return None # None = SummaryWriter(str)