2

I am currently following this tutorial at section 4. When I run the command to generate the TF Records it returns a trace-back error for the generate_tfrecord.py file. The first error being for:

flags = tf.compat.v1.flags
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
flags.DEFINE_string('image_dir', '', 'Path to the image directory')
flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
FLAGS = flags.FLAGS

I simply fixed it by adding the .compat.v1 line because I am using TF 2.0.

The next error I got was that last line with;

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

It returned:

Traceback (most recent call last):
  File "generate_tfrecord.py", line 101, in <module>
    tf.app.run()
AttributeError: module 'tensorflow' has no attribute 'app'

Any help would greatly appreciated! -Cheers

2 Answers 2

1

In this TensorFlow 2 guide, https://www.tensorflow.org/guide/effective_tf2, it says tf.app is removed. To resolve, either uninstall TensorFlow 2.x and then install 1.x, or modify the code so that it uses 2.x API. You should be able to just call main method instead of tf.app.run().

Reference: https://github.com/tensorflow/tensorflow/issues/34431

Sign up to request clarification or add additional context in comments.

Comments

1

Or you can simpy add import tensorflow.compat.v1 as tf tf.disable_v2_behavior() instead of import tensorflow as tf

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.