My Image segmentation result map contains black lattice in in the white patch

China☆狼群 提交于 2019-12-13 13:27:26

问题


I'm doing an image segmentation with UNet-like CNN architecture by Pytorch 0.4.0.It mark foreground as 1 and background as 0 in the final segmentation result.I use a pre-trained VGG's feature extractor as my encoder, so I need to upsampling the encoder output many times.But the result shows a weird lattice parttern in the result like this:

I suspect these different shape of black parttern were caused by the deconvolutional layers.It's said that deconv layer add (s-1) zeros between the input pixel in the official documentation.the deconvolutional layer's hyperparameter are listed below:

kernel_size=3,stride=2,padding=1,output_padding=1

(the output_padding is used to fit the skip connection feature size, for instance, with a input size 40*30,I want it size enlarge twice in one deconvolutional layer,under my calculation with the formula:out=s(in-1)+k-2p,I must use padding 1 and output-padding 1 to keep size,or there might be other better choice I don’t know.)

I'm wondering the reason that generate the black lattice.They looks like a grid or square parttern.And how to solve it.Besides,I need to adjust all deconv layer hyperparamater to one uniform or modify them separately?

environment:Ubuntu 16.04,Pytorch 0.4.0,GTX 1080Ti, the architecture of upsampling is three deconv layer,they are one after another.

Update

after I modified the deconv hyperparameter,(inspired by noise in image segmentation result use

kernel_size=4,stride=2,padding=1

thus to avoid output-padding and satisfy the size.But after 100 epoch I met similiar problem.

after another 30 epoch training, it seems like this,

the black points just scattered,It seems these black points just change their parttern and jump into another parttern,I don't know why it occurs.I'm don't know how to modify my network hyperparameter.
self.conv1=Basic(1024,512,kernel_size=3,stride=1,padding=1)
        self.conv2=Basic(512,512,kernel_size=3,stride=1,padding=1)
        self.deconv1=Basic(512,256,kernel_size=4,stride=2,conv=False,padding=1)
        self.deconv2=Basic(256,128,kernel_size=4,stride=2,conv=False,padding=1)
        self.deconv3=Basic(128,64,kernel_size=4,stride=2,conv=False,padding=1)
        #output  480*640 segmap
        self.conv4=Basic(64,2,kernel_size=1,stride=1)
        # self.avgpool=nn.AvgPool2d(kernel_size=2,stride=2)

    def forward(self, input):
        input=self.conv1(input)
        input=self.conv2(input)
        input=self.deconv1(input)
        input=self.deconv2(input)
        input=self.deconv3(input)
        input=self.conv4(input)
        # print(input.shape)
        #a channel-wise probability map
        raw=input
        return raw`

来源:https://stackoverflow.com/questions/51145527/my-image-segmentation-result-map-contains-black-lattice-in-in-the-white-patch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!