Commit cd8c0c3c authored by Sam Gross's avatar Sam Gross Committed by Soumith Chintala
Browse files

Fix ResourceWarning due to Image.open(path) (#176)

See https://github.com/python-pillow/Pillow/issues/835
parent f4c4d6cb
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment