Leaf Disease Detection

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')

            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()

Please find model.h5 file and sample images in my github link

  1. What is the error?
  2. You neither have a python file nor requirements file in your github repo

I have updated my github with the python file also. After running the streamlit application i am getting the below error

  1. There is no app.py file in your github repo.
  2. Check the variable result, it probably does not have the content you expected.

Yeah That’s what . The app.py code i have pasted initially in a code snippet in this post

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.