OpenImages数据集上有一个pre-train ResNet。我想使用TensorRT或OpenVino部署它。为此,我应该将此模型转换为ONNX。但是有一个问题:DecodeJpeg运算符已嵌入到图形定义中,而ONNX不支持它。 如何在占位符上替换它并删除旧的(DecodeJpeg)节点?
我已经尝试使用以下代码替换DecodeJpeg(我仍然不知道如何删除旧节点):
g = tf.Graph()
with g.as_default():
with tf.Session() as sess:
saver = tf.train.import_meta_graph('./oidv2-resnet_v1_101.ckpt.meta')
saver.restore(sess, './oidv2-resnet_v1_101.ckpt')
g2 = tf.Graph()
with g2.as_default():
with tf.Session() as sess:
ph = tf.placeholder(tf.float32, [1, 299, 299, 3], name='input_images')
out = tf.import_graph_def(
g.as_graph_def(),
input_map={"map/TensorArrayStack/TensorArrayGatherV3": ph},
return_elements=["multi_predictions:0"]
)
input_values = g2.get_tensor_by_name('input_images:0')
predictions = out[0]
predictions_eval = sess.run(predictions, feed_dict={input_values: image})
但它sess.run
失败,
Attempting to use uninitialized value import/resnet_v1_101/block3/unit_5/bottleneck_v1/conv1/BatchNorm/beta