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

How to introduce resnet50 backbone? #37

Open
white2018 opened this issue Oct 24, 2019 · 5 comments
Open

How to introduce resnet50 backbone? #37

white2018 opened this issue Oct 24, 2019 · 5 comments

Comments

@white2018
Copy link

@princewang1994 Thanks for your excellent implementation.

I have tried vgg16 backbone. However, I suppose the resnet50 backbone is better than vgg16 in this case. How to support resnet50 backbone in the textnet.py?

Thanks

@princewang1994
Copy link
Owner

Thank you for your praise! I have not tried resnet50 yet(network/resnet is an incomplete version), if you are going to do this, try importing resnet into textnet.py. In the textnet.py I had prepared resnet related code here.

BTW, if you have got better performance, welcome pull request!

@white2018
Copy link
Author

Thank you for your praise! I have not tried resnet50 yet(network/resnet is an incomplete version), if you are going to do this, try importing resnet into textnet.py. In the textnet.py I had prepared resnet related code here.

BTW, if you have got better performance, welcome pull request!

Thanks for your prompt reply.

Actually, I have tried to introduce your resnet.py in textnet.py. However, I did not work it out.

Here is the detail. the resnet code snippet in textnet.py is as follows

        self.backbone = ResNet50(pretrained=self.is_training)

        self.deconv5 = nn.ConvTranspose2d(2048, 256, kernel_size=4, stride=2, padding=1)
        self.merge4 = Upsample(1024 + 256, 128)
        self.merge3 = Upsample(512 + 128, 64)
        self.merge2 = Upsample(256 + 64, 32)
        self.merge1 = Upsample(128 + 32, 16) # WRONG in merge1

I run it and error happens in 'up1 = self.merge1(C1, up2)', like 'RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 256 and 128 in dimension 2'

I suppose the reason is that C1 of resnet.py is different that of vgg.py, which leads to error.

python resnet.py
torch.Size([4, 64, 128, 128]) # here is 128
torch.Size([4, 256, 128, 128])
torch.Size([4, 512, 64, 64])
torch.Size([4, 1024, 32, 32])
torch.Size([4, 2048, 16, 16])

python vgg.py
torch.Size([4, 64, 256, 256]) # here is 256
torch.Size([4, 128, 128, 128])
torch.Size([4, 256, 64, 64])
torch.Size([4, 512, 32, 32])
torch.Size([4, 512, 16, 16])

@CXinXinGo
Copy link

have you solved it ?

@white2018
Copy link
Author

have you solved it ?

not yet. However, vgg16 in this case still works fine.

@CXinXinGo
Copy link

Thanks for your prompt reply.

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

3 participants