Lesson 1 – Weights directory not found

When executing the notebook for lesson1-rxt50 I get this error:

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

I’m uncertain about how to get these files in the correct place. I’m using the fast.ai template in paperspace.

It’s possible that I deleted something by mistake, so does anybody know a way to restore the files to their original state or even the whole papaerspace machine?

1 Like

Actually we need to download the weights and place it in the proper directory…
Searching the forum might help…
files.fast.ai

1 Like

The specific commands that that fixed this for me were as follows:

Navigate to ~/fastai/courses/dl1/fastai/
wget http://files.fast.ai/models/weights.tgz
tar -xvzf weights.tgz

and then I was able to run:
arch = resnext101_64
learn = ConvLearner.pretrained(arch, data, precompute = True)

in my notebook without an error.

12 Likes

Thanks ianhi this helped.

Thank you, this helped me as well

Thanks, ianhi, this solved my problem. cheers!

In my case I also had to download and move the weights directory to virtualenv_name/lib/python3.6/site-packages/fastai/weights. It worked then.

I also ran into the same problem but even after downloading the weights file and placing it inthe appropriate directory and unzipping it i am still getting this error

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\khwaja wisal\Anaconda3\lib\site-packages\fastai/weights/resnext_101_64x4d.pth’
please help.
This is happening with any architecture i use i am getting this same error

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

~\Anaconda3\lib\site-packages\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

~\Anaconda3\lib\site-packages\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()]

~\Anaconda3\lib\site-packages\fastai\torch_imports.py in resnext50(pre)
54 @_fastai_model(‘ResNeXt 50’, ‘Aggregated Residual Transformations for Deep Neural Networks’,
55 ‘https://arxiv.org/abs/1611.05431’)
—> 56 def resnext50(pre): return load_pre(pre, resnext_50_32x4d, ‘resnext_50_32x4d’)
57
58 @_fastai_model(‘ResNeXt 101_32’, ‘Aggregated Residual Transformations for Deep Neural Networks’,

~\Anaconda3\lib\site-packages\fastai\torch_imports.py in load_pre(pre, f, fn)
30 m = f()
31 path = os.path.dirname(file)
—> 32 if pre: load_model(m, f’{path}/weights/{fn}.pth’)
33 return m
34

~\Anaconda3\lib\site-packages\fastai\torch_imports.py in load_model(m, p)
25 def children(m): return m if isinstance(m, (list, tuple)) else list(m.children())
26 def save_model(m, p): torch.save(m.state_dict(), p)
—> 27 def load_model(m, p): m.load_state_dict(torch.load(p, map_location=lambda storage, loc: storage))
28
29 def load_pre(pre, f, fn):

~\Anaconda3\lib\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: ‘C:\Users\khwaja wisal\Anaconda3\lib\site-packages\fastai/weights/resnext_50_32x4d.pth’