Deploying your notebook as an app under 10 minutes

This short post will walk you through all of the steps necessary to deploy your app

Build Model and app notebook

  1. Once it is model is trained and notebook is ready, create a duplicate of your working notebook with minimal content. Here is sample notebook from my work (Find My Food app) of what it should look like
  2. Once done, download export.pkl & the minimal version of your notebook created in step 1 above

Setup repository in Github

  1. Create a Github account by clicking here
  2. Create a repository in Github by clicking here
    Note: Repository Name can be ‘FindBear’, Type can be ‘Public’ and you can check ‘Initialize this repository with a README’ option. Finally, click on Create repository button to create it
  3. Upload your model (export.pkl), notebook to this repository. Additionally, you also need requirements.txt file, which you can download from here. You do not need to modify requirements.txt. Use as-is.
    Note: If your model (export.pkl) is larger than 25 MBs (which is very possible, even with Resnet18, you need to use Git Large File Storage service. Steps for same are given at the end of this post
  4. You only need 3 files (+1 README.md) to build this app. Same are highlighted below

Using Binder to launch your app

  1. Head over to binder by clicking here
  2. Configure binder as shown below. Please ensure to add /voila/render/ before your notebook name
  3. Once done, click on launch button and you are all set
  4. Share URL to your app (marked with text 3 in the above image) with others to explore

In case your model is larger than 25 Mb, please use below steps to set up Git Large File Storage
Note: Below steps are tested on Windows

  1. If you do not have Git installed locally, please download from here
  2. Download and install Git Large File Storage
  3. Next, create a new folder to hold your Github repository in one of your drive
  4. Open Git bash and head over to above-created folder by using “cd” command
  5. Next, Clone your github repository using “git clone (URL)”
    Note: You can find URL here

    Note: You may be prompted for username and password. If so, please provide your Github username and password
  6. Finally, run below commands in same order to upload large file. Run in the same folder where you cloned your Github repository
git lfs install
git lfs track "*.pkl"

Note: Please use double quotes around .pkl keyword

git add .gitattributes
git add export.pkl
git commit -m "Add model"
git push -u origin master
  1. This shall upload your large model file to Github

Good luck and keep learning!

15 Likes

Thanks for posting this as it really helped to get me to understand what I needed.
I changed the requirements.txt:

voila
fastai
pillow<7
packaging
ipywidgets==7.5.1

I also took a look at your sample notebook which was great that you gave me that as a reference. I changed this in my notebook:

from fastai.vision.all import *
from fastai.vision.widgets import *

With that it almost worked.
Binder wanted to deploy at url that looked like this

https://hub.gke.mybinder.org/user/andrewn2000-findfish-rtfim94r/tree/voila/render/Fish_classifier.ipynb

but when I looked at it on binder and ran the voila from there it worked but the path took out the /tree directory and then it was working!!!

https://hub.gke.mybinder.org/user/andrewn2000-findfish-qr4v7hy9/voila/render/Fish_classifier.ipynb

  • I later found out this was because I didn’t change it to URL and left it as File as the image shows. It should really be like this:

Thanks for your very insightful post!

Andy

2 Likes

Also don’t share those hub.gke links around. They time out after a while and won’t work. Use the /v2/gh/ link it gives you in your screenshot.

1 Like

Thanks for the comment. I didn’t realize they’ll timeout!

Hi all,

I made a fastai binder app github template based on the instructions in this thread.

It also includes some additional links to things you need to run your app on binder.

I tested it out on Paperspace Gradient (and to a lesser extent, Colab) but if you encounter errors, feel free to reply in this thread so I can update it.

HTH.

Butch