解决Object detection训练时出现的ValueError: Tensor conversion requested dtype string for Tensor with dtype

0.前言

最近开始学习接触目标检测,使用的是TensorFlow的开源框架,工程文件源自github。在依照相关教程配置好开发环境后,准备调用coco预训练模型进行training时,出现ValueError报错。查阅一番资料后,有人说是tfrecord的格式问题,也有人说是data的路径问题,但按照那些方法进行修改并未解决我的问题(Github Issues传送门:https://github.com/tensorflow/models/issues/4909)

1.运行环境及操作过程

Windows7+Python 3.6+Tensorflow 1.10

2.控制台输出的报错信息

ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: ‘Tensor(“arg0:0”, shape=(), dtype=float32, device=/device:CPU:0)’

3.可能的原因

(1)pipeline.config管道文件的路径fine_tune_checkpoint,input_path,label_map_path的绝对路径与相对路径问题;
(2)pipeline.config管道文件的路径fine_tune_checkpoint,input_path,label_map_path的斜杠与反斜杠问题(相当隐蔽!!!);

4.解决方法

(1)修改相对路径为绝对路径;
(2)在Windows OS下,文件目录路径不能直接复制粘贴资源管理器上的路径,如下图:
错误示范
而是应当使用r转义,或使用双斜杠,或使用反斜杠,如下图所示:
正确操作:使用r转义
正确操作:使用双斜杠
正确操作:使用反斜杠

原文地址:https://www.cnblogs.com/litchi99/p/13504323.html