Reputation: 2270
I can access the training data set of an MNIST object like so:
from torchvision.datasets import MNIST
trainset = MNIST(root='.', train=True, download=True)
print(trainset.data)
However, I'm not able to do the same using ImageFolder. Anybody know the equivalent for ImageFolder?
AttributeError: 'ImageFolder' object has no attribute 'data'
Upvotes: 2
Views: 2831
Reputation: 13601
There isn't any.
Nowadays, everyone assumes that MNIST fits in memory, thus it is preloaded to the data
attribute. However, this is usually not possible for ImageDataset
s. Therefore, the images are loaded on-the-fly which means, no data
attribute for them. You can access the image paths and labels using the self.imgs
or self.samples
.
Upvotes: 2