赞
踩
看了迪导给yolov5网络更换主干网络ShuffleNetv2的操作后,跟着他的操作步骤更换了我自己正在学习的yolov5网络的主干,并在最后用改过后的网络跑了一下自己的数据集。以下是修改步骤:
要更换网络首先得在common.py文件中添加函数,添加的代码如下:
- def channel_shuffle(x, groups):
- batchsize, num_channels, height, width = x.data.size()
- channels_per_group = num_channels // groups
- x = x.view(batchsize, groups, channels_per_group, height, width)
- x = torch.transpose(x, 1, 2).contiguous()
- x = x.view(batchsize, -1, height, width)
- return x
-
- class CBRM(nn.Module):
- def __init__(self, c1, c2):
- super(CBRM, self).__init__()
- self.conv = nn.Sequential(
- nn.Conv2d(c1, c2, kernel_size=3, stride=2, padding=1, bias=False),
- nn.BatchNorm2d(c2),
- nn.ReLU(inplace=True),
- )
- self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
-
- def forward
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。