tensorflow - Tensorflow 对象检测 api 示例不适用于 Tensorflow 1x
问题描述
这是我的第一个 ML 项目,所以我可能在理解上犯了错误。我已经使用教程Tensorflow 对象检测 API Github训练了一个自定义模型。我很困惑,因为这个页面说当前对象检测 api 不支持 Tensorflow 2.x。但是,当我阅读演示时 ,它要求安装 Tensorflow 2.x。
我不明白什么时候物体检测api不支持tensorflow v2.x,为什么demo要求安装tensorflow v2.x?你们能帮我理解这个吗?我肯定错过了什么。
编辑 1:当我尝试使用 Tensorflow 1.15 运行演示脚本时,出现以下错误
File "object_detection_custom.py", line 71, in run_inference_for_single_image
num_detections = int(output_dict.pop('num_detections'))
TypeError: int() argument must be a string or a number, not 'Tensor'
编辑2:下面是模型调用的输出
{
u 'detection_boxes': < tf.Tensor 'StatefulPartitionedCall:0' shape = ( ? , 100, 4) dtype = float32 > ,
u 'detection_classes': < tf.Tensor 'StatefulPartitionedCall:1' shape = ( ? , 100) dtype = float32 > ,
u 'raw_detection_scores': < tf.Tensor 'StatefulPartitionedCall:6' shape = ( ? , ? , 2) dtype = float32 > ,
u 'detection_scores': < tf.Tensor 'StatefulPartitionedCall:3' shape = ( ? , 100) dtype = float32 > ,
u 'detection_multiclass_scores': < tf.Tensor 'StatefulPartitionedCall:2' shape = ( ? , 100, 2) dtype = float32 > ,
u 'num_detections': < tf.Tensor 'StatefulPartitionedCall:4' shape = ( ? , ) dtype = float32 > ,
u 'raw_detection_boxes': < tf.Tensor 'StatefulPartitionedCall:5' shape = ( ? , ? , 4) dtype = float32 >
}
解决方案
您上面引用的演示链接已损坏,但您引用的笔记本已移动。本教程确实使用了 TensorFlow 2,但仅用于推理。训练需要 TensorFlow 1.15。
推荐阅读
- python - 为什么我的正则表达式模式收集的比我预期的要多?
- android - Android 4.4 - 沉浸式模式顶栏
- javascript - forEach 循环没有根据需要更新数组
- python - 按下按钮时变量加 1
- python - 如何在python中使用文件路径?
- java - 二叉树路径和问题中的递归逻辑给出错误的输出
- arrays - 你如何创建一个带有类的数组?
- python - 为什么 Python 在复制某些文件时更喜欢某些目录而忽略其他目录?
- php - 谷歌 api v3 日历 quickadd php
- google-apps-script - 任何人都可以在这个 html 中找到丢失的 )