Skip to content

Commit

Permalink
Add missing Python function docstrings (#13105)
Browse files Browse the repository at this point in the history
* Add missing Python function docstrings

* Auto-format by https://ultralytics.com/actions

---------

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 19, 2024
1 parent cf8933c commit ec331cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions utils/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit ec331cb

Please sign in to comment.