UserWarning: Corrupt EXIF data. Expecting to read 2 bytes but only got 0. warnings.warn(str(msg))

#2
by songxw - opened

When I used the test set, I found that there was an error when I got the test set sample,
code:
dataset = load_dataset(dataset_name, split='test')
print(dataset[33669])
output:
lib/python3.7/site-packages/PIL/TiffImagePlugin.py:850: UserWarning: Corrupt EXIF data. Expecting to read 2 bytes but only got 0.
warnings.warn(str(msg))

I get it as well. Also raises the error : cannot identify image file <_io.BytesIO object at 0x7f0de14d0c70>

I encountered the same problem, and currently, i only removed that data point following this thread: https://discuss.huggingface.co/t/remove-a-row-specific-index-from-the-dataset/12875

test_dataset = load_dataset("rvl_cdip", split="test")
test_dataset = test_dataset.select(
    (
        i for i in range(len(test_dataset)) if i != 33669
    )
)

This does cause a problem for caching:

<genexpr> at 0x7f6d38109f20> of the transform datasets.arrow_dataset.Dataset.select couldn't be hashed properly, a random hash was used instead. Make sure your transforms and parameters are serializable with pickle or dill for the dataset fingerprinting and caching to work. If you reuse this transform, the caching mechanism will consider it to be different from the previous calls and recompute everything. This warning is only showed once. Subsequent hashing failures won't be showed.

@lhoestq what would be the best way (including caching) to bypass this corrupt example?

Can someone paste the image path for this corrupt sample? I want to check if I have an uncorrupted backup somewhere.

Can someone paste the image path for this corrupt sample? I want to check if I have an uncorrupted backup somewhere.

I had the same problem with imagese/e/j/e/eje42e00/2500126531_2500126536.tif

@jordyvl RE what would be the best way (including caching) to bypass this corrupt example?

You just have to replace the generator expression with list comprehension so that it's picklable:

test_dataset = load_dataset("rvl_cdip", split="test")
test_dataset = test_dataset.select([i for i in range(len(test_dataset)) if i != 33669])

Sign up or log in to comment