I am trying to deploy my Image Classification model and facing this issue while reading the selected image.
Code snippet:
def prediction(model):
image_file = st.file_uploader("Choose a bird image..", type="jpg")
if(image_file is not None):
image = Image.open(image_file)
st.image(image, width=40, caption='Uploaded bird image', use_column_width=True)
np_image = np.array(image).astype('float32')/255
np_image = transform.resize(np_image, (224, 224, 3))
np_image = np.expand_dims(np_image, axis=0)
model = load_model(model)
prediction = model.predict(img.reshape(1,224,224,3))
if(np.argmax(prediction)==0.0):
st.write('According to Model, it can be: COVID-19 with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
elif(np.argmax(prediction)==1.0):
st.write('According to Model, it can be: Normal with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
elif(np.argmax(prediction)==2.0):
st.write('According to Model, it can be: Pneumonia with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
I executed the same code a month ago, and it worked fine—Donno why I am facing this error now.
Debug info
- Streamlit version: 0.72.0
- Python version: Python 3.7.5
- Tensorflow Version: tensorflow==2.4.1
- Keras Version: Keras==2.3.1
- Using IDLE
- OS version: Windows
- Browser version: Chrome