Merge branch 'master' into main

pull/12706/head
Ultralytics Assistant 2024-06-19 02:29:45 +02:00 committed by GitHub
commit f92bd0be93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -242,13 +242,14 @@ class DetectionModel(BaseModel):
# 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

View File

@ -23,6 +23,7 @@ try:
except ImportError:
def SummaryWriter(*args):
"""Fall back to SummaryWriter returning None if TensorBoard is not installed."""
return None # None = SummaryWriter(str)