Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
cd8c0c3c
Commit
cd8c0c3c
authored
May 26, 2017
by
Sam Gross
Committed by
Soumith Chintala
May 26, 2017
Browse files
Fix ResourceWarning due to Image.open(path) (#176)
See
https://github.com/python-pillow/Pillow/issues/835
parent
f4c4d6cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
torchvision/datasets/folder.py
torchvision/datasets/folder.py
+4
-1
No files found.
torchvision/datasets/folder.py
View file @
cd8c0c3c
...
...
@@ -39,7 +39,10 @@ def make_dataset(dir, class_to_idx):
def
pil_loader
(
path
):
return
Image
.
open
(
path
).
convert
(
'RGB'
)
# open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
with
open
(
path
,
'rb'
)
as
f
:
with
Image
.
open
(
f
)
as
img
:
return
img
.
convert
(
'RGB'
)
def
accimage_loader
(
path
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment