【发布时间】:2020-05-03 13:00:58
【问题描述】:
所以整个故事是我正在尝试将 .pb 冻结推理图转换为 tflite 模型,为此我首先尝试创建 SavedModel。这是我在下面尝试使用的代码:
with tf.Session(graph=tf.Graph()) as sess:
# name="" is important to ensure we don't get spurious prefixing
tf.import_graph_def(graph_def, name="")
g = tf.get_default_graph()
inp = g.get_tensor_by_name("image_tensor:0")
out = {{g.get_tensor_by_name('num_detections:0')}, {g.get_tensor_by_name('detection_boxes:0')},{g.get_tensor_by_name('detection_scores:0')},{g.get_tensor_by_name('detection_classes:0')}}
sigs[signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY] = \
tf.saved_model.signature_def_utils.predict_signature_def(
{"inputs": inp}, {"outputs": out})
builder.add_meta_graph_and_variables(sess,
[tag_constants.SERVING],
signature_def_map=sigs)
builder.save()
我没有正确地“输出”,但是我不知道如何为 SavedModel 签名包含更多输出,或者是否有可能?
【问题讨论】:
标签: python tensorflow