def __init__(self, pretrained=True, reduction=2): super().__init__() self.densenet = dense.densenet121(pretrained=pretrained) self.conv1 = nn.Sequential(self.densenet.features.conv0, self.densenet.features.norm0, self.densenet.features.relu0, self.densenet.features.pool0) # 64,64 self.encoder2 = nn.Sequential( self.densenet.features.denseblock1, self.densenet.features.transition1) # 32,32 self.encoder3 = nn.Sequential( self.densenet.features.denseblock2, self.densenet.features.transition2) # 16,16 self.encoder4 = nn.Sequential( self.densenet.features.denseblock3, self.densenet.features.transition3) # 8,8 # self.encoder5 = nn.Sequential( # self.densenet.features.denseblock4 # )#16,16 self.scse1 = ModifiedSCSEBlock(64) self.scse2 = ModifiedSCSEBlock(128) self.scse3 = ModifiedSCSEBlock(256) self.scse4 = ModifiedSCSEBlock(512) # self.scse5 = ModifiedSCSEBlock(1024) # self.scse_center = ModifiedSCSEBlock(256) self.decoder5 = Decoder(256 + 256, 256, 64, reduction) self.decoder4 = Decoder(64 + 128, 128, 64, reduction) self.decoder3 = Decoder(64 + 64, 64, 64, reduction) self.decoder2 = Decoder(64, 32, 64, reduction) self.decoder1 = Decoder(64, 32, 64, reduction) self.center = nn.Sequential( ConvBn2d(512, 512, kernel_size=3, padding=1), nn.ReLU(inplace=True), ConvBn2d(512, 256, kernel_size=3, padding=1), nn.ReLU(inplace=True), # nn.MaxPool2d(kernel_size=2,stride=2) ) # 256,8,8 self.logit1 = nn.Sequential(nn.Conv2d(64, 1, kernel_size=1, padding=0)) self.logit2 = nn.Sequential(nn.Conv2d(64, 1, kernel_size=1, padding=0)) self.logit3 = nn.Sequential(nn.Conv2d(64, 1, kernel_size=1, padding=0)) self.logit4 = nn.Sequential(nn.Conv2d(64, 1, kernel_size=1, padding=0))
def __init__(self,pretrained=True,reduction=2): super().__init__() self.densenet = dense.densenet121(pretrained=pretrained) self.densenet2 = dense.densenet121(pretrained=pretrained) self.input_conv = nn.Sequential( self.densenet.features.conv0, self.densenet.features.norm0, self.densenet.features.relu0, #self.densenet.features.pool0 ) #64,64 self.denseBlocksDown1 = self.densenet.features.denseblock1 self.transDownBlocks1 = self.densenet.features.transition1 self.denseBlocksDown2 = self.densenet.features.denseblock2 self.transDownBlocks2 = self.densenet.features.transition2 self.denseBlocksDown3 = self.densenet.features.denseblock3 self.transDownBlocks3 = self.densenet.features.transition3 self.block = self.densenet.features.denseblock4 self.transUpBlocks3 = TransitionUp(1024+1024,256,1024) self.denseBlocksUp3 = self.densenet2.features.denseblock3 self.transUpBlocks2 = TransitionUp(1024+512,128,1024) self.denseBlocksUp2 = self.densenet2.features.denseblock2 self.transUpBlocks1 = TransitionUp(512+256,64,512) self.denseBlocksUp1 = self.densenet2.features.denseblock1 self.dout = nn.ConvTranspose2d(in_channels=256, out_channels=256, kernel_size=3, stride=2, padding=0,bias=True) self.scse1 = ModifiedSCSEBlock(128) self.scse2 = ModifiedSCSEBlock(256) self.scse3 = ModifiedSCSEBlock(512) self.scse4 = ModifiedSCSEBlock(1024) self.scse5 = ModifiedSCSEBlock(512) self.scse6 = ModifiedSCSEBlock(256) self.center_class = nn.Sequential( ConvBn2d(1024,256,kernel_size=3,padding=1), nn.ReLU(inplace=True), )#256,8,8 self.class_fuse_conv = nn.Sequential( ConvBn2d(256,64,kernel_size=1,padding=0), nn.ReLU(inplace=True) )#64,1,1 self.class_out = nn.Linear(64,1) self.seg_basefuse_conv = nn.Sequential( ConvBn2d(256,64,kernel_size=3,padding=1), nn.ReLU(inplace=True) )#64,128,128 self.seg_single_logit = nn.Conv2d(64,1,kernel_size=1,padding=0)