Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close PIL.Image file handler in Image.decode_example #3995

Merged
merged 3 commits into from
Mar 23, 2022
Merged

Conversation

mariosasko
Copy link
Collaborator

Closes the file handler of the PIL image object in Image.decode_example to avoid the Too many open files error.

To pass the image equality checks in CI, Image.decode_example calls image.load() regardless of how the image object is created (not only for the PIL.Image.open(local_path) case). This is needed because load() sets the readonly attribute of a PIL.Image object to 0 (it's 1 after PIL.Image.open(file_like)), and in the older PIL versions (only fixed on main), that attribute is considered in PIL.Image.__eq__. More info can be found here: python-pillow/Pillow#5926.

Fix #3985

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you !

src/datasets/features/image.py Outdated Show resolved Hide resolved
Co-authored-by: Quentin Lhoest <[email protected]>
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 23, 2022

The documentation is not available anymore as the PR was closed or merged.

@mariosasko mariosasko merged commit 113d61a into master Mar 23, 2022
@mariosasko mariosasko deleted the fix-3985 branch March 23, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[image feature] Too many files open error when image feature is returned as a path
3 participants