New guide for easy web app deployment

I had the same error. The problem was in the model being targeted for gpu. When exporting the model (in colab), I used:

defaults.device = torch.device(‘cpu’)‘stage-1’)

1 Like

@amatic i changed that in but didn’t work.I will try that thank u )

DVC sounds cool! Have you spent any time with it? Cheers


only did the tutorial and used it for a small toy project… not in production yet. But I plan to use it more in the coming months…

How about you?


1 Like

No not yet! Only looked through the documentation so far.

Will post here if I use it soon!

I had the same issue, figured out that it was because my file was large enough for Google Drive to prompt you to make sure you want to download the file instead of directly downloading it. After switching over to Dropbox the direct download worked and the error went away.

I had the same issue with the google drive download link until I added the google drive api key. Then it worked fine.

@anurag I am trying to run Jeremy’s model but am getting:

(venv) [qq88@qq88-pc fastai-v3]$ python app/ serve
Traceback (most recent call last):
  File "app/", line 5, in <module>
    from import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/", line 5, in <module>
    from .data import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/", line 4, in <module>
    from .transform import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/", line 233, in <module>
    _solve_func = getattr(torch, 'solve', torch.gesv)
AttributeError: module 'torch' has no attribute 'gesv'

EDIT: This was fixed by updating fastai
But now I am getting: module 'sys' has no attribute 'set_coroutine_wrapper'

Hi qq88 hope you are having a wonderful day!

What version of python are you using in your venv environment?

I believe that ‘set_coroutine_wrapper’ has been removed in python 3.8, so you may have to run or train your model in python 3.7 where I believe it was deprecated but is still included.

1 Like

How difficult is it to downgrade? Can I do it in a venv so it’s just temporary?
I already messed up my comp when upgrading to 3.8 and am having now two versions.

Is it not possible to change the code in such a way it works with 3.8?

Hi qq88 hope you are having a beautiful day today!

How difficult is it to downgrade?

I wouldn’t bother downgrading if your machine is working, 3.8 is the future. :smiley:

In my humble opinion the only way to program in python is with virtual environments.
I literally have probably 100’s of virtual environments from tutorials and different apps and things I work on. If I don’t have a virtual env with the libraries I want, I create another you can specify the version of python you want to use.

I don’t consider virtual environments temporary, they allow me to try all all sorts of experiments and work with code from other peoples environments without trashing my machine.

if you don’t use virtual environments and you install lots of libraries and are always trying new things in python I guarantee you will end up trashing parts of the software on your machine.

Is it not possible to change the code in such a way it works with 3.8?

I don’t know enough about the python and fastai to answer this, and am not sure if this is the best approach.

Cheers mrfabulous1 hope this helps :smiley: :smiley:


Thanks for your response.
I do work only with virtual environments, luckily I was exposed to this credo right at the start of my learning.

What I was referring to with:

I already messed up my comp when upgrading to 3.8 and am having now two versions.

is that after installing 3.8 with via the official upgrade the old version stayed on my computer. Or smth like that. I tried to resolve it but no success but found out other people suffer from this as well.

1 Like

OK, so made some progress, was able to create the app with flask but now I’m struggling with the evaluation phase, here is the error.

This is my code:

from fastai import *
from import *

path = Path('')
model = load_learner(path)

def get_veggie(image_bytes):
    img_bytes = image_bytes['file'].read()
    img = open_image(BytesIO(img_bytes))
    prediction = model.predict(img)[0]

And this is the part:

from flask import Flask, render_template, request
from commons import get_tensor
from inference import get_veggie

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def hello_world():
    if request.method == 'GET':
        return render_template('index.html', value='O')
    if request.method == 'POST':
        if 'file' not in request.files:
            print('image not uploaded')
        file = request.files['file']
        image =
        return render_template('result.html', veggie='cucumber')

if __name__ == '__main__':

@jeremy The link that you have mentioned for production using Zeit doesn’t seem to work .I am a new learner and I have been struggling to find resources , so that i can create a web application just like you did. can you show me the right way to go about for creating an web application and deploy the fastai model ,I stumble across platforms that needs me to pay and I have no clue how to proceed ,I am a student and I cannot afford to pay ,Is there a way for me to create the web application free of cost ?Help me with resources please ! Thank you .

Looking at the cached link ( ), it seems this method no longer works sadly.

1 Like

After some reading, I too think that Zeit (now Vercel) is the best way to deploy the web app.

The link for the guide does not work. Where can I find one?

I would like to find out how to deploy the model to an web app. A step by step guide is expected.

the post above yours seems to suggest that vercel no longer works for fastai.

if you want an easy deployment option i’d recommend heroku. there’s a guide here.

if you want a guide for somewhere else google it. if you don’t find one, write one and post it.


I have deployed to Heroku for free. You can refer to this or the method mentioned by @joedockrill

I too have deployed to heroku. Initially, I had problems because I had to install some libraries to install for opencv but figured it out eventually.

Looking for some guidance to get my heroku app to work. I am getting an error with

2021-01-16T17:16:29.430526+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/torch/", line 211, in __init__
2021-01-16T17:16:29.430965+00:00 app[web.1]:     super(_open_file, self).__init__(open(name, mode))
2021-01-16T17:16:29.431055+00:00 app[web.1]: IsADirectoryError: [Errno 21] Is a directory: 'app'
2021-01-16T17:16:30.377978+00:00 heroku[web.1]: Process exited with status 1

I believe it has something to do with the load_learner step, but I can’t seem to figure out what it is.
Any ideas?