Closed jakubLangr closed 4 years ago
Actually it was just me being stupid—just re-define all the functions that are assumed by your model.
Yes. We actually go over that once we hit lesson 5 in the study group :)
Actually it was just me being stupid—just re-define all the functions that are assumed by your model.
I'm having the first issue you stated. Can you tell me how you fixed it?
When you bring your learner back in make sure to re-define any functions your model wants to use along with it
I did not define any functions, I believe. For instance, I defined these for my model:
dls = ImageDataLoaders.from_folder(path_output, train='train', valid_pct=0.3, bs=8)
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(4)
learn.unfreeze()
learn.fit_one_cycle(n_epoch = 10, lr_max = 5e-3)
learn.save('model_34')
Then calling the code below gives the error:
tst_files = get_image_files(path_output/'test')
learn = load_learner(path_output/'models/model_34_unfrozen.pth', cpu=False)
tst_dl = learn.dls.test_dl(tst_files)
When running through the camvid example and trying to then subsequently use the classifier as a deployed inference model I run into the following issue:
To reproduce:
Option 1
1a. just put
learn.save('camvid-v2')
at the end of the notebook 2a. in another notebook run:learner = load_learner('/home/jakub/.fastai/data/camvid/models/camvid-v2.pth')
If this is the case then the error is:3a. If I instead write:
learner = load_learner('/home/jakub/.fastai/data/camvid/models/camvid-v2.pth', cpu=False)
Then line runs, but:learner.predict(test_img)
returns:Because it is type
dict
.I tried looking at @muellerzr tutorial for deployment but it seems that that the same issue does not appear there.
Option 2
1b: If I instead use the
export
method, such aslearner.export('camvid-test')
I have the following problem: 2b: After running:I get :
Apologies for the confusion, took me a while to retrace all the things I tried. Will continue to investigate.