Lesson 2: Bear Classifier: ipywidgets FileUpload does not work when using Voila

I’m trying to upload an image through the ipywidget FileUpload widget:

btn_upload = widgets.FileUpload()

To run inside a notebook, I had to adjust websocket_max_message_size; otherwise, the notebook hangs, as reported here.

I could do that using classical jupyter server using a customized jupyter_notebook_config.py

jupyter notebook --config="/path/to/user/.jupyter/jupyter_notebook_config.py" bear_classifier.ipynb
c.ServerApp.tornado_settings = {"websocket_max_message_size": 100 * 1024 * 1024}

When running the notebook, I cannot adjust this websockect_max_message_size, so the execution hangs after selecting a file.

I already tried setting config through command line options

voila bear_classifier.ipynb --Voila.tornado_settings="{'websocket_max_message_size': 209715200}"

Or even through a custom app

from voila.app import Voila, _, Dict

class CustomVoila(Voila):
  tornado_settings = Dict(
      'websocket_max_message_size': 209715200
        "Extra settings to apply to tornado application, e.g. headers, ssl, etc"

app = CustomVoila()

Do you have any idea what else could I try?

If you don’t have a specific need to use voila, take a look at gradio instead to do your demo.

1 Like

I found it helpful to hop back and forth between the book and the more recent 2022 course workbooks. Some of the functions recommended in the book have been deprecated. The tools in the 2022 material are more up to date, in this case recommending the Gradio + HuggingFace Spaces method to host a model.