From ec331cbda7434f6c04c1c1c310dcb3948dcc5d3e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 19 Jun 2024 02:29:08 +0200 Subject: [PATCH] Add missing Python function docstrings (#13105) * Add missing Python function docstrings * Auto-format by https://ultralytics.com/actions --------- Co-authored-by: UltralyticsAssistant Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> --- models/yolo.py | 9 +++++---- utils/loggers/__init__.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/models/yolo.py b/models/yolo.py index ebd0e830296f..d89c5da018de 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 1c2f4ccfb99c..2bd8583d2ade 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)