Load learner and show results


I trained a model on a server and I would like to copy it to my laptop to visualize the training results. I exported the pickle file from the server and I loaded it in a Jupyter notebook on my laptop:

learn = load_learner('learn.pkl')

When I try to use the show_results() (as well as show_batch()) method, I get the following error:

ValueError: This DataLoader does not contain any batches.

I saw in this topic that the original data is wiped from the exported model. So I copied all images from the server to my laptop, and I kept the same folder architecture. However, I am still getting the same error.

Could you please tell me what else I should copy / add to my script so that it works? Thanks!


1 Like

Maybe this… How to attach data/dls after load_learner()

I’m not sure whether recreating the dataset on your local machine will exactly align the images with the original DataLoader. It “probably will”, but you might want to verify alignment by checksumming the elements of the original DataLoader into an array that you copy to your local machine to verify (sorry, that’s only general advice, I’m not sure the code to do that - if you do it that way, it would be nice to see the code you end up with.)

The other way to ensure an identical DataLoader might be to pickle the original “dls” variable you create the original learner from and copy that file to load on your local machine. That would be very large file so its probably advisable to do an MD5 checksum at the commandline on each side of the transfer.


Thanks for your answer.

In the end, I found another solution:

  1. apply the get_preds() method on the server to do the prediction in batches
  2. save the top 5 predictions and probabilities in a dataframe (as a pickle file)
  3. export to my laptop
  4. visualize the results with custom code (not with show_results()), calculate some statistics, etc.
1 Like