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.99k stars 521 forks source link

inference another models like yolor_W6,E6,D6 error #105

Closed ehdrndd closed 2 years ago

ehdrndd commented 2 years ago

Detecting with yolor_p6 is fine.

But, another models like 'yolor_W6,E6,D6'

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\KANG\anaconda3\envs\OD\lib\site-packages\torch\serialization.py", line 594, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "C:\Users\KANG\anaconda3\envs\OD\lib\site-packages\torch\serialization.py", line 853, in _load result = unpickler.load() ModuleNotFoundError: No module named 'models.yolo'

I guess W6,E6,D6 is saved by torch 1.4. but now i using torch 1.7

Is there any solution not downgrading torch?

WongKinYiu commented 2 years ago

all of p6, w6, e6, and d6 are saved by either pytorch 1.8.0a0+52ea372 or 1.9.0a0+df837d0.

but models.yolo means ./models/yolo.py, it can be find in the repository.

ehdrndd commented 2 years ago

Thanks. but, i still don't know solution..

In debug mode.. print(torch.load('yolor_w6.pt', map_location=device)['model'])

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\KANG\anaconda3\envs\OD\lib\site-packages\torch\serialization.py", line 594, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "C:\Users\KANG\anaconda3\envs\OD\lib\site-packages\torch\serialization.py", line 853, in _load result = unpickler.load() ModuleNotFoundError: No module named 'models.yolo'

print(torch.load('yolor_p6.pt', map_location=device)['model'])

OrderedDict([('module_list.1.Conv2d.weight', tensor([[[[ 7.08389e...='cuda:0')), ('module_list.1.BatchN...m2d.weight', tensor([2.45703, 1.7...='cuda:0')), ('module_list.1.BatchNorm2d.bias', tensor([ 3.51172, 3...='cuda:0')), ('module_list.1.BatchN...nning_mean', tensor([ 3.52287e-03...='cuda:0')), ('module_list.1.BatchN...unning_var', tensor([3.51715e-03,...='cuda:0')), ('module_list.1.BatchN...es_tracked', tensor(0, device='cuda:0')), ('module_list.2.Conv2d.weight', tensor([[[[ 7.91168e...='cuda:0')), ('module_list.2.BatchN...m2d.weight', tensor([1.27051, 1.7...='cuda:0')), ('module_list.2.BatchNorm2d.bias', tensor([ 1.19336, -2...='cuda:0')), ('module_list.2.BatchN...nning_mean', tensor([-1.83984, -0...='cuda:0')), ('module_list.2.BatchN...unning_var', tensor([ 2.45703, 0...='cuda:0')), ('module_list.2.BatchN...es_tracked', tensor(0, device='cuda:0')), ('module_list.3.Conv2d.weight', tensor([[[[ 0.00136]...='cuda:0')), ('module_list.3.BatchN...m2d.weight', tensor([1.99707, 2.0...='cuda:0')), ...])

And models/yolo.py.
I can't find in your repo..

WongKinYiu commented 2 years ago

https://github.com/WongKinYiu/yolor/blob/paper/models/yolo.py

maybe you are using code of main branch and weights of paper branch.

ehdrndd commented 2 years ago

Oh, you're right. thanks.

I moved paper branch. it works!

ShoaibSajid commented 2 years ago

https://github.com/WongKinYiu/yolor/blob/paper/models/yolo.py

maybe you are using code of main branch and weights of paper branch.

So we cannot use weights of paper branch in main branch and vice versa, even for our custom trained models ?

RizwanMunawar commented 2 years ago

https://github.com/WongKinYiu/yolor/blob/paper/models/yolo.py maybe you are using code of main branch and weights of paper branch.

So we cannot use weights of paper branch in main branch and vice versa, even for our custom trained models ?

Thanks, it worked. Yolor-p6 main branch weights: yolor-p6.pt Yolor-p6 paper branch weights: yolor_p6.pt