Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSPNet final conv #29

Closed
nklein23 opened this issue Dec 2, 2018 · 5 comments
Closed

PSPNet final conv #29

nklein23 opened this issue Dec 2, 2018 · 5 comments

Comments

@nklein23
Copy link

nklein23 commented Dec 2, 2018

Hi qubvel,

are you sure that the final conv layer of your PSPNet implementation is correct?

model = PSPNet(backbone_name = 'resnet18',
               final_interpolation = 'bilinear',
               encoder_weights = 'imagenet',
               freeze_encoder = False,
               input_shape = (384, 384, 3),
               classes = 1,
               activation = 'sigmoid',
               use_batchnorm = True,
               downsample_factor = 8, 
               psp_pooling_type = 'avg',
               psp_conv_filters = 256,
               dropout = 0.5)

yields for the last couple of layers:


concatenate_1 (Concatenate) (None, 48, 48, 1152) 0 stage3_unit1_relu1[0][0]
resize_image_1[0][0]
resize_image_2[0][0]
resize_image_3[0][0]
resize_image_4[0][0]


conv_block_conv (Conv2D) (None, 48, 48, 512) 589824 concatenate_1[0][0]


conv_block_bn (BatchNormalizati (None, 48, 48, 512) 2048 conv_block_conv[0][0]


conv_block_relu (Activation) (None, 48, 48, 512) 0 conv_block_bn[0][0]


spatial_dropout2d_1 (SpatialDro (None, 48, 48, 512) 0 conv_block_relu[0][0]


final_conv (Conv2D) (None, 48, 48, 1) 4609 spatial_dropout2d_1[0][0]


resize_image_5 (ResizeImage) (None, 384, 384, 1) 0 final_conv[0][0]


sigmoid (Activation) (None, 384, 384, 1) 0 resize_image_5[0][0]


conv_block_conv has 589.824 params, I guess these originate from 512 1 * 1 * 1152 convolutions.
And final_conv (Conv2D) has 4609 params, likely constructed from 1 3 * 3 * 512 conv.
Shouldnt it be the other way around? conv_block_conv having 3 * 3 convs and the final layer having 1 * 1 convs? Sorry if I am mistaken here.

@qubvel
Copy link
Owner

qubvel commented Dec 5, 2018

Hi @NiklasDL
The most implementations od PSPNet I saw have (3,3) -> (1,1) final convolutions (like you describe), however (3,3) convolution have 9 times more params (500K -> 4,5M), so I decide to switch them and make something like bottleneck in ResNet models.

@qubvel
Copy link
Owner

qubvel commented Dec 5, 2018

P.S. If you would test both cases, please, let me know your results. Thanks. 😄

@nklein23
Copy link
Author

nklein23 commented Dec 5, 2018

Hi @qubvel

will take some time because my model trains for almost two weeks but I will let you know :)

@nklein23
Copy link
Author

nklein23 commented Feb 5, 2019

Hi @qubvel, the difference between both cases is slightly noticeable. Please find the results for both models for the same random subset of 200 test images (binary segmentation problem, IoU-threshold optimized results). The training data contains roughly 600k images.

"Wrong" final conv:
wrong_final-conv

"Corrected" final conv:
corrected_final_conv

@qubvel
Copy link
Owner

qubvel commented Feb 21, 2019

Hi @NiklasDL,
Thanks a lot for reporting results of your experiments! If difference is not noticeable I will leave it as it is.
Btw, I have mention your work in release note in CHANGELOG.md, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants