(self)
Create Records for the ILSVRC 2012 classes.

    The field that requires modification in this case is only self.class_names.
Create Records for the ILSVRC 2012 classes.
Create Records for the ILSVRC 2012 classes .
def create_dataset_specification_and_records(self):
    """Create Records for the ILSVRC 2012 classes.

    The field that requires modification in this case is only self.class_names.
    """
    # Get a list of synset id's assigned to each split.
    train_synset_ids = self._get_synset_ids(learning_spec.Split.TRAIN)
    valid_synset_ids = self._get_synset_ids(learning_spec.Split.VALID)
    test_synset_ids = self._get_synset_ids(learning_spec.Split.TEST)
    all_synset_ids = train_synset_ids + valid_synset_ids + test_synset_ids

    # It is expected that within self.data_root there is a directory
    # for every ILSVRC 2012 synset, named by that synset's WordNet ID
    # (e.g. n15075141) and containing all images of that synset.
    set_of_directories = set(
        entry for entry in tf.io.gfile.listdir(self.data_root)
        if tf.io.gfile.isdir(os.path.join(self.data_root, entry)))
    assert set_of_directories == set(all_synset_ids), (
        'self.data_root should contain a directory whose name is the WordNet '
        "id of each synset that is a leaf of any split's subgraph.")

    # By construction of all_synset_ids, we are guaranteed to get train synsets
    # before validation synsets, and validation synsets before test synsets.
    # Therefore the assigned class_labels will respect that partial order.
    for class_label, synset_id in enumerate(all_synset_ids):
      self.class_names[class_label] = synset_id
      class_path = os.path.join(self.data_root, synset_id)
      class_records_path = os.path.join(
          self.records_path, self.dataset_spec.file_pattern.format(class_label))

      # Create and write the tf.Record of the examples of this class.
      # Image files for ImageNet do not necessarily come from a canonical
      # source, so pass 'skip_on_error' to be more resilient and avoid crashes
      write_tfrecord_from_directory(
          class_path,
          class_label,
          class_records_path,
          files_to_skip=self.files_to_skip,
          skip_on_error=True)
def create_dataset_specification_and_records ( self ) : # Get a list of synset id's assigned to each split. train_synset_ids = self . _get_synset_ids ( learning_spec . Split . TRAIN ) valid_synset_ids = self . _get_synset_ids ( learning_spec . Split . VALID ) test_synset_ids = self . _get_synset_ids ( learning_spec . Split . TEST ) all_synset_ids = train_synset_ids + valid_synset_ids + test_synset_ids # It is expected that within self.data_root there is a directory # for every ILSVRC 2012 synset, named by that synset's WordNet ID # (e.g. n15075141) and containing all images of that synset. set_of_directories = set ( entry for entry in tf . io . gfile . listdir ( self . data_root ) if tf . io . gfile . isdir ( os . path . join ( self . data_root , entry ) ) ) assert set_of_directories == set ( all_synset_ids ) , ( 'self.data_root should contain a directory whose name is the WordNet ' "id of each synset that is a leaf of any split's subgraph." ) # By construction of all_synset_ids, we are guaranteed to get train synsets # before validation synsets, and validation synsets before test synsets. # Therefore the assigned class_labels will respect that partial order. for class_label , synset_id in enumerate ( all_synset_ids ) : self . class_names [ class_label ] = synset_id class_path = os . path . join ( self . data_root , synset_id ) class_records_path = os . path . join ( self . records_path , self . dataset_spec . file_pattern . format ( class_label ) ) # Create and write the tf.Record of the examples of this class. # Image files for ImageNet do not necessarily come from a canonical # source, so pass 'skip_on_error' to be more resilient and avoid crashes write_tfrecord_from_directory ( class_path , class_label , class_records_path , files_to_skip = self . files_to_skip , skip_on_error = True )