pytorch: get number of classes given an ImageFolder dataset
If I have a dataset like:

image_datasets['train'] = datasets.ImageFolder(train_dir, transform=train_transforms)


How do I determine programatically the number of classes or unique labels in the dataset?

Use:

len(image_datasets['train'].classes)


.classes returns a list.
