diff --git a/generate_tfrecord.py b/generate_tfrecord.py index 87fa5a98..c27b7ed6 100644 --- a/generate_tfrecord.py +++ b/generate_tfrecord.py @@ -20,7 +20,7 @@ from object_detection.utils import dataset_util from collections import namedtuple, OrderedDict -flags = tf.app.flags +flags = tf.compat.v1.app.flags flags.DEFINE_string('csv_input', '', 'Path to the CSV input') flags.DEFINE_string('output_path', '', 'Path to output TFRecord') flags.DEFINE_string('image_dir', '', 'Path to images') @@ -42,7 +42,7 @@ def split(df, group): def create_tf_example(group, path): - with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid: + with tf.compat.v1.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) @@ -83,7 +83,7 @@ def create_tf_example(group, path): def main(_): - writer = tf.python_io.TFRecordWriter(FLAGS.output_path) + writer = tf.compat.v1.python_io.TFRecordWriter(FLAGS.output_path) path = os.path.join(FLAGS.image_dir) examples = pd.read_csv(FLAGS.csv_input) grouped = split(examples, 'filename') @@ -97,4 +97,4 @@ def main(_): if __name__ == '__main__': - tf.app.run() + tf.compat.v1.app.run()