TextSnake.pytorch icon indicating copy to clipboard operation
TextSnake.pytorch copied to clipboard

How to introduce resnet50 backbone?

Open white2018 opened this issue 5 years ago • 5 comments

@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

white2018 avatar Oct 24 '19 13:10 white2018

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!

princewang1994 avatar Oct 25 '19 02:10 princewang1994

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])

white2018 avatar Oct 26 '19 03:10 white2018

have you solved it ?

CXinXinGo avatar Dec 12 '19 11:12 CXinXinGo

have you solved it ?

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

white2018 avatar Dec 12 '19 15:12 white2018

Thanks for your prompt reply.

CXinXinGo avatar Dec 13 '19 13:12 CXinXinGo