def load_imagenet_images(dirname: str, split: str, class_names: Union[List[str], Tuple[str, ...]]):
    """
    Load ImageNet annotations to Detectron2 format.

    Args:
        dirname: Contain "Annotations", "ImageSets", "JPEGImages"
        split (str): one of "train", "test", "val", "trainval"
        class_names: list or tuple of class names
    """
    image_folders = sorted(glob.glob(os.path.join(dirname, split, 'n*')))

    dicts = []
    for image_folder in image_folders:
        folder_name = image_folder.split('/')[-1]
        image_pths = sorted(glob.glob(os.path.join(image_folder, "*.JPEG")))
        for img_pth in image_pths:
            r = {
                "file_name": img_pth,
                "class_name": IMAGENET_CLASSES[IMAGENET_FOLDER_NAMES.index(folder_name)],
                "class_id": IMAGENET_FOLDER_NAMES.index(folder_name),
            }
            dicts.append(r)
    return dicts

    Load ImageNet annotations to Detectron2 format.

    Args:
        dirname: Contain "Annotations", "ImageSets", "JPEGImages"
        split (str): one of "train", "test", "val", "trainval"
        class_names: list or tuple of class names
    
datasets/registration/register_imagenet_cls.py