toriato / stable-diffusion-webui-wd14-tagger

Labeling extension for Automatic1111's Web UI
1.34k stars 235 forks source link

Fix for truncated images #28

Closed thojmr closed 1 year ago

thojmr commented 1 year ago

Hey again, I would suggest adding the following to avoid the below error. It's not ideal to be processing 50k images but a single one in the bunch fails the script.

from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

Prevents the following error, that stops the run:

    image.convert('RGB')
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 901, in convert
    self.load()
  File "/usr/local/lib/python3.10/dist-packages/PIL/ImageFile.py", line 251, in load
    raise OSError(
OSError: image file is truncated (5 bytes not processed)
toriato commented 1 year ago

Thank you for letting me know the issue and the solution! can you check if it's resolved?

thojmr commented 1 year ago

I would if I had not converted all the truncated images last night XD I've been using that flag in other projects on both windows and Ubuntu for a while now. It should be fine.