You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that, since we perform synthesis on a single directory at a time,
the PyTorch ImageFolder expects a directory structure like the
following:
```
+ metal-root/
|-+ metal/
```
Making these alterations to trashnet/data/dataset-resized, however,
would require additional modifications to the trashnet source code to
account for the new directory structure during trashnet
training/validation/test. As such, we opt for the suggested fix as
mentioned by: pytorch/vision#669.
Environment
OS: Windows 10 64-bit
torch: 0.4.1
torchvision: 0.2.1
Code_1
`
import torch
from torchvision import datasets, transforms
data_dir = "PetImages/Dog"
transform = transforms.Compose([transforms.Resize(255), transforms.CenterCrop(224), transforms.ToTensor()])
dataset = datasets.ImageFolder(root=data_dir, transform=transform)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=32, shuffle=True)
`
Output_1
`
RuntimeError Traceback (most recent call last)
in
5 transforms.ToTensor()])
6
----> 7 dataset = datasets.ImageFolder(root=data_dir, transform=transform)
8
9 dataloader = torch.utils.data.DataLoader(dataset, batch_size=32, shuffle=True)
d:\programs\anaconda3\envs\deep-learning\lib\site-packages\torchvision\datasets\folder.py in init(self, root, transform, target_transform, loader)
176 super(ImageFolder, self).init(root, loader, IMG_EXTENSIONS,
177 transform=transform,
--> 178 target_transform=target_transform)
179 self.imgs = self.samples
d:\programs\anaconda3\envs\deep-learning\lib\site-packages\torchvision\datasets\folder.py in init(self, root, loader, extensions, transform, target_transform)
77 if len(samples) == 0:
78 raise(RuntimeError("Found 0 files in subfolders of: " + root + "\n"
---> 79 "Supported extensions are: " + ",".join(extensions)))
80
81 self.root = root
RuntimeError: Found 0 files in subfolders of: PetImages/Dog
Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif
`
However, when I tried to read the image file, it works
Code_2
`
Test data loader
images, labels = next(iter(dataloader))
plt.imshow(images[0].numpy().transpose((1, 2, 0)))
`
Output_2
https://drive.google.com/file/d/109-Uw5YYXJ0Nij2RIhFAdEorOKgqcXHM/view?usp=sharing
Directory
petImages/
___Cat/
______0.jpg
______1.jpg
______2.jpg
The text was updated successfully, but these errors were encountered: