Expected str, bytes or os.PathLike object, not UploadedFile

this is my code


and I am getting this error

can anyone please help me??

Hello @itsme_yashu5, welcome to the community!

According to the API Reference examples you would need to read the uploaded file variable to convert it to bytes, which then Image.load_img should gladily accept :slight_smile:

I didn’t try yet on my side, but could

if image_file is not None:
    image_data = image_file.read()
    img = Image.load_img(image_data)
    ...

do the trick?

Best,
Fanilo

2 Likes