WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

RuntimeError: shape '[64, 12, 3, 3]' is invalid for input of size 292 #193

Open xiaoxioamu opened 2 years ago

xiaoxioamu commented 2 years ago

I have encountered this problem when I run test.py with below commands: 'python train.py --batch-size 8 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0 --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300'

Trackback is below: '''bash During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 319, in test(opt.data, File "test.py", line 71, in test load_darknet_weights(model, weights[0]) File "/home/liubang/Engineer/YoloR/models/models.py", line 698, in load_darknetweights conv.weight.data.copy(torch.from_numpy(weights[ptr:ptr + nw]).view_as(conv.weight)) RuntimeError: shape '[64, 12, 3, 3]' is invalid for input of size 292 ''' And same issue was encounter again when run train.py

jvnsg commented 2 years ago

same issue here! Have you found a solution? @xiaoxioamu

Model Summary: 665 layers, 79873400 parameters, 79873400 gradients, 113.473314200 GFLOPS
Traceback (most recent call last):
  File "test.py", line 67, in test
    ckpt = torch.load(weights[0], map_location=device)  # load checkpoint
  File "/opt/conda/lib/python3.6/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/opt/conda/lib/python3.6/site-packages/torch/serialization.py", line 762, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 330, in <module>
    save_conf=opt.save_conf,
  File "test.py", line 71, in test
    load_darknet_weights(model, weights[0])
  File "/yolor/models/models.py", line 698, in load_darknet_weights
    conv.weight.data.copy_(torch.from_numpy(weights[ptr:ptr + nw]).view_as(conv.weight))
RuntimeError: shape '[64, 12, 3, 3]' is invalid for input of size 292

issue occured while using the docker image.

jvnsg commented 2 years ago

@xiaoxioamu I found the solution! Just download the "xxx.pt"-file manually. Don't use the "bash scripts/get_pretrain.sh" skript. The link is in the bash "get_pretrain.sh" file. Just open it with a file editor and copy the url.