Binder and Fastai2

Dear all,
it would be great to wikify this post and create a complete guide regarding deploying the app with Binders, there are different comments and suggestions around. This can help other users in the future.

@DanielLam Tips

[git-lfs](https://git-lfs.github.com/) uploaded files work [It needs the add gitattributes]
see repo here https://github.com/albertotono/deployment_solid_classifier

  1. Double check you have all the functions, and a path defined in your jupyter notebook. What I did to my code.
  1. use a small model such as resnet18 at the beginning. When the voila app is working on binder, then try a bigger model with git lfs

  2. Make sure you have all the right files in the github repo
    (the jupyter notebook, .pkl file, and requirements.txt)


    (REAME, Utils and LICENSE are not needed)

  3. Try your files out on mybinder before doing the voila option. For example, you can just include your repo, but leave “Path to a notebook file” blank. This lets you debug on the mybinder server similar to your local jupyter notebook or colab


Change from FILE to URL

  1. If 1-4 have been done, I think your app will deploy correctly. (May take a few minutes to start up though)

  2. Before Launch make sure to copy the URL provided in order to post in your github repo

Good luck and let’s collect here feebacks

7 Likes

Hey @Albertotono,

Thanks for your tips on using Binder! I’ve never used Git Large File Storage, but it looks really helpful for large model files.

One thing that got me was making sure I clicked “URL” instead of the default “File” in the dropdown when entering /voila/render/NOTEBOOK_NAME.ipynb.

Also, a good way to debug the notebook is to replace /voila/render with /notebooks in the URL to run the Jupyter notebook.

2 Likes

@Albertotono

how did you make to display directly the voila output when we click on launch binder from here: https://github.com/albertotono/deployment ?

I created a similar application here:

but to see the voila output we need to:
click on launch binder --> click on the jupyter notebook --> click on voila

When I deployed the repository in mybinder I used:
GitHub: https://github.com/enricodata/emotion-faces/
Path to a notebook file (optional): /voila/render/emotion_classifier.ipynb

Try this instead:

For repository: enricodata/emotion-faces (no need for https… and the/ after faces)

For notebook file: (make sure URL chosen): /voila/render/emotion_classifier.ipynb (same as what you have currently).

This should work

Thanks.
I tried and the result is the same:


Or should I had any specific script to the repository?

The url to copy is present in binder before deploying the app at the bottom. Let me know if you need a screenshot @enr

This is the link that I get from binder before deploying:

it still shows all the jupyter environment

1 Like

I had this problem as well. When I clicked on your link https://mybinder.org/v2/gh/enricodata/emotion-faces/master?filepath=%2Fvoila%2Frender%2Femotion_classifier.ipynb it has filePath in it as a query parameter. You want urlPath like this: https://mybinder.org/v2/gh/enricodata/emotion-faces/master?urlPath=%2Fvoila%2Frender%2Femotion_classifier.ipynb.

When you are entering the input to the text box labeled Path to a notebook file (optional), you want to change the dropdown from File to URL. The label above the box will change to URL to open (optional). After you click launch, you will be redirected to a deployment page with urlPath instead of filePath in the URL.

Change File to URL.

4 Likes

thank you. This solved the issue

1 Like

Thanks for the comment. It happened to me too, but I forgot to add it in the steps.
@Albertotono Hey Alberto, I think you might wanna add a step for Christian’s comment on changing File to URL. I edited my binder tips post (in lessons 2) to reflect the addition.

1 Like

Hi

I still have this issue. My binder link is https://mybinder.org/v2/gh/tissa2/webapp/master?urlpath=%2Fvoila%2Frender%2Fmywebapp.ipynb give NO FOUND ERROR but from my other binder link https://mybinder.org/v2/gh/tissa2/webapp/6dce103bd3b97c3609e824b4af275ed335305114 I have access to my files and run mywebapp.ipynb and it works . see the screenshot

1 Like

Sure, It is a wiki post this one, so we can all modify to make it more useful for others, thanks @DanielLam

1 Like

Thanks a lot for your help, I don’t know why it still not working with me. It’s my first time to use widgets, and it’s frustrating! I got another error because on-click is not defined. Although I have this line in my code:
from ipywidgets import widgets

Hi @SMEissa,

I have not use observe method before. If you update btn_upload.observe(on_click, names=['data']) to btn_upload.on_click(on_click_classify), it should work.

You pass a function on_click_classify that will be called when you click on the button.

You can see an example here: https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#Example

If others have used observe before, then please chime in!

Also, I think you will need to add the following import for it to work properly.

from fastai2.vision.widgets import *

I went through this page and it didn’t work, maybe it’s Google colab problem, did it work with paperspace? I don’t want to spend doing all the project again and don’t work

1 Like

I did it with google colab and it worked

I wrote here the steps that I followed:

thanks for these steps @Albertotono - I followed the steps here, however when trying to run the notebook on binder (step4),I seem to get an error that states "can’t get attribute. ‘_ConstantFunc’ on <module ‘fastai2.learner’ from ‘/srv/conda/envs/notebook/lib/python3.7/site-packages/fastai2/learner.py’>


any insight? @sgugger fyi

1 Like

This is a thing that has been added recently for some exporting errors, so I’d guess you don’t have the same version of fastai2 on your binder.