How to set file path

learn = cnn_learner(data, resnet34, metrics=error_rate)

I want to load the model with the file I have dowloaded from the website,
but I don’t konw whether the cnn_learner function has a parameter to set the file path

you can pass a path to the learner as such:

learn = cnn_learner(data, resnet34, path=path, metrics=error_rate)

To see the possible parameters in a learner run the following:
??cnn_learner

Now what this path is pointing to is a different story. I am using my local machine and therefore I like setting the file path to somewhere I can easily navigate to with the GUI – mainly to delete things that I do terribly :slight_smile:

Check if there’s a load method, learn.load, that you can use.


You need to set learn.path and learn.model_dir such that they allow you to point to the file containing the model you downloaded.

I hava downloaded the file resnet34-333f7ec4.pth to the path = ‘/Users/lc/Desktop/test/’

learn = cnn_learner(dls, resnet34, metrics = error_rate, path = path)

But it still downloads the file resnet34-333f7ec4.pth.

Are you using a local machine or working off a server?

I am a bit confused as to what you’re trying to do, are you trying to upload (unique) trained weights into a resnet34 architecture? the way you are calling it there – the cnn_learner call will be instantiated with the trained weights for imagenet.

@immarried’s suggestion should work. You could instantiate it with normal imagenet weights like you are trying and then call learn.load(x) where x would be the file containing the weights you want.

This also seems like a promising route to try: Loading pretrained weights that are not from ImageNet