首页 > 解决方案 > 来自 tensorflow.python.framework 的对象检测 API 将 device_spec 导入为 tf_device ImportError: cannot import name 'device_spec'

问题描述

我已经在 Anaconda 的虚拟环境中使用 tensorflow 的对象检测 API tf 1.13.1 训练了一个对象检测器,现在我正在尝试评估我的模型。

不久,我到目前为止所做的是,为测试和训练图像生成标签并将它们存储在 object_detection/images 文件夹下。我还生成了 train.record 和 test.record 文件,并编写了 labelmap.pbtxt 文件。我正在使用 tensorflow 模型动物园中的 faster_rcnn_inception_v2_pets 模型,因此我配置了 faster_rcnn_inception_v2_pets.config 文件,并将其存储在 object_detection/training 文件夹中。训练过程运行良好,所有检查点也存储在 object_detection/training 文件夹中。

现在我必须评估模型,我以各种方式运行 eval.py 脚本,例如:

C:\users\hp\improject\models\models/research/object_detection/eval.py --pipeline_config_path=C:\users\hp\improject\models\research\object_detection\training\pipeline.config --model_dir=C:\users\hp\improject\models\research\object_detection\training  --checkpoint_dir=C:\users\hp\improject\models\research\object_detection\training --run_once=True

C:\users\hp\improject\models\models/research/object_detection/model_main.py --pipeline_config_path=C:\users\hp\improject\models\research\object_detection\training\pipeline.config --model_dir=C:\users\hp\improject\models\research\object_detection\training  --checkpoint_dir=C:\users\hp\improject\models\research\object_detection\training --run_once=True 

使用 model_main.py 和 eval.py 两种方式我都遇到错误

从 tensorflow.python.framework import device_spec as tf_device ImportError: cannot import name 'device_spec'

有一些建议,例如在 device.py 中进行一些更改(它没有解决)并将 tf 更新到 1.15(我想继续使用 tf 1.13.1)但这些并没有解决我的问题。

提前谢谢你的帮助!

标签: pythontensorflowevaluationobject-detection-api

解决方案


推荐阅读