Skip to content

Commit

Permalink
ADD: check existence of output_shapes.json and output_types.json
Browse files Browse the repository at this point in the history
  • Loading branch information
remicres committed Sep 13, 2022
1 parent e8dfec4 commit 0c58c8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions otbtf/tfrecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c58c8f

Please sign in to comment.