Open the-lazy-val opened 4 years ago
@the-lazy-val I ran into this same issue. I haven't yet resolved it, but did find an alternate way to publish using Voila:
In your paperspace notebook (I'm using V2), click the Volia button in the top menu (far right):
You should see your working bear classifier open in a new tab. To share, add ?token=
plus your notebook token to that url, for example: https://n9eusla3.gradient.paperspace.com/voila/render/fastbook/BearBot.ipynb?token=putyourtokenhere
You can copy your token from the main paperspace notebooks page: https://console.paperspace.com/notebooks:
I'm still new to paperspace and haven't researched implications of sharing your token publicly, but using above you should be able to share at least with trusted people and run from any computer.
Yes I've faced the same issue. I've spent hours on it and can't find the solution yet :/ As @mlapeter suggested, voila works well using Paperspace.
Reproduced the same thing as shown here.
I'm facing the same issue. Seems original repo is working fine in binder because the environment was built already before something broke in binder? Even new binder requests for original repo is working fine and showing as the environment is already build. Any solutions for forks?
As temporary workaround is to follow this link: https://forums.fast.ai/t/load-learner-attributeerror-cant-get-attribute-flattenedloss-on-module-fastai-layers/78117/10
Just add this to the first code block:
import fastai.losses
import fastai.layers
fastai.layers.BaseLoss = fastai.losses.BaseLoss
fastai.layers.CrossEntropyLossFlat = fastai.losses.CrossEntropyLossFlat
fastai.layers.BCEWithLogitsLossFlat = fastai.losses.BCEWithLogitsLossFlat
fastai.layers.BCELossFlat = fastai.losses.BCELossFlat
fastai.layers.MSELossFlat = fastai.losses.MSELossFlat
fastai.layers.L1LossFlat = fastai.losses.L1LossFlat
fastai.layers.LabelSmoothingCrossEntropy = fastai.losses.LabelSmoothingCrossEntropy
fastai.layers.LabelSmoothingCrossEntropyFlat = fastai.losses.LabelSmoothingCrossEntropyFlat
@nanospeck
Em, this assumes that we trained a model with fastai <2.0 and want to deploy with fastai>2.0.
However I have the error in with the latest fastai (>2.0) trained model being deployed at binder.
Edit: Heroku seems like a better app to deploy with functions to --debug. If interested have a look here
Hi, @the-lazy-val and all, Faced the same issue too. Now I savled this problem. I found that the problem was due to a mismatch between.pkl and some other packages. I updated my requiretments.txt, add runtime.txt, and change some code to fix it. This is my requiretments.txt and runtime.txt.
requirements.txt
voila
fastai>=2,<=2.0.6
fastcore==1.0.0
pillow<7
packaging
ipywidgets==8.0.0
torch==1.6.0
runtime.txt
python-3.8.6
and change the code
def on_data_change(change):
lbl_pred.value = ''
img = PILImage.create(btn_upload.value[0].content.tobytes())
out_pl.clear_output()
with out_pl: display(img.to_thumb(128,128))
pred,pred_idx,probs = learn_inf.predict(img)
lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
btn_upload.observe(on_data_change, names=['value'])
my forked repo https://github.com/supermaxJ/bear_voila_copy
Hi, I am just starting with fastai. I forked the fastai/bear_voila repo (to this repo), and set it up in Binder. https://mybinder.org/v2/gh/the-lazy-val/bear_classifier/master?filepath=%2Fvoila%2Frender%2Fbear_classifier.ipynb
After app launch, I get the below error:
There was an error when executing cell [2]. Please run Voilà with --debug to see the error message.
I am using the same pre-trained model (export.pkl) that is already available in the repo.