(self)
Implements DatasetConverter.create_dataset_specification_and_records.
Implements DatasetConverter.create_dataset_specification_and_records.
Implements DatasetConverter . create_dataset_specification_and_records .
def create_dataset_specification_and_records(self):
    """Implements DatasetConverter.create_dataset_specification_and_records."""

    splits = self.get_splits()
    # Get the names of the classes assigned to each split
    train_classes = splits['train']
    valid_classes = splits['valid']
    test_classes = splits['test']

    self.classes_per_split[learning_spec.Split.TRAIN] = len(train_classes)
    self.classes_per_split[learning_spec.Split.VALID] = len(valid_classes)
    self.classes_per_split[learning_spec.Split.TEST] = len(test_classes)

    all_classes = list(
        itertools.chain(train_classes, valid_classes, test_classes))
    for class_id, class_label in enumerate(all_classes):
      logging.info('Creating record for class ID %d (%s)...', class_id,
                   class_label)
      # The raw dataset file uncompresses to `GTSRB/Final_Training/Images/`.
      # The `Images` subdirectory contains 43 subdirectories (one for each
      # class) whose names are zero-padded, 5-digit strings representing the
      # class number. data_root should be the path to the GTSRB directory.
      class_directory = os.path.join(self.data_root, 'Final_Training', 'Images',
                                     '{:05d}'.format(class_id))
      class_records_path = os.path.join(
          self.records_path, self.dataset_spec.file_pattern.format(class_id))
      self.class_names[class_id] = class_label
      # We skip `GT-?????.csv` files, which contain addditional annotations.
      # Shuffle the images, as they are ordered as sequences of 30 frames from
      # the same physical sign.
      self.images_per_class[class_id] = write_tfrecord_from_directory(
          class_directory,
          class_id,
          class_records_path,
          files_to_skip=set(['GT-{:05d}.csv'.format(class_id)]),
          shuffle_with_seed=self.seed + 1)
def create_dataset_specification_and_records ( self ) : splits = self . get_splits ( ) # Get the names of the classes assigned to each split train_classes = splits [ 'train' ] valid_classes = splits [ 'valid' ] test_classes = splits [ 'test' ] self . classes_per_split [ learning_spec . Split . TRAIN ] = len ( train_classes ) self . classes_per_split [ learning_spec . Split . VALID ] = len ( valid_classes ) self . classes_per_split [ learning_spec . Split . TEST ] = len ( test_classes ) all_classes = list ( itertools . chain ( train_classes , valid_classes , test_classes ) ) for class_id , class_label in enumerate ( all_classes ) : logging . info ( 'Creating record for class ID %d (%s)...' , class_id , class_label ) # The raw dataset file uncompresses to `GTSRB/Final_Training/Images/`. # The `Images` subdirectory contains 43 subdirectories (one for each # class) whose names are zero-padded, 5-digit strings representing the # class number. data_root should be the path to the GTSRB directory. class_directory = os . path . join ( self . data_root , 'Final_Training' , 'Images' , '{:05d}' . format ( class_id ) ) class_records_path = os . path . join ( self . records_path , self . dataset_spec . file_pattern . format ( class_id ) ) self . class_names [ class_id ] = class_label # We skip `GT-?????.csv` files, which contain addditional annotations. # Shuffle the images, as they are ordered as sequences of 30 frames from # the same physical sign. self . images_per_class [ class_id ] = write_tfrecord_from_directory ( class_directory , class_id , class_records_path , files_to_skip = set ( [ 'GT-{:05d}.csv' . format ( class_id ) ] ) , shuffle_with_seed = self . seed + 1 )