Solved by eqy in post #2 
              
              
                If the class folder names of both ./train/ and /.tr/ are the same then the indices for each class should be identical by default. This is because the class names are sorted before the class to index map is built: