From e8dfec4062f5005e82785a8e786c3fbd36f3849b Mon Sep 17 00:00:00 2001 From: Remi Cresson <remi.cresson@inrae.fr> Date: Tue, 13 Sep 2022 10:24:02 +0200 Subject: [PATCH 1/3] ADD: check existence of output_shapes.json and output_types.json --- otbtf/tfrecords.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/otbtf/tfrecords.py b/otbtf/tfrecords.py index 123bdea5..1acd01d0 100644 --- a/otbtf/tfrecords.py +++ b/otbtf/tfrecords.py @@ -121,6 +121,9 @@ class TFRecords: :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) -- GitLab From 0c58c8f9c442ab2607a59e3d9e89f5aed4092ce1 Mon Sep 17 00:00:00 2001 From: Remi Cresson <remi.cresson@inrae.fr> Date: Tue, 13 Sep 2022 10:24:46 +0200 Subject: [PATCH 2/3] 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 @@ class TFRecords: :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 @@ class TFRecords: :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 -- GitLab From b5eb85397937388624120f09218ea3ef127d896c Mon Sep 17 00:00:00 2001 From: Narcon Nicolas <nicolas.narcon@inrae.fr> Date: Tue, 13 Sep 2022 13:12:00 +0200 Subject: [PATCH 3/3] Apply 1 suggestion(s) to 1 file(s) --- otbtf/tfrecords.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otbtf/tfrecords.py b/otbtf/tfrecords.py index 7d1a4d4c..254efd2a 100644 --- a/otbtf/tfrecords.py +++ b/otbtf/tfrecords.py @@ -172,8 +172,8 @@ class TFRecords: :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!" + for dic, file in zip([self.output_types, self.output_shapes], [self.output_types_file, self.output_shapes_file]): + assert dic, f"The file {file} is missing!" options = tf.data.Options() if shuffle_buffer_size: -- GitLab