def get_fusion_module(config, in_channels): layers = [] layers += [ BasicConv(in_channels=in_channels[0], out_channels=config[0][0], kernel_size=config[0][1], stride=config[0][2], padding=config[0][3]) ] layers += [ nn.Sequential( BasicConv(in_channels=in_channels[1], out_channels=config[1][0], kernel_size=config[1][1], stride=config[1][2], padding=config[1][3]), nn.PixelShuffle(upscale_factor=2)) ] layers += [ nn.Sequential( BasicConv(in_channels=in_channels[2], out_channels=config[2][0], kernel_size=config[2][1], stride=config[2][2], padding=config[2][3]), nn.PixelShuffle(upscale_factor=4)) ] return layers
def get_fusion_module(config, base, extras): layers = [] # conv4_3 layers += [ BasicConv(in_channels=base[24].out_channels, out_channels=config[0][0], kernel_size=config[0][1], stride=config[0][2], padding=config[0][3]) ] # fc_7 layers += [ nn.Sequential( BasicConv(in_channels=base[-2].out_channels, out_channels=config[1][0], kernel_size=config[1][1], stride=config[1][2], padding=config[1][3]), nn.PixelShuffle(upscale_factor=2)) ] layers += [ nn.Sequential( BasicConv(in_channels=extras[-2].out_channels, out_channels=config[2][0], kernel_size=config[2][1], stride=config[2][2], padding=config[2][3]), nn.PixelShuffle(upscale_factor=4)) ] return layers
def get_pyramid_module(config): layers = [] for layer in config: layers += [ BasicConv(in_channels=layer[0], out_channels=layer[1], kernel_size=layer[2], stride=layer[3], padding=layer[4]) ] return layers
def get_extras(config, in_channels, size, batch_norm=False): layers = [] for k, v in enumerate(config): if in_channels != 'S': if v == 'S': if in_channels == 256 and size == 512: layers += [BasicRFB(in_channels=in_channels, out_channels=config[k + 1], stride=2, scale=1.0, visual=1)] else: layers += [BasicRFB(in_channels=in_channels, out_channels=config[k + 1], stride=2, scale=1.0, visual=2)] else: layers += [BasicRFB(in_channels=in_channels, out_channels=v, scale=1.0, visual=2)] in_channels = v if size == 512: layers += [BasicConv(in_channels=256, out_channels=128, kernel_size=1, stride=1)] layers += [BasicConv(in_channels=128, out_channels=256, kernel_size=4, stride=1, padding=1)] elif size == 300: layers += [BasicConv(in_channels=256, out_channels=128, kernel_size=1, stride=1)] layers += [BasicConv(in_channels=128, out_channels=256, kernel_size=3, stride=1)] layers += [BasicConv(in_channels=256, out_channels=128, kernel_size=1, stride=1)] layers += [BasicConv(in_channels=128, out_channels=256, kernel_size=3, stride=1)] return layers