From 8a42c98398d50644d72f99f80ce68fdc4b01a071 Mon Sep 17 00:00:00 2001 From: HenriqueSchmitz <43157258+HenriqueSchmitz@users.noreply.github.com> Date: Sun, 5 Jun 2022 18:45:13 -0300 Subject: [PATCH] Updated generate tfrecords for newer tensorflow --- generate_tfrecord.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generate_tfrecord.py b/generate_tfrecord.py index bb7379a5fb4..f5a6e28a592 100644 --- a/generate_tfrecord.py +++ b/generate_tfrecord.py @@ -24,7 +24,7 @@ from object_detection.utils import dataset_util from collections import namedtuple, OrderedDict -flags = tf.app.flags +flags = tf.compat.v1.flags flags.DEFINE_string("csv_input", "", "Path to the CSV input") flags.DEFINE_string("output_path", "", "Path to output TFRecord") flags.DEFINE_string( @@ -50,7 +50,7 @@ def split(df, group): def create_tf_example(group, path, label_map): - with tf.gfile.GFile(os.path.join(path, "{}".format(group.filename)), "rb") as fid: + with tf.io.gfile.GFile(os.path.join(path, "{}".format(group.filename)), "rb") as fid: encoded_jpg = fid.read() encoded_jpg_io = io.BytesIO(encoded_jpg) image = Image.open(encoded_jpg_io) @@ -104,7 +104,7 @@ def create_tf_example(group, path, label_map): def main(_): - writer = tf.python_io.TFRecordWriter(FLAGS.output_path) + writer = tf.io.TFRecordWriter(FLAGS.output_path) path = os.path.join(os.getcwd(), FLAGS.img_path) examples = pd.read_csv(FLAGS.csv_input) @@ -131,4 +131,4 @@ def main(_): if __name__ == "__main__": - tf.app.run() + tf.compat.v1.app.run()