We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4c4d6c commit cd8c0c3Copy full SHA for cd8c0c3
torchvision/datasets/folder.py
@@ -39,7 +39,10 @@ def make_dataset(dir, class_to_idx):
39
40
41
def pil_loader(path):
42
- return Image.open(path).convert('RGB')
+ # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
43
+ with open(path, 'rb') as f:
44
+ with Image.open(f) as img:
45
+ return img.convert('RGB')
46
47
48
def accimage_loader(path):
0 commit comments