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:
  
      github.com
  
  
    pytorch/vision/blob/b2d4d8a24e221b3d084184fee89a8e1f51e1bcaf/torchvision/datasets/folder.py#L40

        bool: True if the filename ends with a known image extension
    """
    return has_file_allowed_extension(filename, IMG_EXTENSIONS)




def find_classes(directory: str) -> Tuple[List[str], Dict[str, int]]:
    """Finds the class folders in a dataset.


    See :class:`DatasetFolder` for details.
    """
    classes = sorted(entry.name for entry in os.scandir(directory) if entry.is_dir())
    if not classes:
        raise FileNotFoundError(f"Couldn't find any class folder in {directory}.")


    class_to_idx = {cls_name: i for i, cls_name in enumerate(classes)}
    return classes, class_to_idx




def make_dataset(
    directory: str,
    class_to_idx: Optional[Dict[str, int]] = None,