Bear Classifier: There was an error when executing cell [4]. Please run Voilà with --debug to see the error message

Hi, I am unable to deploy the Bear Classifier app on mybinder. I get the following error:

There was an error when executing cell [4]. Please run Voilà with --debug to see the error message.

What is in that cell [4] of the notebook is:

path = Path()
learn_inf = load_learner(path/‘export.pkl’, cpu=True)
btn_upload = widgets.FileUpload()
out_pl = widgets.Output()
lbl_pred = widgets.Label()

My guess is that this issue comes from the line:

learn_inf = load_learner(path/‘export.pkl’, cpu=True)

Because I wrote it on my own machine (Windows), I was getting an error due to / versus \ in the path name. So I added the following cell to fix that:

import pathlib
temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath

And everything works well with Voila.
However, myBinder doesn’t seem to get it. Any idea?

PS: I had to run voila from my own machine because it doesn’t seem to work on the Paperspace’s ones

Problem solved!
The issue was this portion of code that I had added:

import pathlib
temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath

This portion was necessary for testing my program on my machine (Windows), but then, before uploading the notebook to github for app deployment (myBinder) I should remove that portion of code.

1 Like

Really interested in this. But can you be more specific? I added this piece of code but nothing worked for me. Can you re explain for those who might come across this issue? :slight_smile:

Hi,
I downloaded the code from Paperspace and ran it locally on my machine (Windows) using Jupyter Notebook. And for it to run on a Windows environment, I had to add the following piece:

import pathlib
temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath

Note that I had also installed Voila on my local environment/machine.
I was then able to test the code using Voila on my local machine.
The reason I decided to test on my local machine is that, for some reason Voila wasn’t working for me in Paperspace.
Now, after testing the code in my local machine, I had to remove piece of code presented above before uploading the Bear classifier code onto github and using myBinder.

If you facing this on the Heroku server. try to update fastai version. I faced the same issue then I upgraded to fastai==2.3.1

How to Deploy Fast.ai Models? (Voilà , Binder and Heroku)

Medium article:
https://medium.com/unpackai/how-to-deploy-fast-ai-models-8704ea711ad2

code:

I hope this may help.