megengine.data.dataset.ImageNet

class ImageNet(root=None, train=True, **kwargs)[源代码]

从原始文件或文件夹中加载ImageNet,期望的文件夹形如:

${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

如果期望的图片文件夹不存在,则需要原始tar文件来进行抽取和处理。

  • 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.

参数
  • 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.

属性

default_devkit_dir

default_train_dir

default_val_dir

meta

raw_file_meta

valid_ground_truth

方法

check_raw_file()

rtype

bool

collect_class()

rtype

Dict

collect_samples()

rtype

List