How do I create DataLoaders with images from different folders?

I have files with their grandparent folders as their labels. How do I go on to create a DataLoader object from the files with train, validation, and test splits?

The structure is like below-

root
|
|
|-- label1
       |
       |-- train
              |
              |-- img1.jpg
              |-- img2.jpg
              |...
       |-- test
              |-- test1.jpg
              |...
|-- label2
|-- label3
|...

How do I get the labels from this folder structure?

I want to additionally split the files from the train folders into train and validation splits.