(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)

    image_root_folder = os.path.join(self.data_root, 'images')
    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)
      class_records_path = os.path.join(
          self.records_path, self.dataset_spec.file_pattern.format(class_id))
      self.class_names[class_id] = class_label
      class_directory = os.path.join(image_root_folder, class_label)
      self.images_per_class[class_id] = len(
          tf.io.gfile.listdir(class_directory))
      write_tfrecord_from_directory(class_directory, class_id,
                                    class_records_path)
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 ) image_root_folder = os . path . join ( self . data_root , 'images' ) 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 ) class_records_path = os . path . join ( self . records_path , self . dataset_spec . file_pattern . format ( class_id ) ) self . class_names [ class_id ] = class_label class_directory = os . path . join ( image_root_folder , class_label ) self . images_per_class [ class_id ] = len ( tf . io . gfile . listdir ( class_directory ) ) write_tfrecord_from_directory ( class_directory , class_id , class_records_path )