JobHunter69
JobHunter69

Reputation: 2270

The .data attribute for a dataset in torchvision.datasets doesn't work for ImageFolder?

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

Answers (1)

Berriel
Berriel

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 ImageDatasets. 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

Related Questions