mseitzer / pytorch-fid

Compute FID scores with PyTorch.
Apache License 2.0
3.22k stars 497 forks source link

OSError: image file is truncated #85

Closed Rem-Yin closed 5 months ago

Rem-Yin commented 2 years ago

I double checked the dataset and there are no broken images.

Searching on Baidu, It seems that the error occurs when loading large images. As a result, the source code has to be modified to solve this problem.

mseitzer commented 1 year ago

I am not able to find information about PIL not being able to load large images. Thus I would first advise first to double check that the images in question really can not be loaded by PIL, e.g. using:

img = Image.open(path).load()

You can also try adding the following snippet to see if it solves the problem. However, this may silently create padded images, which is not what you want for FID computations.

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True