def __init__(self, inchannels): super(FiveStr, self).__init__() self.five_str = nn.ModuleList([ Conv_BN_Act(inchannels, inchannels // 2, kernel_size=1, stride=1, activation='leaky'), Conv_BN_Act(inchannels // 2, inchannels, kernel_size=3, stride=1, activation='leaky'), Conv_BN_Act(inchannels, inchannels // 2, kernel_size=1, stride=1, activation='leaky'), Conv_BN_Act(inchannels // 2, inchannels, kernel_size=3, stride=1, activation='leaky'), Conv_BN_Act(inchannels, inchannels // 2, kernel_size=1, stride=1, activation='leaky') ])
def __init__(self, in_channels, per_anchors, outs): super(OUTPUT, self).__init__() self.conv1 = Conv_BN_Act(in_channels, in_channels * 2, 3, 1, 'leaky') self.conv2 = nn.Conv2d(in_channels * 2, per_anchors * outs, kernel_size=1, stride=1)
def __init__(self, in_channels=512): super(PANUP2, self).__init__() self.conv1 = Conv_BN_Act(in_channels, in_channels // 2, 1, 1, 'leaky') self.five_s = FiveStr(in_channels) self.upsample = UPSAMPLE(in_channels // 2)
def __init__(self, in_channels=1024): super(PANUP1, self).__init__() self.conv1 = Conv_BN_Act(in_channels, in_channels // 2, 1, 1, 'leaky') self.conv2 = Conv_BN_Act(in_channels // 2, in_channels, 3, 1, 'leaky') self.spp = SPP(in_channels) self.conv3 = Conv_BN_Act(in_channels * 2, in_channels // 2, 1, 1, 'leaky') self.conv4 = Conv_BN_Act(in_channels // 2, in_channels, 3, 1, 'leaky') self.conv5 = Conv_BN_Act(in_channels, in_channels // 2, 1, 1, 'leaky') self.upsample = UPSAMPLE(in_channels // 2)
def __init__(self, in_channels): super(DOWNSAMPLE, self).__init__() self.down = Conv_BN_Act(in_channels, in_channels * 2, kernel_size=3, stride=2, activation='leaky')
def __init__(self, in_channels): super(UPSAMPLE, self).__init__() self.conv1 = Conv_BN_Act(in_channels, in_channels // 2, kernel_size=1, stride=1, activation='leaky')
def __init__(self, in_channels): super(SPP, self).__init__() self.spp_head = Conv_BN_Act(in_channels, in_channels // 2, kernel_size=1, stride=1, activation='leaky') # #SPP层 self.spp_body1 = nn.MaxPool2d(kernel_size=13, stride=1, padding=13 // 2) self.spp_body2 = nn.MaxPool2d(kernel_size=9, stride=1, padding=9 // 2) self.spp_body3 = nn.MaxPool2d(kernel_size=5, stride=1, padding=5 // 2)
def __init__(self, anchors, num_bbparas, num_classes, freeze=False): super(YOLOBODY, self).__init__() self.darknet53 = Darknet53(freeze=freeze) self.panup1 = PANUP1() self.five_d32 = FiveStr(inchannels=1024) self.outs1 = OUTPUT(in_channels=512, per_anchors=anchors // 3, outs=num_bbparas + 1 + num_classes) self.panup2 = PANUP2() self.pandown2 = PANDOWN2() self.convd16 = Conv_BN_Act(512, 256, 1, 1, 'leaky') self.outs2 = OUTPUT(in_channels=256, per_anchors=anchors // 3, outs=num_bbparas + 1 + num_classes) self.pandown1 = PANDOWN1() self.outs3 = OUTPUT(in_channels=128, per_anchors=anchors // 3, outs=num_bbparas + 1 + num_classes)
def __init__(self, in_channels=256): super(PANDOWN1, self).__init__() self.conv1 = Conv_BN_Act(in_channels, in_channels // 2, 1, 1, 'leaky') self.conv2 = FiveStr(in_channels) self.down1 = DOWNSAMPLE(in_channels=128)