专栏相关代码:目前售价售价69.9,改进点80+
专栏介绍:YOLOv9改进系列 | 包含深度学习最新创新,助力高效涨点!!!
1. SPPELAN
SPPELAN是YOLOv9作者在SPPF的基础上创新的模块(增加了一次最大池化),整体结构及代码如下,代码中SP模块即为最大池化。
class SP(nn.Module):def __init__(self, k=3, s=1):super(SP, self).__init__()self.m = nn.MaxPool2d(kernel_size=k, stride=s, padding=k // 2)def forward(self, x):return self.m(x)class SPPELAN(nn.Module):# spp-elandef __init__(self, c1, c2, c3): # ch_in, ch_out, number, shortcut, groups, expansionsuper().__init__()self.c = c3self.cv1 = Conv(c1, c3, 1, 1)self.cv2 = SP(5)self.cv3 = SP(5)self.cv4 = SP(5)self.cv5 = Conv(4*c3, c2, 1, 1)def forward(self, x):y = [self.cv1(x)]y.extend(m(y[-1]) for m in [self.cv2, self.cv3, self.cv4])return self.cv5(torch.cat(y, 1))