I want to use torchvision ImgaeFolder class to create my dataset.
By default ImageFolder creates labels according to upper directories’ name. I want to change this behaviour to upper upper directories.
Here is my directories structure:
Image/
    -001/
        -frontal/
            -01.jpg
            -02.jpg
    -002/
        -frontal/
            -01.jpg
            -02.jpg
    -003/
        -frontal/
            -01.jpg
            -02.jpg

So as you can see, the upper directories’ name are all ‘frontal’. I want to set upper upper directories’ name(001,002,003) as label name.
How can I modify the torchvision ImgaeFolder class?
Thank you in advance!