Imagine that you have a folder called my_directory, in this folder you have 2 folders (cat - dog) that contains images of cat and dogs.
you can load theses images like this :
train_data = datasets.ImageFolder('my_directory', transform=transform)
And ImageFolder will automatically assigne the label cat and dog to the right images.