After exporting model with
And trying to load it using
learn = load_learner(path=EXPERIMENT_PATH / ('bce' + str(0)), file = 'final model.pkl')
I get ValueError: num_samples should be a positive integer value, but got num_samples=0
I guess the error is related to not having data, but I just want to use it for inference. What should I do?
If the problem has to do with needing data as you say then have a look here https://docs.fast.ai/vision.data.html#ImageDataBunch.single_from_classes
That method is deprecated and links to use load_empty instead. load_empty docs mention
But its never used in the tutorial…
Its unclear what I need to pass it because if I pass my exported learner path and fname, it doesn’t work
I couldn’t find a link to load_empty in the docs so I just linked to single_from_classes because it says it’s deprecated anyway
I guess the only way is just loading model and give it the image as tensor, normalizing + applying custom transforms manually.
Edit: found an easy hackish way: redefine len in custom itemList to return at least 1
return max(1, len(self.items))
Did you pass it a
"path" or a
Path("path")? What error do you get?
Passed it a Path(“path”) same as used in load_learner. Thing is load_empty expects an export of only the databunch, so it tries to unpack stuff that is not in the pkl file from learn.save, but rather the data attribute of learn.save. There is no way to tell it that though, and the fix I found is easy and short so no need to keep diving ^^