class_docstr: The ILSVRC12 classification dataset, aka the commonly used 1000 classes ImageNet subset.
  This dataflow produces uint8 images of shape [h, w, 3(BGR)], and a label between [0, 999].
  The label map follows the synsets.txt file in
  http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz,
  which can also be queried using :class:`ILSVRCMeta`.
class_docstr_tok: ["The","ILSVRC12","classification","dataset",",","aka","the","commonly","used","1000","classes","ImageNet","subset",".","This","dataflow","produces","uint8","images","of","shape","[","h",",","w",",","3","(","BGR",")","]",",","and","a","label","between","[","0",",","999","]",".","The","label","map","follows","the","synsets.txt","file","in","http",":","\/\/dl.caffe.berkeleyvision.org\/caffe_ilsvrc12.tar.gz",",","which","can","also","be","queried","using",":","class",":","`","ILSVRCMeta","`","."]
docstr: Args:
      dir (str): A directory containing a subdir named ``name``,
          containing the images in a structure described below.
      name (str): One of 'train' or 'val' or 'test'.
      shuffle (bool): shuffle the dataset. Defaults to True if name=='train'.
      dir_structure (str): One of 'original' or 'train'.
          The directory structure for the 'val' directory.
          'original' means the original decompressed directory, which only has list of image files (as below).
          If set to 'train', it expects the same two-level directory structure similar to 'dir/train/'.
          By default, it tries to automatically detect the structure.
          You probably do not need to care about this option because 'original' is what people usually have.
  
  Example:
  
  When `dir_structure=='original'`, `dir` should have the following structure:
  
  .. code-block:: none
  
      dir/
        train/
          n02134418/
            n02134418_198.JPEG
            ...
          ...
        val/
          ILSVRC2012_val_00000001.JPEG
          ...
        test/
          ILSVRC2012_test_00000001.JPEG
          ...
  
  With the downloaded ILSVRC12_img_*.tar, you can use the following
  command to build the above structure:
  
  .. code-block:: none
  
      mkdir val && tar xvf ILSVRC12_img_val.tar -C val
      mkdir test && tar xvf ILSVRC12_img_test.tar -C test
      mkdir train && tar xvf ILSVRC12_img_train.tar -C train && cd train
      find -type f -name '*.tar' | parallel -P 10 'echo {} && mkdir -p {/.} && tar xf {} -C {/.}'
  
  When `dir_structure=='train'`, `dir` should have the following structure:
  
  .. code-block:: none
  
      dir/
        train/
          n02134418/
            n02134418_198.JPEG
            ...
          ...
        val/
          n01440764/
            ILSVRC2012_val_00000293.JPEG
            ...
          ...
        test/
          ILSVRC2012_test_00000001.JPEG
          ...
docstr_tok: ["Args",":","dir","(","str",")",":","A","directory","containing","a","subdir","named","``","name","``",",","containing","the","images","in","a","structure","described","below",".","name","(","str",")",":","One","of","'train","'","or","'val","'","or","'test","'",".","shuffle","(","bool",")",":","shuffle","the","dataset",".","Defaults","to","True","if","name=='train","'",".","dir_structure","(","str",")",":","One","of","'original","'","or","'train","'",".","The","directory","structure","for","the","'val","'","directory",".","'original","'","means","the","original","decompressed","directory",",","which","only","has","list","of","image","files","(","as","below",")",".","If","set","to","'train","'",",","it","expects","the","same","two-level","directory","structure","similar","to","'dir\/train\/","'",".","By","default",",","it","tries","to","automatically","detect","the","structure",".","You","probably","do","not","need","to","care","about","this","option","because","'original","'","is","what","people","usually","have",".","Example",":","When","`","dir_structure=='original","'","`",",","`","dir","`","should","have","the","following","structure",":","..","code-block",":",":","none","dir\/","train\/","n02134418\/","n02134418_198.JPEG","...","...","val\/","ILSVRC2012_val_00000001.JPEG","...","test\/","ILSVRC2012_test_00000001.JPEG","...","With","the","downloaded","ILSVRC12_img_","*",".tar",",","you","can","use","the","following","command","to","build","the","above","structure",":","..","code-block",":",":","none","mkdir","val","&","&","tar","xvf","ILSVRC12_img_val.tar","-C","val","mkdir","test","&","&","tar","xvf","ILSVRC12_img_test.tar","-C","test","mkdir","train","&","&","tar","xvf","ILSVRC12_img_train.tar","-C","train","&","&","cd","train","find","-type","f","-name","'","*",".tar","'","|","parallel","-P","10","'echo","{","}","&","&","mkdir","-p","{","\/",".","}","&","&","tar","xf","{","}","-C","{","\/",".","}","'","When","`","dir_structure=='train","'","`",",","`","dir","`","should","have","the","following","structure",":","..","code-block",":",":","none","dir\/","train\/","n02134418\/","n02134418_198.JPEG","...","...","val\/","n01440764\/","ILSVRC2012_val_00000293.JPEG","...","...","test\/","ILSVRC2012_test_00000001.JPEG","..."]
code: def __init__(
      self, dir, name, meta_dir=None, shuffle=None, dir_structure=None
  ):
      """
      Args:
          dir (str): A directory containing a subdir named ``name``,
              containing the images in a structure described below.
          name (str): One of 'train' or 'val' or 'test'.
          shuffle (bool): shuffle the dataset. Defaults to True if name=='train'.
          dir_structure (str): One of 'original' or 'train'.
              The directory structure for the 'val' directory.
              'original' means the original decompressed directory, which only has list of image files (as below).
              If set to 'train', it expects the same two-level directory structure similar to 'dir/train/'.
              By default, it tries to automatically detect the structure.
              You probably do not need to care about this option because 'original' is what people usually have.
  
      Example:
  
      When `dir_structure=='original'`, `dir` should have the following structure:
  
      .. code-block:: none
  
          dir/
            train/
              n02134418/
                n02134418_198.JPEG
                ...
              ...
            val/
              ILSVRC2012_val_00000001.JPEG
              ...
            test/
              ILSVRC2012_test_00000001.JPEG
              ...
  
      With the downloaded ILSVRC12_img_*.tar, you can use the following
      command to build the above structure:
  
      .. code-block:: none
  
          mkdir val && tar xvf ILSVRC12_img_val.tar -C val
          mkdir test && tar xvf ILSVRC12_img_test.tar -C test
          mkdir train && tar xvf ILSVRC12_img_train.tar -C train && cd train
          find -type f -name '*.tar' | parallel -P 10 'echo {} && mkdir -p {/.} && tar xf {} -C {/.}'
  
      When `dir_structure=='train'`, `dir` should have the following structure:
  
      .. code-block:: none
  
          dir/
            train/
              n02134418/
                n02134418_198.JPEG
                ...
              ...
            val/
              n01440764/
                ILSVRC2012_val_00000293.JPEG
                ...
              ...
            test/
              ILSVRC2012_test_00000001.JPEG
              ...
      """
      super(ILSVRC12, self).__init__(
          dir, name, meta_dir, shuffle, dir_structure
      )
  
imports: import numpy
  import os
  import tarfile
  import tqdm
  from pathlib import Path
  from ...utils import logger
  from ...utils.fs import download, get_dataset_path, mkdir_p
  from ...utils.loadcaffe import get_caffe_pb
  from ...utils.timer import timed_operation
  from ..base import RNGDataFlow
label_desc: Use image node_id 1 to create a new ILSVRC12 object from inherited base classes: ILSVRC12Files with example: obj = ILSVRC12(dir, name, meta_dir, shuffle, dir_structure)