New guide for easy web app deployment

Hello @miwojc. I thought very interesting your post. Indeed, the option “Not recognized” must be given I think (or “Other” if you prefer) in order to use the “Classifier in Real Life”.

Following the idea of @martinmm, this is the code I use when I build a classifier with 2 classes:

def predict_label(img, ths, model=learn):
    
    # Condition function
    def cond(idx):
        return (indice == idx) and (value >= ths[idx])
    
    # Get prediction values
    cat, indice, preds = model.predict(img)
    value, _ = torch.max(preds, 0)
    indice = indice.item()
    value = value.item()

    if cond(0) or cond(1):
        print(cat)
    else:
        print('Not recognized') 

Then, you type predict_label(img, ths) to get the label of class 0, class 1 or the label “Not recognized” for an image classified by the model.

Note: the argument ths is a list [th0, th1]. th0 and th1 are the thresholds of classes 0 and 1 above which the class label is given. You need to analysis your predictions to search the best values for theses thresholds.

Thanks for the post @anurag.

Can you give us an idea of how your service compares with zeit? I’ve been happy with the later thus far but have found their messaging confusing regarding docker support and so forth. Would be looking to explore this for both personal and professional projects.

I tried deploy my model with zeit but i didn’t :slight_smile: I have mac and i am using now app on computer.Also i couldn’t upgrade.:persevere:

The biggest difference is that we plan to offer first class Docker support for as long as developers are using Docker, and our Docker offering is only going to get better (we’re going to introduce Docker persistence so you can run Wordpress or MySQL on Render).

We also don’t have restrictions on Docker image sizes, unlike Zeit where you have to $50/month to go over 100MB, and $200/month to go over 500MB. With Render, you’ll just pay $5/month.

2 Likes

Yasin: feel free to sign up for Render with code fastai-v3.

@anurag Thank u i will try.I want to make skin cancer classification.I trained model but i couldn’t deploy yet.how can i solve problem at zeit?

I don’t think you can since they’ve closed v1 off to new signups from what I can tell.

@anurag Render is really good and easy but i have a problem again.Have any idea? :slightly_smiling_face:

You’ll need to get the latest version of the fastai library on the machine you use to train your model and export it again. That should fix the issue.

@anurag Thank u so much Anurag.If i can do, i will send address and i would be grateful if u look :slight_smile:

1 Like

@Ysnylmz
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’)
learn.save(‘stage-1’)
learn.export()`

1 Like

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

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

Hi

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?

C

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/server.py serve
Traceback (most recent call last):
  File "app/server.py", line 5, in <module>
    from fastai.vision import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/__init__.py", line 5, in <module>
    from .data import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/data.py", line 4, in <module>
    from .transform import *
  File "/home/qq88/python-virtual-environments/venv/lib/python3.8/site-packages/fastai/vision/transform.py", 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?