Error while uploading image

I have built a mask detector, that is working fine locally, but after hoisting, the image uploader giving an error Error: Request failed with status code 500

code:

uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:

    image = Image.open(uploaded_file)

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

Hi @devil-cyber, welcome to the Streamlit community.

Where are you trying to host this app? Is this limited to a specific image, or have you tried multiple images with the same result?

Best,
Randy

I tried to hoist at GitHub using streamlit invite link and i have tried with various image but same error

Hi,
Not sure if you were able to solve the error or not

But I have done this and hosted as well. I did it for video, but I am positive it worked for images as well.

Did you try this:

if uploaded_file is not None:
    #try the below line instead of Image.open()
    image= uploaded_file.read()

    st.image(image, caption='Uploaded Image.')
1 Like

Ok , I will try