TypeError: Exception occured in `ProgressCallback` when calling event `after_batch`: unsupported format string passed to TensorBase.__format__

Some of my models that used to work don’t work today with the following error message.
What is causing an error?

TypeError: Exception occured in `ProgressCallback` when calling event `after_batch`: unsupported format string passed to TensorBase.__format__

This is the code for app.py.

from fastai.vision.all import *
import fastai
import streamlit as st

learn = load_learner('export.pkl')
labels = learn.dls.vocab

def predict(img):
  img = PILImage.create(img)
  pred, pred_idx, probs = learn.predict(img)
  highest_prob = probs.argmax()
  file_name = f"{labels[highest_prob].split(' ')[0].item()}_sugg.png"
  img_sugg = PILImage.create(file_name)
  return f'Is this {labels[highest_prob].item()}?', img_sugg

picture = st.camera_input("Take a picture")

if picture:
    st.image(picture)
    result, sugg = predict(picture)
    st.write(result)
    st.image(sugg)
2 Likes

I can confirm this, I got the same error
However if I run the same code in my local machine or colab, it worked as expected

so is this error caused by huggingface?

After a few searches, it seems like fastai didn’t support the latest pytorch yet.
Specifying torch as 1.12.1 in requirements.txt did the trick for now

3 Likes

Thank you @farkmu45 It fixed the error. :smiley: