594422814 / UDT_pytorch

MIT License
192 stars 23 forks source link

'ascii' codec can't decode byte 0xd1 in position 0: ordinal not in range(128) #2

Closed ZLCQ closed 4 years ago

ZLCQ commented 5 years ago

Hi, When I ran the command 'python UDT.py --model ../train/work/checkpoint.pth.tar', some mistakes occurred:

Traceback (most recent call last): File "UDT.py", line 122, in net.load_param(args.model) File "/home/wy/UDT_pytorch/track/net.py", line 64, in load_param checkpoint = torch.load(path) File "/home/wy/.pyenv/versions/3.6.3/lib/python3.6/site-packages/torch/serialization.py", line 387, in load return _load(f, map_location, pickle_module, **pickle_load_args) File "/home/wy/.pyenv/versions/3.6.3/lib/python3.6/site-packages/torch/serialization.py", line 574, in _load result = unpickler.load() UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 0: ordinal not in range(128)

What can I do to fix this problem? Thanks

wtyuan96 commented 5 years ago

You can try to add the following code at the beginning of net.py:

from functools import partial
import pickle
pickle.load = partial(pickle.load, encoding="latin1")
pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
ZLCQ commented 5 years ago

It works,thank you very much.

Clannad000000 commented 5 years ago

I add the code in net.py, but there has other mistake occurs: Traceback (most recent call last): File "E:/Person_Tracking/TA/_Siamese/UDT/UDT_pytorch/track/UDT.py", line 123, in net.load_param(args.model) File "E:\Person_Tracking\TA_Siamese\UDT\UDT_pytorch\track\net.py", line 71, in load_param if 'module' in state_dict.keys()[0]: # train with nn.DataParallel TypeError: 'odict_keys' object does not support indexing What can I do to fix this problem? Thanks

swrdZWJ commented 5 years ago

you can modify _if 'module' in statedict.keys()[0]: to _if 'module' in list(statedict.keys())[0]: @Clannad000000