Image/jpeg files are not allowed

i have built a stream lit app gave the path to a trained model but when i upload an image to test im getting error as
image/jpeg files are not allowed
for any type of file i upload
please help. Here’s my code

import streamlit as st

import numpy as np

from import imread

from skimage.transform import resize

import joblib

from PIL import Image

import streamlit.components.v1 as components

st.title('Plant Disease Identification')

st.text('Upload the image to verify')

model = joblib.load(r"C:\Users\SARATH\OneDrive\Desktop\Project\leaf disease detection")

uploaded_file = st.file_uploader("Choose Image....",type = 'jpeg')

if uploaded_file is not None:

  img =

  st.image(img,caption = 'Uploaded image')

if st.button('PREDICT'):


      CATEGORIES = ['Tomato___Leaf_Mold','Tomato___Late_blight','Tomato___healthy','Potato___Late_blight','Potato___healthy','Potato___Early_blight','Grape___healthy','Grape___Esca_(Black_Measles)','Grape___Black_rot','Corn_(maize)___Northern_Leaf_Blight','Corn_(maize)___healthy','Corn_(maize)___Common_rust_','Apple___healthy','Apple___Apple_scab']

      flat_data = []

      img = np.array(img)

      img_resized = resize(img,(150,150,3))


      flat_data = np.array(flat_data)

      y_out = model.predict(flat_data)

      y_out = CATEGORIES[y_out[0]]

      st.title(f'Predicted output:{y_out}')

      q = model.predict_proba(flat_data)

      for index,item in enumerate(CATEGORIES):                  #prints the probability of all the categories

        st.write(f'{item} : {q[0][index]*100}%')

Hi @Sarath_Chandra , since image upload is the problem, I only targeted that portion of your code:

Try first with the following code for image upload:

import streamlit as st
from PIL import Image

st.title('Plant Disease Identification')
uploaded_file = st.file_uploader('Choose Image to upload…', type = (["jpg", "jpeg"]))

if uploaded_file is not None:
    img =
    st.image(img, caption = 'Uploaded image')

If this works, you can add all the other portions of your code to this.
(Also check if your image size if above the max limits of 200mb)


To add to @Shawn_Pereira 's answer, it’s important to note that you don’t have to have a type parameter, which by default will allow any file type to be passed. But in your case, it was a simple issue of writing jpeg as the only allowed file extension but passing a .jpg file.