Lesson-1-rxt50 : unpickling error

I just followed the instruction and tried to run this notebook, but ‘invalid load key’ error occurred.

Can anyone help me out here? Thank you!

UnpicklingError                           Traceback (most recent call last)
<ipython-input-21-32c252fefc13> in <module>()
  1 tfms = tfms_from_model(arch, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
  2 data = ImageClassifierData.from_paths(PATH, tfms=tfms, bs=bs, num_workers=4)
----> 3 learn = ConvLearner.pretrained(arch, data, precompute=True, ps=0.5)

~/fastai/courses/dl1/fastai/conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, custom_head, precompute, **kwargs)
 98     def pretrained(cls, f, data, ps=None, xtra_fc=None, xtra_cut=0, custom_head=None, precompute=False, **kwargs):
 99         models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg,
--> 100             ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut, custom_head=custom_head)
101         return cls(data, models, precompute, **kwargs)
102 

~/fastai/courses/dl1/fastai/conv_learner.py in __init__(self, f, c, is_multi, is_reg, ps, xtra_fc, xtra_cut, custom_head)
 36         else: cut,self.lr_cut = 0,0
 37         cut-=xtra_cut
---> 38         layers = cut_model(f(True), cut)
 39         self.nf = model_features[f] if f in model_features else (num_features(layers)*2)
 40         if not custom_head: layers += [AdaptiveConcatPool2d(), Flatten()]

~/fastai/courses/dl1/fastai/torch_imports.py in resnext50(pre)
 35     return children(load_pre(pre, InceptionV4, 'inceptionv4-97ef9c30'))[0]
 36 def inceptionresnet_2(pre): return load_pre(pre, InceptionResnetV2, 'inceptionresnetv2-d579a627')
---> 37 def resnext50(pre): return load_pre(pre, resnext_50_32x4d, 'resnext_50_32x4d')
 38 def resnext101(pre): return load_pre(pre, resnext_101_32x4d, 'resnext_101_32x4d')
 39 def resnext101_64(pre): return load_pre(pre, resnext_101_64x4d, 'resnext_101_64x4d')

~/fastai/courses/dl1/fastai/torch_imports.py in load_pre(pre, f, fn)
 29     m = f()
 30     path = os.path.dirname(__file__)
---> 31     if pre: load_model(m, f'{path}/models/{fn}.py')
 32     return m
 33 

~/fastai/courses/dl1/fastai/torch_imports.py in load_model(m, p)
 24 def children(m): return m if isinstance(m, (list, tuple)) else list(m.children())
 25 def save_model(m, p): torch.save(m.state_dict(), p)
---> 26 def load_model(m, p): m.load_state_dict(torch.load(p, map_location=lambda storage, loc: storage))
 27 
 28 def load_pre(pre, f, fn):

~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/serialization.py in load(f, map_location, pickle_module)
265         f = open(f, 'rb')
266     try:
--> 267         return _load(f, map_location, pickle_module)
268     finally:
269         if new_fd:

~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/serialization.py in _load(f, map_location, pickle_module)
408             f.seek(foffset)
409 
--> 410     magic_number = pickle_module.load(f)
411     if magic_number != MAGIC_NUMBER:
412         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '\x0a'.
2 Likes

any help?

I am also getting the same UnpicklingError. Does anyone have a solution?