Voila does not work for me

I finally got to the point where I was ready to deploy my model, and as always, nothing works as advertised:

I created my inference notebook with this simple code, which runs just fine in Jupyter Notebooks:

from utils import *
from fastai2.vision.widgets import *
from fastai2.vision.all import *

inferencer = load_learner('export.pkl')
btn_upload = widgets.FileUpload()
out_pl = widgets.Output()
lbl_pred = widgets.Label()
# listener method:
def on_click_classify(change):
    img = PILImage.create(btn_upload.data[-1])
    out_pl.clear_output()
    with out_pl:
        display(img.to_thumb(128,128))
    pred, idx, probs = inferencer.predict(img)
    lbl_pred.value = f'Predicted {pred} with {probs[idx]*100:.01f}% certainty'
    
btn_run.on_click(on_click_classify)

VBox([
     widgets.Label('Squash IT!'),
     btn_upload,
     btn_run,
     out_pl,
     lbl_pred
     ])

Then I click “voila” to run it and I get a very cryptic error message:

There was an error when executing cell [6]. Please run Voila with --debug to see the error message.

I try running “voila inference.ipynb --debug” to see what the error is, but get this back:

[Voila] Voila is running at:
http://localhost:8866/
WARNING | No web browser found: could not locate runnable browser

As a side note, I try this both on my local terminal where I SSH into my VM, and on the Cloud Console provided command line.

Nothing is running on port 8886 on local machine, which makes sense since I’m using Google Cloud. But I can’t navigate to wherever voila is running on the cloud. So, I decide to just pull the repo down to my local machine and try it there, but my notebook won’t run at all on my local machine because of this totally unrelated error:

NotImplementedError: cannot instantiate 'PosixPath' on your system,

which I read somewhere MIGHT be because I’ve been developing the notebook on Google Cloud, which is using a Unix virtual machine, and it won’t run because my local machine is windows.

So basically, I never got to find out why Voila won’t work, and I’ve been stuck on trying to deploy my model for 3 days.

Am I the only one having this many problems? Does anyone have a solution to any of these numerous problems?

2 Likes

Hi @wcneill,

I run into this same Problem but fixed that by running from shell: voila mywebapp0.ipynb
Basically voila nameofyournotebook and then copy the url you get into your web browser. I also notice that your code is slightly different your Jeremy note which has

display(VBox([ widgets.Label(‘Squash IT!’), btn_upload, out_pl, lbl_pred ]))

But display() is missing in your above code. Plus you have additional parameter ‘‘btn_run’’ . I am not sure if this make a difference or fix your your problem!

  1. Forward an additional port (8866) in your connection script to gcp instance.

  2. run voila from the command line in your gcp instance typing

voila yournotebook.ipynb

  1. on your local machine go to localhost:8866

You should be able to use the application on your local machine.

1 Like

Hi there

Did you manage to figure out the original issue with the deployment?
I can run voila locally and it all works fine locally but on mybinder.org I just get this error message for every cell:
“There was an error when executing cell [1]. Please run Voila with --debug to see the error message”
I created the notebook from scratch as there were some Colab bits in there, copied someone else’s notebook and just added my export file and still the same!
About to give up and try something else now.

Thanks,
Perusha

You actually need the export.pkl file and the requirements.txt in your repo , the error that you have in cell one is because its trying to import the export.pkl file . my requrements.txt looks like this
voila
fastai>=0.0.16
pillow<7
packaging
ipywidgets==7.5.1

Can anyone confirm if Voila works on Colab?
I’m trying to run this line of code
!jupyter serverextension enable voila --sys-prefix
and getting this error:
Enabling: voila
- Writing config: /usr/etc/jupyter
- Validating…
Error loading server extension voila
X is voila importable?
How to fix this error?

3 Likes

This is what I have tried so far:

iypnb file:

requirement.txt

2.- requirements

readme file

my github repo, which you can see here:

and my settings in binder

and I still get this error:

it still does not work/ do you see something wrong?

I think its because you haven’t uploaded the .pkl file in your repo and its trying to find it .

Thanks for helping me, but the export.pkl is in the repo.

Can you try changing the fastai version in requirements.txt to fastai>=0.0.16

This is the error that occurs in your path/‘export.pkl’ line
AttributeError: ‘str’ object has no attribute 'stored_args

@Uh_shwin I really appreciate you taking the time to reply to my comments. Well I did the changes as you sugested and I updated the screeshots in my previous comments. Maybe you could check it to see if you find some mistake.

its okay this will help someone in the future

unfortunately , I cant figure out what’s wrong , if you figure out a way lemme know too .

for the poxis path error

when you train your model on colab / gradient and download it
then do inference on windows

Just redirect PosixPath to WindowsPath.

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