MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / SPPBottleneck

Class SPPBottleneck

yolox/models/network_blocks.py:122–144  ·  view source on GitHub ↗

Spatial pyramid pooling layer used in YOLOv3-SPP

Source from the content-addressed store, hash-verified

120
121
122class SPPBottleneck(nn.Module):
123 """Spatial pyramid pooling layer used in YOLOv3-SPP"""
124
125 def __init__(
126 self, in_channels, out_channels, kernel_sizes=(5, 9, 13), activation="silu"
127 ):
128 super().__init__()
129 hidden_channels = in_channels // 2
130 self.conv1 = BaseConv(in_channels, hidden_channels, 1, stride=1, act=activation)
131 self.m = nn.ModuleList(
132 [
133 nn.MaxPool2d(kernel_size=ks, stride=1, padding=ks // 2)
134 for ks in kernel_sizes
135 ]
136 )
137 conv2_channels = hidden_channels * (len(kernel_sizes) + 1)
138 self.conv2 = BaseConv(conv2_channels, out_channels, 1, stride=1, act=activation)
139
140 def forward(self, x):
141 x = self.conv1(x)
142 x = torch.cat([x] + [m(x) for m in self.m], dim=1)
143 x = self.conv2(x)
144 return x
145
146
147class CSPLayer(nn.Module):

Callers 2

make_spp_blockMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected