Are you working on a shared drive or are you moving data around?
This seems really weird, as the samples and targets are created in the __init__ call.
So after initializing the ImageFolder, the length should be constant even if you add new files to the folders.
Or are you reinitializing the dataset also?