mvasil / fashion-compatibility

Learning Type-Aware Embeddings for Fashion Compatibility
BSD 3-Clause "New" or "Revised" License
152 stars 42 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 2: invalid start byte #23

Closed monajalal closed 3 years ago

monajalal commented 3 years ago
(fashcomp) [jalal@goku fashion-compatibility]$ python main.py --test --l2_embed --resume runs/nondisjoint_l2norm/model_best.pth.tar --datadir ../../../data/fashion/
/scratch3/venv/fashcomp/lib/python3.8/site-packages/torchvision/transforms/transforms.py:310: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  warnings.warn("The use of the transforms.Scale transform is deprecated, " +
Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /home/grad3/jalal/.cache/torch/hub/checkpoints/resnet18-5c106cde.pth
100.0%
=> loading checkpoint 'runs/nondisjoint_l2norm/model_best.pth.tar'
Traceback (most recent call last):
  File "main.py", line 312, in <module>
    main()    
  File "main.py", line 138, in main
    checkpoint = torch.load(args.resume)
  File "/scratch3/venv/fashcomp/lib/python3.8/site-packages/torch/serialization.py", line 608, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/scratch3/venv/fashcomp/lib/python3.8/site-packages/torch/serialization.py", line 787, in _legacy_load
    result = unpickler.load()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 2: invalid start byte
$ pip freeze
h5py==3.3.0
joblib==1.0.1
numpy==1.21.2
Pillow==8.3.1
scikit-learn==0.24.2
scipy==1.7.1
sklearn==0.0
threadpoolctl==2.2.0
torch==1.9.0
torchaudio==0.9.0
torchvision==0.10.0
typing-extensions==3.10.0.0

Will post the solution later.

monajalal commented 3 years ago

checkpoint = torch.load(args.resume, encoding='latin1')

added encoding='latin1' and it's working now.