Mohammad Derakhshan
Mohammad Derakhshan

Reputation: 1572

how to solve 'tensorflow' has no attribute 'init_scope'

I'm using TensorFlow 1.8 in windows. I used object_detection sample for my project and when i run train.py i get this error:

    (tensorflow_gpu) C:\Users\hewil\Desktop\Tensorflow\models\research>python train.py --logtostderr --train_dir=object_detection/CAPTCHA_training/ --pipeline_config_path=object_detection/CAPTCHA_training/faster_rcnn_inception_v2_coco.config
WARNING:tensorflow:From C:\Users\hewil\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\app.py:126: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
WARNING:tensorflow:From C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\legacy\trainer.py:266: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
WARNING:tensorflow:num_readers has been reduced to 1 to match input file shards.
Traceback (most recent call last):
  File "train.py", line 184, in <module>
    tf.app.run()
  File "C:\Users\hewil\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\app.py", line 126, in run
    _sys.exit(main(argv))
  File "C:\Users\hewil\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\util\deprecation.py", line 250, in new_func
    return func(*args, **kwargs)
  File "train.py", line 180, in main
    graph_hook_fn=graph_rewriter_fn)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\legacy\trainer.py", line 291, in train
    clones = model_deploy.create_clones(deploy_config, model_fn, [input_queue])
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\slim\deployment\model_deploy.py", line 193, in create_clones
    outputs = model_fn(*args, **kwargs)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\legacy\trainer.py", line 204, in _create_losses
    prediction_dict = detection_model.predict(images, true_image_shapes)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 822, in predict
    prediction_dict = self._predict_first_stage(preprocessed_inputs)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 873, in _predict_first_stage
    image_shape) = self._extract_rpn_feature_maps(preprocessed_inputs)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 1252, in _extract_rpn_feature_maps
    feature_map_shape[2])]))
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\core\anchor_generator.py", line 108, in generate
    anchors_list = self._generate(feature_map_shape_list, **params)
  File "C:\Users\hewil\Desktop\Tensorflow\models\research\object_detection\anchor_generators\grid_anchor_generator.py", line 111, in _generate
    with tf.init_scope():
AttributeError: module 'tensorflow' has no attribute 'init_scope'

how should I solve that?

Upvotes: 1

Views: 1386

Answers (1)

ChowderII
ChowderII

Reputation: 157

Following this thread https://github.com/tensorflow/hub/issues/324 it seems that TensorFlow only has the init_scope attribute on version higher than 9. I have TensorFlow 1.12 up and running perfectly for object detection as well. Give that a shot and let me know how that goes. P.S. you might want to purge your installation and start from scratch with the specific version. 1.12.0 should do the trick.

Cheers,

Upvotes: 1

Related Questions