pythontensorflowobject-detection

AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0


I got that error when I'm trying to train my model:

(tensorflow1) C:\tensorflow1\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
Traceback (most recent call last):
  File "train.py", line 52, in <module>
    from object_detection.builders import model_builder
  File "C:\tensorflow1\models\research\object_detection\builders\model_builder.py", line 35, in <module>
    from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
  File "C:\tensorflow1\models\research\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 30, in <module>
    from nets import inception_resnet_v2
  File "C:\tensorflow1\models\research\slim\nets\inception_resnet_v2.py", line 375, in <module>
    batch_norm_updates_collections=tf.compat.v1.GraphKeys.UPDATE_OPS,
AttributeError: module 'tensorflow.compat' has no attribute 'v1'

Tensorflow version: 1.10.0

I'm using conda virtualenv created with:

conda create -n tensorflow1 pip python=3.5

(tensorflow1) conda install tensorflow-gpu

Working on Windows 10


Solution

  • Providing the solution here (Answer Section), even though it is present in the Comment Section for the benefit of the community.

    This code tf.compat.v1.GraphKeys.UPDATE_OPS is not available on Tensorflow==1.10.0

    If you are using an older version of TensorFlow, here is a table showing which GitHub commit of the repository you should use.

    To have those features update your version to 1.15 or 2.2 as below

       conda install tensorflow=1.15
    

    or

       conda install tensorflow=2.2