def guess_dir_structure(dir):
        """
        Return the directory structure of "dir".

        Args:
            dir(str): something like '/path/to/imagenet/val'

        Returns:
            either 'train' or 'original'
        """
        subdir = os.listdir(dir)[0]
        # find a subdir starting with 'n'
        if subdir.startswith('n') and \
                os.path.isdir(os.path.join(dir, subdir)):
            dir_structure = 'train'
        else:
            dir_structure = 'original'
        logger.info(
            "[ILSVRC12] Assuming directory {} has '{}' structure.".format(
                dir, dir_structure))
        return dir_structure