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.
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.
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.
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.
@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'
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.
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?