title | sidebar |
---|---|
Deploying on Zeit |
home_sidebar |
Unfortunately Zeit changed their API in a way that broke all fastai deployments. We suggest using an alternative service, such as render.com
This is quick guide to deploy your trained models using the Now service from Zeit. This guide comes with a starter app deploying Jeremy's Bear Image Classification model form Lesson 2.
sudo apt install npm # if not already installed
sudo npm install -g now
wget https://github.com/fastai/course-v3/raw/master/docs/production/zeit.tgz
tar xf zeit.tgz
cd zeit
Upload your trained learner file (for example export.pkl
) to a cloud service like Google Drive or Dropbox. Copy the download link for the file. Note: the download link is the one which starts the file download directly—and is normally different than the share link which presents you with a view to download the file (use https://rawdownload.now.sh/ if needed)
If you want to just test the deployment initially, you can use Jeremy's bear classification model from Lesson 2, you can skip this step, since that model's weights URL is already filled in the sample app.
- Open up the file
server.py
inside theapp
directory and update thelearner_file_url
variable with the url copied above
On the terminal, make sure you are in the zeit
directory, then type:
now
The first time you run this, it will prompt for your email address and create your Now account for you. After your account is created, run it again to deploy your project.
Every time you deploy with now
it'll create a unique deployment URL for the app. It has a format of xxx.now.sh
, and is shown while you are deploying the app. When the deployment finishes and it shows "> Success! Deployment ready" on the terminal, type in the terminal:
export NAME='changeme:this-is-your-name-for-the-url'
now alias $NAME
This will alias the above mentioned deployment URL to $NAME.now.sh
. You can do this everytime after you deployed. With that, you have a single URL for your app.
By default all deployment goes to sleep after some inactive time. This is not good for the latest version of your app. So do this:
# You only need to do this once.
now scale $NAME.now.sh sfo 1
Go to $NAME
.now.sh in your browser and test your app.
In case you want to run the app server locally, make these changes to the above steps:
Instead of
now
type in the terminal:
python app/server.py serve
Go to http://localhost:5042/ to test your app.
Thanks to Navjot Matharu for the initial version of this guide, and Simon Willison for sample code.