55

I am following this tutorial and doing a project on custom object-detection using tensorflow.

So when I tried to create TF record for the train images using the following command

python3 generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record

I get the following error:

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

How can I resolve this error?

Edward Minnix
  • 2,889
  • 1
  • 13
  • 26
Dora89
  • 671
  • 1
  • 6
  • 10

4 Answers4

99

try using import tensorflow.compat.v1 as tf

ThMore
  • 999
  • 4
  • 2
31

Which Tensorflow version, are you using? If it is TF2.0 then you need to replace tf.app.flags with tf.compat.v1.flags defined here since it is no longer supported.

Rishabh Sahrawat
  • 2,437
  • 1
  • 15
  • 32
3

use absl if you don't want to downgrade tf.

from absl import app

if __name__ == '__main__':
    
    app.run(main)
JamesAng
  • 344
  • 2
  • 9
0

I also got similar error, then installed tensorflow 1.15 version and it worked with following warning.

WARNING:tensorflow:From generate_tfrecord.py:104: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

So, if you got this error try using tf.compat.v1.app.run instead of tf.app.run as stated in the warning from tensorflow.

Dharman
  • 30,962
  • 25
  • 85
  • 135
shivu kumar
  • 51
  • 1
  • 5