From 0c58c8f9c442ab2607a59e3d9e89f5aed4092ce1 Mon Sep 17 00:00:00 2001 From: Remi Cresson Date: Tue, 13 Sep 2022 10:24:46 +0200 Subject: [PATCH] ADD: check existence of output_shapes.json and output_types.json --- otbtf/tfrecords.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/otbtf/tfrecords.py b/otbtf/tfrecords.py index 1acd01d0..7d1a4d4c 100644 --- a/otbtf/tfrecords.py +++ b/otbtf/tfrecords.py @@ -121,9 +121,6 @@ def parse_tfrecord(self, example, target_keys, preprocessing_fn=None, **kwargs): :param preprocessing_fn: Optional. A preprocessing function that process the input example :param kwargs: some keywords arguments for preprocessing_fn """ - for file in [self.output_types_file, self.output_shapes_file]: - assert self.output_types, f"The file {file} is missing!" - read_features = {key: tf.io.FixedLenFeature([], dtype=tf.string) for key in self.output_types} example_parsed = tf.io.parse_single_example(example, read_features) @@ -175,6 +172,9 @@ def read(self, batch_size, target_keys, n_workers=1, drop_remainder=True, shuffl :param num_parallel_calls: number of parallel calls for the parsing + preprocessing step :param kwargs: some keywords arguments for preprocessing_fn """ + for file in [self.output_types_file, self.output_shapes_file]: + assert self.output_types, f"The file {file} is missing!" + options = tf.data.Options() if shuffle_buffer_size: options.experimental_deterministic = False # disable order, increase speed