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)