Faster-rcnn.pytorch: ERROR: pytorch1.0 test size mismatch

Created on 22 Apr 2019  Â·  7Comments  Â·  Source: jwyang/faster-rcnn.pytorch

train on coco dataset:

python trainval_net.py --dataset coco --net vgg16 --bs 12 --nw 4 --lr 0.01 --lr_decay_step 1000 --cuda --mGPUs

then test:

python demo.py --net vgg16 --checksession 1 --checkepoch 8 --checkpoint 19543 --cuda --load_dir models --dataset coco

But I got the result:

load checkpoint models/vgg16/coco/faster_rcnn_1_8_19543.pth
Traceback (most recent call last):
  File "demo.py", line 195, in <module>
    fasterRCNN.load_state_dict(checkpoint['model'])
  File "/home/xuan/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 769, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for vgg16:
        size mismatch for RCNN_rpn.RPN_cls_score.weight: copying a param with shape torch.Size([24, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 512, 1, 1]).
        size mismatch for RCNN_rpn.RPN_cls_score.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([18]).
        size mismatch for RCNN_rpn.RPN_bbox_pred.weight: copying a param with shape torch.Size([48, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([36, 512, 1, 1]).
        size mismatch for RCNN_rpn.RPN_bbox_pred.bias: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([36]).
        size mismatch for RCNN_cls_score.weight: copying a param with shape torch.Size([81, 4096]) from checkpoint, the shape in current model is torch.Size([21, 4096]).
        size mismatch for RCNN_cls_score.bias: copying a param with shape torch.Size([81]) from checkpoint, the shape in current model is torch.Size([21]).
        size mismatch for RCNN_bbox_pred.weight: copying a param with shape torch.Size([324, 4096]) from checkpoint, the shape in current model is torch.Size([84, 4096]).
        size mismatch for RCNN_bbox_pred.bias: copying a param with shape torch.Size([324]) from checkpoint, the shape in current model is torch.Size([84]).

Most helpful comment

I went ahead and compared the config of my training, with the config of the demo... turns out there were some configs snuck in.. before the yaml file were loaded..

see this example.. https://github.com/jwyang/faster-rcnn.pytorch/blob/master/test_net.py#L118

double check, and fix your config to match how you trained and you should be gtg

All 7 comments

Hi, did you slove this problem? I also have the same question, can you help me?

Just had this issue as well... looks like the demo was hard coded to support VOC.. as per the README.md said...

did you properly modify the classes as mentioned?

even after I modify the class list, I get a smaller set of errors

I went ahead and compared the config of my training, with the config of the demo... turns out there were some configs snuck in.. before the yaml file were loaded..

see this example.. https://github.com/jwyang/faster-rcnn.pytorch/blob/master/test_net.py#L118

double check, and fix your config to match how you trained and you should be gtg

Good moring Yang:
Thanks for your help,I had fixed these problems which are caused by inconsistent of incoming scale parameters [4,8,16,32 ]and configuration parameters [8,16,32].
I am looking forward to exchange to you in the further work.

    Best regards
                                                                                                                                                                                                                                                           Yours   sincerely
                                                                                                                                                                                                                                                            Xiaobao YANG

[email protected]

From: Jianwei Yang
Date: 2019-05-04 03:39
To: jwyang/faster-rcnn.pytorch
CC: y78h11b09; Comment
Subject: Re: [jwyang/faster-rcnn.pytorch] ERROR: pytorch1.0 test size mismatch (#518)
Closed #518.
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

I was wondering how you work it out?I face with the same problem,could you give me some advice?

I knew how to work it out, modify the lib/model/utils/config.py line 295 as __C.ANCHOR_SCALES = [4,8,16,32],then the demo.py could be run successfully.

Sorry, I cannot answer your question right away for other things.
Congradutely to you for fixed the quesiton, firstly,. I do so same as you that i had modified the value of __C.ANCHOR_SCALES in the config.py.

[email protected]

From: LYH-YNU
Date: 2019-07-20 16:06
To: jwyang/faster-rcnn.pytorch
CC: y78h11b09; Comment
Subject: Re: [jwyang/faster-rcnn.pytorch] ERROR: pytorch1.0 test size mismatch (#518)
I knew how to work it out, modify the lib/model/utils/config.py line 295 as __C.ANCHOR_SCALES = [4,8,16,32],then the demo.py could be run successfully.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manoja328 picture manoja328  Â·  3Comments

gayathrimahalingam picture gayathrimahalingam  Â·  3Comments

hiroponnn picture hiroponnn  Â·  4Comments

ZhangJiajun1995 picture ZhangJiajun1995  Â·  5Comments

wanghan0501 picture wanghan0501  Â·  4Comments