Lesson 2 - Dog Breed

On this command:
learn = ConvLearner.pretrained(arch, data, precompute=True)

I’m getting this error which I cannot troubleshoot:

FileNotFoundError Traceback (most recent call last)
in
----> 1 learn = ConvLearner.pretrained(arch, data, precompute=True)

~/fastai/courses/dl1/fastai/conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, custom_head, precompute, pretrained, **kwargs)
111 pretrained=True, **kwargs):
112 models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg,
–> 113 ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut, custom_head=custom_head, pretrained=pretrained)
114 return cls(data, models, precompute, **kwargs)
115

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

~/fastai/courses/dl1/fastai/torch_imports.py in resnext101_64(pre)
75 @_fastai_model(‘ResNeXt 101_64’, ‘Aggregated Residual Transformations for Deep Neural Networks’,
76 ‘https://arxiv.org/abs/1611.05431’)
—> 77 def resnext101_64(pre): return load_pre(pre, resnext_101_64x4d, ‘resnext_101_64x4d’)
78
79 @_fastai_model(‘Wide Residual Networks’, ‘Wide Residual Networks’,

~/fastai/courses/dl1/fastai/torch_imports.py in load_pre(pre, f, fn)
43 m = f()
44 path = os.path.dirname(file)
—> 45 if pre: load_model(m, f’{path}/weights/{fn}.pth’)
46 return m
47

~/fastai/courses/dl1/fastai/torch_imports.py in load_model(m, p)
32 def save_model(m, p): torch.save(m.state_dict(), p)
33 def load_model(m, p):
—> 34 sd = torch.load(p, map_location=lambda storage, loc: storage)
35 names = set(m.state_dict().keys())
36 for n in list(sd.keys()): # list “detatches” the iterator

~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/serialization.py in load(f, map_location, pickle_module)
263 (sys.version_info[0] == 3 and isinstance(f, pathlib.Path)):
264 new_fd = True
–> 265 f = open(f, ‘rb’)
266 try:
267 return _load(f, map_location, pickle_module)

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/paperspace/fastai/courses/dl1/fastai/weights/resnext_101_64x4d.pth’

You need to download and unzip the pretrained model weights. Uncomment the bottom two lines in this cell as I did here and run it:
# If you haven't downloaded weights.tgz yet, download the file.
# "http://forums.fast.ai/t/error-when-trying-to-use-resnext50/7555"
# "http://forums.fast.ai/t/lesson-2-in-class-discussion/7452/222"
!wget -O fastai/weights.tgz http://files.fast.ai/models/weights.tgz
``
!tar xvfz fastai/weights.tgz -C fastai

1 Like