Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'feature_column_v2' from 'tensorflow.python.tpu' using Object Detection API

I am trying to use tensorflow's Object Detection API, and i'm getting and import error right after calling model_main.py.

ImportError: cannot import name 'feature_column_v2' from 'tensorflow.python.tpu'

This happens right after I call:

python model_main.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config

Full traceback:

Traceback (most recent call last):
  File "model_main.py", line 26, in <module>
    from object_detection import model_lib
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\model_lib.py", line 28, in <module>
    from object_detection import eval_util
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\eval_util.py", line 35, in <module>
    slim = tf.contrib.slim
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__
    module = self._load()
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 45, in _load
    module = importlib.import_module(self.__name__)
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\contrib\__init__.py", line 33, in <module>
    from tensorflow.contrib import compiler
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\contrib\compiler\__init__.py", line 22, in <module>
    from tensorflow.contrib.compiler import xla
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\contrib\compiler\xla.py", line 22, in <module>
    from tensorflow.python.estimator import model_fn as model_fn_lib
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\estimator\__init__.py", line 26, in <module>
    from tensorflow_estimator.python import estimator
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\__init__.py", line 25, in <module>
    import tensorflow_estimator.python.estimator.estimator_lib
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator_lib.py", line 69, in <module>
    from tensorflow_estimator.python.estimator.tpu.tpu_estimator import TPUEstimator
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\tpu\tpu_estimator.py", line 83, in <module>
    from tensorflow_estimator.python.estimator import estimator as estimator_lib
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\__init__.py", line 8, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py", line 11, in <module>
    from tensorflow_estimator._api.v1.estimator import tpu
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\tpu\__init__.py", line 8, in <module>
    from tensorflow_estimator._api.v1.estimator.tpu import experimental
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\tpu\experimental\__init__.py", line 8, in <module>
    from tensorflow_estimator.python.estimator.tpu._tpu_estimator_embedding import EmbeddingConfigSpec
  File "C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\tpu\_tpu_estimator_embedding.py", line 32, in <module>
    from tensorflow.python.tpu import feature_column_v2 as tpu_fc_v2
ImportError: cannot import name 'feature_column_v2' from 'tensorflow.python.tpu' (C:\Users\Rodolfo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\tpu\__init__.py)

Inside my training folder is the labelmap and the configuration file, and the tf records are correctly specified in the config file.

Paths in the pipeline configuration file:

train_input_reader: {
  tf_record_input_reader {
    input_path: "data/train.record"
  }
  label_map_path: "training/object-detection.pbtxt"
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "data/test.record"
  }
  label_map_path: "training/object-detection.pbtxt"
  shuffle: false
  num_readers: 1
}

I'm running everything on Windows 10, using Python 3.7 and the API is appearently working fine, since I ran the test file and the tests ran without any issue. I also ran the Object detection example jupyter notebook, which also worked.

like image 638
Rodolfo Donã Hosp Avatar asked Jul 09 '19 11:07

Rodolfo Donã Hosp


1 Answers

Upgrade your tensorflow version to 1.14 (at least).

like image 166
Minions Avatar answered Nov 20 '22 04:11

Minions