CSAILVision / semantic-segmentation-pytorch

Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset
http://sceneparsing.csail.mit.edu/
BSD 3-Clause "New" or "Revised" License
4.93k stars 1.1k forks source link

pickle.UnpicklingError: invalid load key, '<'. #110

Open meteorshowers opened 6 years ago

meteorshowers commented 6 years ago

Hi I run into this error with your suggested environment: pickle.UnpicklingError: invalid load key, '<'..

Full log is as below:

 guest@Monster  ~/lxy/semantic-segmentation-pytorch   master  python3 train.py 
Input arguments:
batch_size_per_gpu 2
workers          16
start_epoch      1
ckpt             ./ckpt
lr_encoder       0.02
imgSize          [300, 375, 450, 525, 600]
id               baseline
disp_iter        20
deep_sup_scale   0.4
epoch_iters      5000
imgMaxSize       1000
lr_pow           0.9
root_dataset     ./data/
padding_constant 8
segm_downsampling_rate 8
beta1            0.9
random_flip      True
list_val         ./data/validation.odgt
fix_bn           0
weights_encoder  
arch_encoder     resnet50_dilated8
num_gpus         8
seed             304
weights_decoder  
num_epoch        20
optim            SGD
fc_dim           2048
lr_decoder       0.02
list_train       ./data/train.odgt
arch_decoder     ppm_bilinear_deepsup
num_class        150
weight_decay     0.0001
Model ID: baseline-resnet50_dilated8-ppm_bilinear_deepsup-ngpus8-batchSize16-imgMaxSize1000-paddingConst8-segmDownsampleRate8-LR_encoder0.02-LR_decoder0.02-epoch20-decay0.0001-fixBN0
Traceback (most recent call last):
  File "train.py", line 314, in <module>
    main(args)
  File "train.py", line 149, in main
    weights=args.weights_encoder)
  File "/home/guest/lxy/semantic-segmentation-pytorch/models/models.py", line 105, in build_encoder
    orig_resnet = resnet.__dict__['resnet50'](pretrained=pretrained)
  File "/home/guest/lxy/semantic-segmentation-pytorch/models/resnet.py", line 198, in resnet50
    model.load_state_dict(load_url(model_urls['resnet50']), strict=False)
  File "/home/guest/lxy/semantic-segmentation-pytorch/models/resnet.py", line 232, in load_url
    return torch.load(cached_file, map_location=map_location)
  File "/usr/local/lib/python3.5/dist-packages/torch/serialization.py", line 358, in load
    return _load(f, map_location, pickle_module)
  File "/usr/local/lib/python3.5/dist-packages/torch/serialization.py", line 532, in _load
    magic_number = pickle_module.load(f)
_pickle.UnpicklingError: invalid load key, '<'.

Detailed configuration:

vjayd commented 5 years ago

Even i am having the same issue, anyone here can help me?

liuwei941213 commented 5 years ago

I am having the same issue,too.Have you solved it yet?

lyq893 commented 4 years ago

I am having the same issue,too.Have you solved it yet? I am having the same issue,too.Have you solved it yet?

onehahaha756 commented 4 years ago

I also encountered the same problem, but in the end I found it was a problem with my network. You can check your internet connection.

changesome commented 2 years ago

This error is caused by loading the wrong model file (*.pth). When you import backbone network files ( for example in this issue) ——

semantic-segmentation-pytorch/mit_semseg/models/resnet.py

Line 11-15 in this py file gives the url of Resnet models to download: model_urls = { 'resnet18': 'http://sceneparsing.csail.mit.edu/model/pretrained_resnet/resnet18-imagenet.pth', 'resnet50': 'http://sceneparsing.csail.mit.edu/model/pretrained_resnet/resnet50-imagenet.pth', 'resnet101': 'http://sceneparsing.csail.mit.edu/model/pretrained_resnet/resnet101-imagenet.pth' } If your computer fails to download these pth files, it will return some html files begins with '<' (which becomes the error you got)

Solution: download those pth files, and put them in the folder (model_dir) given by

semantic-segmentation-pytorch/mit_semseg/models/utils.py

line 10 :def load_url(url, model_dir='./pretrained', map_location=None):