jagin
(Jarosław Gilewski)
January 29, 2019, 3:11pm
1
Hi,
If I run for example
learn = create_cnn(data, models.resnet18, metrics=accuracy)
the model is loaded into /root/.torch/models as it is shown here:
Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /root/.torch/models/resnet18-5c106cde.pth 100%|██████████| 46827520/46827520 [00:00<00:00, 73938844.51it/s]
My question is: can I change the directory where the model is loaded?
Regards
Jarek
jagin
(Jarosław Gilewski)
January 30, 2019, 7:56am
3
I have ~/.fastai/config.yml
setup so the data and model are loaded into the /workspace/fastai/data
and /workspace/fastai/model
respectively.
It works properly for path = untar_data(URLs.PETS); path
for example. The result is PosixPath('/workspace/fastai/data/oxford-iiit-pet')
but still create_cnn
loads the model into ~/.torch/models/
gamo
(Gabriel)
January 30, 2019, 8:37am
4
You can override the default pytorch model_dir by changing the env variable,
os.environ['TORCH_MODEL_ZOO'] = '<path>'
2 Likes
jagin
(Jarosław Gilewski)
January 30, 2019, 8:47am
5
That’s what I need. Thank you!
AlexeyRB
(Alexey)
January 30, 2019, 9:32pm
6
You can also use os.rename(old_path, new_path) if your files are uploaded incorrectly. This will move your files to the new directory. For example:
folders = [‘black’, ‘teddys’, ‘grizzly’]
files = [‘urls_black.csv’, ‘urls_teddys.csv’, ‘urls_grizzly.csv’]
for folder, file in zip(folders, files):
path = ‘data/bears’
os.rename(os.path.join(os.getcwd(), file),
os.path.join(os.getcwd(), path, file))
gil3co
(Gil Cohen)
December 26, 2019, 10:47am
7
Great advice!
Please notice that “TORCH_MODEL_ZOO” is deprecated, use “TORCH_HOME” instead.
1 Like