ImageNet

class ImageNet(root=None, train=True, **kwargs)[source]

Load ImageNet from raw files or folder. Expected folder looks like:

${root}/
|       [REQUIRED TAR FILES]
|-  ILSVRC2012_img_train.tar
|-  ILSVRC2012_img_val.tar
|-  ILSVRC2012_devkit_t12.tar.gz
|       [OPTIONAL IMAGE FOLDERS]
|-  train/cls/xxx.${img_ext}
|-  val/cls/xxx.${img_ext}
|-  ILSVRC2012_devkit_t12/data/meta.mat
|-  ILSVRC2012_devkit_t12/data/ILSVRC2012_validation_ground_truth.txt

If the image folders don’t exist, raw tar files are required to get extracted and processed.

  • if root contains self.target_folder depending on train:

    • initialize ImageFolder with target_folder.

  • else:

    • if all raw files are in root:

      • parse self.target_folder from raw files.

      • initialize ImageFolder with self.target_folder.

    • else:

      • raise error.

Parameters
  • root (Optional[str]) – root directory of imagenet data, if root is None, use default_dataset_root.

  • train (bool) – if True, load the train split, otherwise load the validation split.