(self, train_split_only=False)
Initializes the HierarchicalDatasetSpecification instance for ImageNet.

    See HierarchicalDatasetSpecification for details.
    Args:
      train_split_only: bool, if True the entire dataset is assigned to the
        training split.
Initializes the HierarchicalDatasetSpecification instance for ImageNet.
Initializes the HierarchicalDatasetSpecification instance for ImageNet .
def _create_data_spec(self, train_split_only=False):
    """Initializes the HierarchicalDatasetSpecification instance for ImageNet.

    See HierarchicalDatasetSpecification for details.
    Args:
      train_split_only: bool, if True the entire dataset is assigned to the
        training split.
    """
    # Load lists of image names that are duplicates with images in other
    # datasets. They will be skipped from ImageNet.
    self.files_to_skip = set()
    for other_dataset in ('Caltech101', 'Caltech256', 'CUBirds'):
      duplicates_file = os.path.join(
          AUX_DATA_PATH,
          'ImageNet_{}_duplicates.txt'.format(other_dataset))

      with tf.io.gfile.GFile(duplicates_file) as fd:
        duplicates = fd.read()
      lines = duplicates.splitlines()

      for l in lines:
        # Skip comment lines
        l = l.strip()
        if l.startswith('#'):
          continue
        # Lines look like:
        # 'synset/synset_imgnumber.JPEG  # original_file_name.jpg\n'.
        # Extract only the 'synset_imgnumber.JPG' part.
        file_path = l.split('#')[0].strip()
        file_name = os.path.basename(file_path)
        self.files_to_skip.add(file_name)
    ilsvrc_2012_num_leaf_images_path = FLAGS.ilsvrc_2012_num_leaf_images_path
    if not ilsvrc_2012_num_leaf_images_path:
      ilsvrc_2012_num_leaf_images_path = os.path.join(self.records_path,
                                                      'num_leaf_images.json')
    specification = imagenet_specification.create_imagenet_specification(
        learning_spec.Split,
        self.files_to_skip,
        ilsvrc_2012_num_leaf_images_path,
        train_split_only=train_split_only)
    split_subgraphs, images_per_class, _, _, _, _ = specification

    # Maps each class id to the name of its class.
    self.class_names = {}

    self.dataset_spec = ds_spec.HierarchicalDatasetSpecification(
        self.name, split_subgraphs, images_per_class, self.class_names,
        self.records_path, '{}.tfrecords')
def _create_data_spec ( self , train_split_only = False ) : # Load lists of image names that are duplicates with images in other # datasets. They will be skipped from ImageNet. self . files_to_skip = set ( ) for other_dataset in ( 'Caltech101' , 'Caltech256' , 'CUBirds' ) : duplicates_file = os . path . join ( AUX_DATA_PATH , 'ImageNet_{}_duplicates.txt' . format ( other_dataset ) ) with tf . io . gfile . GFile ( duplicates_file ) as fd : duplicates = fd . read ( ) lines = duplicates . splitlines ( ) for l in lines : # Skip comment lines l = l . strip ( ) if l . startswith ( '#' ) : continue # Lines look like: # 'synset/synset_imgnumber.JPEG  # original_file_name.jpg\n'. # Extract only the 'synset_imgnumber.JPG' part. file_path = l . split ( '#' ) [ 0 ] . strip ( ) file_name = os . path . basename ( file_path ) self . files_to_skip . add ( file_name ) ilsvrc_2012_num_leaf_images_path = FLAGS . ilsvrc_2012_num_leaf_images_path if not ilsvrc_2012_num_leaf_images_path : ilsvrc_2012_num_leaf_images_path = os . path . join ( self . records_path , 'num_leaf_images.json' ) specification = imagenet_specification . create_imagenet_specification ( learning_spec . Split , self . files_to_skip , ilsvrc_2012_num_leaf_images_path , train_split_only = train_split_only ) split_subgraphs , images_per_class , _ , _ , _ , _ = specification # Maps each class id to the name of its class. self . class_names = { } self . dataset_spec = ds_spec . HierarchicalDatasetSpecification ( self . name , split_subgraphs , images_per_class , self . class_names , self . records_path , '{}.tfrecords' )