diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index d25836a01a6..2fa99db357a 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.1.34" +__version__ = "8.1.35" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld diff --git a/ultralytics/nn/modules/block.py b/ultralytics/nn/modules/block.py index a263b603564..ca991f6e090 100644 --- a/ultralytics/nn/modules/block.py +++ b/ultralytics/nn/modules/block.py @@ -171,10 +171,9 @@ def __init__(self, c1, c2, k=5): def forward(self, x): """Forward pass through Ghost Convolution block.""" - x = self.cv1(x) - y1 = self.m(x) - y2 = self.m(y1) - return self.cv2(torch.cat((x, y1, y2, self.m(y2)), 1)) + y = [self.cv1(x)] + y.extend(self.m(y[-1]) for _ in range(3)) + return self.cv2(torch.cat(y, 1)) class C1(nn.Module): @@ -555,40 +554,27 @@ def forward(self, x, w): return x * self.logit_scale.exp() + self.bias -class RepBottleneck(nn.Module): +class RepBottleneck(Bottleneck): """Rep bottleneck.""" def __init__(self, c1, c2, shortcut=True, g=1, k=(3, 3), e=0.5): """Initializes a RepBottleneck module with customizable in/out channels, shortcut option, groups and expansion ratio. """ - super().__init__() + super().__init__(c1, c2, shortcut, g, k, e) c_ = int(c2 * e) # hidden channels self.cv1 = RepConv(c1, c_, k[0], 1) - self.cv2 = Conv(c_, c2, k[1], 1, g=g) - self.add = shortcut and c1 == c2 - - def forward(self, x): - """Forward pass through RepBottleneck layer.""" - return x + self.cv2(self.cv1(x)) if self.add else self.cv2(self.cv1(x)) -class RepCSP(nn.Module): +class RepCSP(C3): """Rep CSP Bottleneck with 3 convolutions.""" def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): """Initializes RepCSP layer with given channels, repetitions, shortcut, groups and expansion ratio.""" - super().__init__() + super().__init__(c1, c2, n, shortcut, g, e) c_ = int(c2 * e) # hidden channels - self.cv1 = Conv(c1, c_, 1, 1) - self.cv2 = Conv(c1, c_, 1, 1) - self.cv3 = Conv(2 * c_, c2, 1) # optional act=FReLU(c2) self.m = nn.Sequential(*(RepBottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n))) - def forward(self, x): - """Forward pass through RepCSP layer.""" - return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), 1)) - class RepNCSPELAN4(nn.Module): """CSP-ELAN."""