AttributeError: 'NoneType' object has no attribute 'update'

Trying to create a web app using streamlit and fastai, I get the following error when I click on “classify.”

***AttributeError: 'NoneType' object has no attribute 'update'***

Weirdly enough, I tried the exact same method last year with no trouble. Could anyone suggest a solution.

Here is the traceback below:

File "/usr/local/lib/python3.7/dist-packages/streamlit/", line 430, in _run_script
    exec(code, module.__dict__)
File "/content/", line 45, in <module>
    predictor = Predict(file_name)
File "/content/", line 21, in __init__
File "/content/", line 36, in get_prediction
    pred, pred_idx, probs = self.learn_inference.predict(self.img)
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 266, in predict
    inp,preds,_,dec_preds = self.get_preds(dl=dl, with_input=True, with_decoded=True)
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 253, in get_preds
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 203, in _do_epoch_validate
    with torch.no_grad(): self._with_events(self.all_batches, 'validate', CancelValidException)
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 163, in _with_events
    try: self(f'before_{event_type}');  f()
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 141, in __call__
    def __call__(self, event_name): L(event_name).map(self._call_one)
File "/usr/local/lib/python3.7/dist-packages/fastcore/", line 155, in map
    def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
File "/usr/local/lib/python3.7/dist-packages/fastcore/", line 698, in map_ex
    return list(res)
File "/usr/local/lib/python3.7/dist-packages/fastcore/", line 683, in __call__
    return self.func(*fargs, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/fastai/", line 145, in _call_one
    for cb in'order'): cb(event_name)
File "/usr/local/lib/python3.7/dist-packages/fastai/callback/", line 45, in __call__
    if and _run: res = getattr(self, event_name, noop)()
File "/usr/local/lib/python3.7/dist-packages/fastai/callback/", line 26, in before_validate
    def before_validate(self): self._launch_pbar()
File "/usr/local/lib/python3.7/dist-packages/fastai/callback/", line 35, in _launch_pbar
File "/usr/local/lib/python3.7/dist-packages/fastprogress/", line 56, in update
File "/usr/local/lib/python3.7/dist-packages/fastprogress/", line 76, in update_bar
    else: self.on_update(val, f'{100 * val/}% [{val}/{} {elapsed_t}<{remaining_t}{end}]')
File "/usr/local/lib/python3.7/dist-packages/fastprogress/", line 127, in on_update
    if self.display: self.out.update(HTML(self.progress))

Hi @Boukman -

Posting the code that generated this error would be helpful, as the traceback appears to be referring to one of the packages you are using.


Hi Randy, Thank you for the follow-up.

Here it is below:

from import *
from import *

from pathlib import Path
import streamlit as st
import numpy as np
from import imread
from skimage.transform import resize
import pickle
import PIL.Image
st.title('Image Classifier')
st.text('upload the image')
path = Path()
learn_inf = load_learner(path/'sclassifier.pkl')
class Predict:
    def __init__(self, filename):
        self.learn_inference = load_learner(Path()/filename)
        self.img = self.get_image_from_upload()
        if self.img is not None:
    def get_image_from_upload():
        uploaded_file = st.file_uploader("Upload Files",type=['png','jpeg', 'jpg'])
        if uploaded_file is not None:
            return PILImage.create((uploaded_file))
        return None

    def display_output(self):
        st.image(self.img.to_thumb(500,500), caption='Uploaded Image')

    def get_prediction(self):

        if st.button('Classify'):
            pred, pred_idx, probs = self.learn_inference.predict(self.img)
            st.write(f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}')
            st.write(f'Click the button to classify') 

if __name__=='__main__':


    predictor = Predict(file_name)

@randyzwitch Is that enough information?

Here is a bit more information @randyzwitch

When I run the classifier within Google Colab it works fine and makes the correct predictions.

The problem starts when I try to run the classifier on a browser using streamlit and ngrok. As soon as I click ‘classify’ I get the long error message posted above.

Below in the picture files is all of the code I use in Google Colab (in order) after successfully testing the classifier and before I get the error when I try using it in a web browser. In fact here, I’ll include the link to the classifier so you can test it out for yourself and see the error in realtime, although Colab may shut it down at any point so might not be running when you read this.

Unfortunately, I don’t have any experience trying to run Streamlit from a notebook and using ngrok.