【发布时间】:2020-09-22 18:06:50
【问题描述】:
我正在尝试将 Tensorflow 的对象检测 API 与预训练模型一起使用。我正在用这个加载模型:
model_name='fish_inception_v2_graph2'
PATH_TO_CKPT='models/research/object_detection/'+model_name+'/frozen_inference_graph.pb'
### Load a (frozen) Tensorflow model into memory.
detection_model = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.compat.v1.GraphDef()
with tf.compat.v2.io.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
这似乎工作正常,但 API 有一个部分用于“检查模型的输入签名,它需要一批 uint8 类型的 3 色图像”:
print(detection_model.signatures['serving_default'].inputs)
当我运行时,我收到错误“AttributeError: 'Graph' object has no attribute 'signatures'”。
有人知道如何解决这个问题吗?谢谢!
【问题讨论】:
-
您能否详细说明一下,您要在这里做什么?您是在尝试对图像进行推理还是试图找到输入张量或其他东西?因为错误是正确的,因为图表不提供任何签名属性。
标签: python tensorflow tensorflow2.0 object-detection object-detection-api