AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
139.6k stars 26.47k forks source link

[Bug]: PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000240CBB2CDB0> #13758

Open bach777 opened 10 months ago

bach777 commented 10 months ago

Is there an existing issue for this?

What happened?

When dragging generated images from the output folders, this error occurs, it never happened to me before and it worked normally some versions ago. I installed a new NVME SSD, but I don't think this has anything to do with it.

Steps to reproduce the problem

Drag any image from the output folders to the PNG info window.

What should have happened?

Read the image with the corresponding metadata without problems.

Sysinfo

sysinfo-2023-10-25-07-57.txt

What browsers do you use to access the UI ?

No response

Console logs

Traceback (most recent call last):
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1429, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1239, in preprocess_data
    processed_input.append(block.preprocess(inputs[i]))
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\gradio\components\image.py", line 274, in preprocess
    im = processing_utils.decode_base64_to_image(x)
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 59, in decode_base64_to_image
    img = Image.open(BytesIO(base64.b64decode(image_encoded)))
  File "X:\STABLE DIFFUSION\stable-diffusion-webui\venv\lib\site-packages\PIL\Image.py", line 3298, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000240CBB2CDB0>

Additional information

No response

CrimsonAxis commented 10 months ago

I've been having this same issue. The only work around is to open the image in photoshop, then save it as a png, and it can then be used. It's something to do with how img2img is saving files.

CrimsonAxis commented 10 months ago

After extensive testing, for me, it seemed to have something to do with which HD the images were written to originally. Changing the hard drive seemed to fix the issue. I have no idea why that fixed the issue, however.

jooglyp commented 10 months ago

pip uninstall contextily pip install contextily

seemed to do the trick for me.

sureally commented 7 months ago

pip uninstall contextily pip install contextily

seemed to do the trick for me.

yes. solve it

Ryden-kai commented 1 week ago

I've tried all the above methods, but they still don't work for me.