There is a pre-train ResNet on OpenImages dataset. I want to deploy it using TensorRT or OpenVino. To do this, I should convert this model to ONNX. But there's a problem: DecodeJpeg operator is embedded into the graph definition and ONNX does not support it. How to replace it op on my placeholder and remove old (DecodeJpeg) nodes?
I have tried this code to replace DecodeJpeg (I still don't know how to remove old nodes):
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})
but it sess.run
fails with
Attempting to use uninitialized value import/resnet_v1_101/block3/unit_5/bottleneck_v1/conv1/BatchNorm/beta