Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'tensorflow' has no attribute 'app'

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?

like image 307
Dora89 Avatar asked Oct 06 '19 14:10

Dora89


3 Answers

try using import tensorflow.compat.v1 as tf

like image 101
ThMore Avatar answered Nov 17 '22 17:11

ThMore


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.

like image 32
Rishabh Sahrawat Avatar answered Nov 17 '22 18:11

Rishabh Sahrawat


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

from absl import app

if __name__ == '__main__':
    
    app.run(main)
like image 2
JamesAng Avatar answered Nov 17 '22 18:11

JamesAng