Can anybody please help me out why this code is not working and what is actually the mistake. I am attaching the model and 2 sample images for testing.
import numpy as np
import streamlit as st
import cv2
from keras.models import load_model
import tensorflow as tf
#Loading the Model
model = load_model('final_model.h5')
#Name of classes
CLASS_NAMES = ['Potato___Early_blight', 'Potato___Late_blight', 'Potato___healthy']
st.title('Potato Leaf Disease Detection')
st.markdown('Upload an image of the plant Leaf')
def main():
plant_img = st.file_uploader('Choose an image', type = 'jpg')
submit = st.button('Predict the Disease Stage')
if submit:
if plant_img is not None:
file_bytes = np.asarray(bytearray(plant_img.read()), dtype = np.uint8)
opencv_img = cv2.imdecode(file_bytes, 1)
st.image(opencv_img, channels = 'BGR')
st.write(opencv_img.shape)
opencv_img = cv2.resize(opencv_img, (256,256))
opencv_img.shape = (1,256,256,3)
y_pred = model.predict(opencv_img)
result = CLASS_NAMES[np.argmax(y_pred)]
st.title(str('This is '+result.split('-')[0]+ "leaf with " +result.split('-')[1]))
if __name__ == '__main__' : main()