You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/ImageFile.py", line 280, in load
s = read(self.decodermaxblock)
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/PngImagePlugin.py", line 989, in load_read
cid, pos, length = self.png.read()
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/PngImagePlugin.py", line 173, in read
length = i32(s)
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/_binary.py", line 95, in i32be
return unpack_from(">I", c, o)[0]
struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/pala/iqa-pytorch/IQA-PyTorch/inference_iqa.py", line 98, in <module>
main()
File "/home/pala/iqa-pytorch/IQA-PyTorch/inference_iqa.py", line 68, in main
score = iqa_model(img_path, ref_img_path).cpu().item()
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pala/iqa-pytorch/IQA-PyTorch/pyiqa/models/inference_model.py", line 92, in forward
target = imread2tensor(target, rgb=True)
File "/home/pala/iqa-pytorch/IQA-PyTorch/pyiqa/utils/img_util.py", line 72, in imread2tensor
img = img.convert('RGB')
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/Image.py", line 993, in convert
self.load()
File "/home/pala/miniconda3/envs/iqa/lib/python3.10/site-packages/PIL/ImageFile.py", line 287, in load
raise OSError(msg) from e
OSError: image file is truncated
seems to occur with bigger images for which iqa-pytorch has no problem to calc a score (e.g. hyperiqa). The fix is:
go to conda env and do find . -type f -iname 'ImageFile.py'
result e.g. - file must be from 'PIL' ./lib/python3.10/site-packages/PIL/ImageFile.py
edit that file and change
LOAD_TRUNCATED_IMAGES = False
to
LOAD_TRUNCATED_IMAGES = True
Then it works. I tried to add in file pyiqa/utils/img_util.py
from PIL import Image
Image.LOAD_TRUNCATED_IMAGES = True
to your script but this did not work so I used the global option. Maybe you can add a switch to your script(s) for that.
The text was updated successfully, but these errors were encountered:
However, setting it as default could cause issues like increased memory usage, compatibility problems, or user confusion. It’s likely better to leave it for users to enable explicitly when needed.
Hello,
the following error:
seems to occur with bigger images for which
iqa-pytorch
has no problem to calc a score (e.g.hyperiqa
). The fix is:find . -type f -iname 'ImageFile.py'
./lib/python3.10/site-packages/PIL/ImageFile.py
LOAD_TRUNCATED_IMAGES = False
to
LOAD_TRUNCATED_IMAGES = True
Then it works. I tried to add in file
pyiqa/utils/img_util.py
to your script but this did not work so I used the global option. Maybe you can add a switch to your script(s) for that.
The text was updated successfully, but these errors were encountered: