aliyun / conditional-lane-detection

Apache License 2.0
386 stars 89 forks source link

TuSimple Test: The model and loaded state dict do not match exactly. #16

Open bsangee08 opened 3 years ago

bsangee08 commented 3 years ago

I tried to use the pretrained model 'tusimple_large' to test and I'm running into this error.

Command used to test

python tools/condlanenet/tusimple/test_tusimple.py configs/condlanenet/tusimple/tusimple_large_test.py '/content/gdrive/MyDrive/LaneDetection/tusimple_large.pth' --show --show_dst '/content/showPath' --result_dst '/content/result'

Error:

The model and loaded state dict do not match exactly

size mismatch for bbox_head.mlp.layers.0.weight: copying a param with shape torch.Size([64, 200, 1]) from checkpoint, the shape in current model is torch.Size([64, 100, 1]). [ ] 0/2782, elapsed: 0s, ETA:Traceback (most recent call last): File "tools/condlanenet/tusimple/test_tusimple.py", line 236, in main() File "tools/condlanenet/tusimple/test_tusimple.py", line 232, in main crop_bbox=cfg.crop_bbox) File "tools/condlanenet/tusimple/test_tusimple.py", line 141, in single_gpu_test return_loss=False, rescale=False, thr=hm_thr, data) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/usr/local/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward return self.module(inputs[0], kwargs[0]) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/content/gdrive/My Drive/LaneDetection/conditional-lane-detection/mmdet/models/detectors/condlanenet.py", line 329, in forward return self.forward_test(img, img_metas, kwargs) File "/content/gdrive/My Drive/LaneDetection/conditional-lane-detection/mmdet/models/detectors/condlanenet.py", line 369, in forward_test kwargs['thr']) File "/content/gdrive/My Drive/LaneDetection/conditional-lane-detection/mmdet/models/dense_heads/condlanenet_head.py", line 444, in forward_test masks = self.mask_head(mask_branch, mask_params, num_ins) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/content/gdrive/My Drive/LaneDetection/conditional-lane-detection/mmdet/models/dense_heads/condlanenet_head.py", line 119, in forward x = torch.cat([locations, x], dim=1) RuntimeError: Sizes of tensors must match except in dimension 2. Got 80 and 40 (The offending index is 0)

Please help me figure out what is wrong.

Thanks in advance.

bsangee08 commented 3 years ago

Dataset path:

TuSimple Dataset installation as mentioned in dataset.md was confusing as the directory structure I got was different from what is mentioned in the installation when I ran the code. So I made dataset root to point to my tusimple-test.

Am I facing the issue due to this?

Gooddz1 commented 3 years ago

求指导

Gooddz1 commented 3 years ago

解决了吗

h-somehow commented 3 years ago

I meet the same question.

After debugging, I found that locations.shape is (1, 1 40, 100) and x.shape is (1, 64, 80, 200) and locations.shape is decided by /conditional-lane-detection/configs/condlanenet/tusimple/ tusimple_large_train.py :72 location_configs=dict(size=(batch_size, 1, 40, 100), device='cuda:0'))

so, I changed it to location_configs=dict(size=(batch_size, 1, 80, 200), device='cuda:0')) to match the size. And the result seems to be correct.

[{"name":"Accuracy","value":0.9654015183,"order":"desc"},{"name":"FP","value":0.0200934579,"order":"asc"},{"name":"FN","value":0.0350167745,"order":"asc"},{"name":"F1","value":0.9723876298,"order":"asc"}]

By the way , neither the smalll size nor medium size model causes the error. If anyone have a clue about x.shape's change please tell me:smile:

Gooddz1 commented 3 years ago

I meet the same question.

After debugging, I found that locations.shape is (1, 1 40, 100) and x.shape is (1, 64, 80, 200) and locations.shape is decided by /conditional-lane-detection/configs/condlanenet/tusimple/ tusimple_large_train.py :72 location_configs=dict(size=(batch_size, 1, 40, 100), device='cuda:0'))

so, I changed it to location_configs=dict(size=(batch_size, 1, 80, 200), device='cuda:0')) to match the size. And the result seems to be correct.

[{"name":"Accuracy","value":0.9654015183,"order":"desc"},{"name":"FP","value":0.0200934579,"order":"asc"},{"name":"FN","value":0.0350167745,"order":"asc"},{"name":"F1","value":0.9723876298,"order":"asc"}]

By the way , neither the smalll size nor medium size model causes the error. If anyone have a clue about x.shape's change please tell me😄 非常感谢,还有个问题 怎么输出它的性能指标 [{"name":"Accuracy","value":0.9654015183,"order":"desc"},{"name":"FP","value":0.0200934579,"order":"asc"},{"name":"FN","value":0.0350167745,"order":"asc"},{"name":"F1","value":0.9723876298,"order":"asc"}]