AttributeError: 'NoneType' object has no attribute 'update' fastai and streamlit


I want to create an web app using streamlit that classify dogs but I can’t get it to work

I tried every trick in the book but I got nowhere, here is my code :

from import *
from import *
from pathlib import Path
import streamlit as st
    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') :            
              self.pred, self.pred_idx, self.probs=self.learn_inference.predict(self.img)
              st.write(f'Prediction: {self.pred}; Probability: {self.probs[pred_idx]:.04f}')
                return st.write(f'Click the button to classify')
    if __name__=='__main__':
        predictor = Predict(file_name)

After I compile

!streamlit run & npx localtunnel --port 8501

and I click on classify
I get :

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

Any help would be much appreciated.


<IPython.core.display.HTML object>
2022-01-18 18:17:18.723 Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/streamlit/”, line 379, in run_script
exec(code, module.dict)
File “/content/”, line 38, in
File “/content/”, line 14, in init
File “/content/”, line 26, in get_prediction
self.pred, self.pred_idx, self.probs=self.learn_inference.predict(self.img)
File “/usr/local/lib/python3.7/dist-packages/fastai/”, line 266, in predict
,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 125, in on_update
if self.display: self.out.update(HTML(self.progress))
AttributeError: ‘NoneType’ object has no attribute 'update

Did you find a solution? I’m facing the same issue right now.


Sadly, I didn’t find any solution.

If you find something please fell free to contact me at

Thank you and good luck