Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generate_tfrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -97,4 +97,4 @@ def main(_):


if __name__ == '__main__':
tf.app.run()
tf.compat.v1.app.run()