TypeError: expected str, bytes or os.PathLike object, not UploadedFile

I am on a Windows 10 machine, using streamlit==0.73.1. I am facing the error while selecting and upload an image using streamlit file_uploader, but it is showing the above error.

Python Code:

image_file = st.file_uploader(“Choose a X-Ray scan image…”, type=“jpg”)
if(image_file is not None):
img = image.load_img(image_file,target_size=(224,224))
img = image.img_to_array(img)
Img = Image.open(image_file)
st.image(Img, width=40, caption=‘Uploaded X-Ray’, use_column_width=True)

It used to work fine before upgrading streamlit.
Can anyone help me figure this out??

Hi @Snehit_Vaddi, welcome to the Streamlit community!

Are you sure this code worked? It appears you are mixing img and Img as variable names, which I would expect is not what you intended.

Best,
Randy

I tried using the same img throughout the program, and yet I am facing the same issue.

I tried this code last month and everything worked fine that time, but dunno why I am facing these issues now.

Code and Output from last month.