I am really new at deep learning and I am studying how to properly run neural networks using pytorch
. Currently I am trying to read a dataset of images using the following code:
from torch.utils.data import Dataset, DataLoader
from torchvision import datasets, transforms
from torchvision import transforms, utils
transformations = transforms.Compose([
transforms.Resize(255),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
train_set = datasets.ImageFolder('faces/train', transform = transformations)
test_set = datasets.ImageFolder('faces/test', transform = transformations)
train_loader = DataLoader(train_set, batch_size=60, shuffle = True)
test_loader = DataLoader(test_set, batch_size=60, shuffle = True)
once done that, I am trying to read the images to start running the neural networks on the images, first by separating the imgs from the labels using:
img, labels = next(iter(train_loader))
And then I received the following message:
UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='faces/train/karyadi/karyadi_straight_angry_open.pgm'>
The structure of the folders on my working directory where I have stored the images is as follows:
- faces:
- Train: 10 folders, each one with around 90 images in pgm format.
- Test: 1o folders, each one with around 90 images in pgm format.
does anyone know what the problem might be?
thanks in advance.