【问题标题】:ImportError: cannot import name 'device_spec' from 'tensorflow.python.framework'ImportError:无法从“tensorflow.python.framework”导入名称“device_spec”
【发布时间】:2020-10-10 16:23:01
【问题描述】:

当我尝试跑步时 python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config

命令此错误弹出。 (tensorflow1.13)

C:\tensorflow1\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config Traceback(最近一次调用):文件“train.py”,第 51 行,在 从 object_detection.builders 导入 dataset_builder 文件“C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py”, 第 33 行,在 从 object_detection.builders 导入 decoder_builder 文件“C:\tensorflow1\models\research\object_detection\builders\decoder_builder.py”, 第 25 行,在 从 object_detection.data_decoders 导入 tf_example_decoder 文件 "C:\tensorflow1\models\research\object_detection\data_decoders\tf_example_decoder.py", 第 28 行,在 从 tf_slim 导入 tfexample_decoder 作为 slim_example_decoder 文件 "C:\Users\user\anaconda3\envs\tensorflow1\lib\site-packages\tf_slim_init_.py", 第 25 行,在 从 tf_slim.layers 导入 * 文件 "C:\Users\user\anaconda3\envs\tensorflow1\lib\site-packages\tf_slim\layers_init_.py", 第 25 行,在 从 tf_slim.layers.layers 导入 * 文件“C:\Users\user\anaconda3\envs\tensorflow1\lib\site-packages\tf_slim\layers\layers.py”, 第 30 行,在 从 tf_slim.ops 导入变量文件“C:\Users\user\anaconda3\envs\tensorflow1\lib\site-packages\tf_slim\ops\variables.py”, 第 27 行,在 from tensorflow.python.framework import device_spec as tf_device ImportError: cannot import name 'device_spec'

【问题讨论】:

  • device_spec 包含在 Tensorflow 2 中,可能您正在使用 Tensorflow1,这就是您没有它的原因。尝试将 tensorflow 更新到最新版本。

标签: python python-3.x tensorflow training-data faster-rcnn


【解决方案1】:

编辑 -> TF OD API 现在支持 TF2

FRCNN 是支持的模型之一。 Soooooooo,更新你的 TF 模型版本,你应该很高兴:)

您可以查看updated TF OD API here


您知道您使用的是什么版本的对象检测 API?

您可能拥有针对 TF2 的版本之一。看起来您正在训练 TF2 尚不支持的 FRCNN - 因此出现了问题!

您可以找到旧版本的TF Models API here。尝试以 TF 1.13 为目标的 v1.13 版本。

OD API 未来可能会迁移到 TF2 but don't hold your breath

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 2021-06-30
    • 2020-10-19
    • 2018-08-13
    • 2015-01-26
    • 2020-02-12
    • 2021-11-27
    • 2021-08-05
    相关资源
    最近更新 更多