not sure if this has been mentioned, but i made this repository which uses resnet50 in this binder app.
steps:
-
after you train your model and export it, upload it somewhere it can be downloaded. i chose dropbox. i also compressed it before i uploaded it but you dont need to. so the file i uploaded to dropbox was
export.tar.gz
(export.pkl compressed). -
in your dropbox, on your
export.tar.gz
file, hit share, then copy link -
this was my link: https://www.dropbox.com/s/ahtavg9k3sble24/export.tar.gz?dl=0. you need to change the dl=0 at the end to dl=1. this will download the file instead of going to the file in dropbox. so the link i used was: https://www.dropbox.com/s/ahtavg9k3sble24/export.tar.gz?dl=1.
-
in your app notebook (replace the url i used with your downloadable dropbox url):
path = Path()
fname='export.tar.gz'
url='https://www.dropbox.com/s/ahtavg9k3sble24/export.tar.gz?dl=1'
# download_url and file_extract are functions from fastai2
download_url(url,path/fname)
file_extract(fname)
os.remove(fname)
this downloads the link to export.tar.gz in the current folder, extracts it (export.pkl), and deletes export.tar.gz.
- so now you can do
learn_inf = load_learner(path/'export.pkl', cpu=True)
just as if you uploaded your model to github.
i also tried this loading a language model, but couldnt get it to work. the kernel crashes loading the learner. not sure why