klopfer384
klopfer384

Reputation: 41

How to change the input shape of an existing tensorflow model (.pb)

I want to turn a preexisting tensorflow graph into a graph that can be deployed on the Movidius Neural Compute stick.

When I use the command mvNCCompile (from NCSDK), following Error occurs: [Error 5] Toolkit Error: Stage Details Not Supported: Dynamic input shape not supported.

After checking the tensorflow graph in tensorboard I figured out that the input tensor has following shape: (?,?,?,3) In my usecase I have always the same input shape which is:(1,368,656,3).

Now I want to change the tensors' dynamic input shape into a static one.

How can I accomplish that?

I have tried following this post: How to change a saved model input shape in Tensorflow? but I could not change the graph.

Graph can be found here: https://github.com/ildoonet/tf-pose-estimation/blob/master/models/graph/mobilenet_thin/graph_opt.pb

import tensorflow as tf

graph_path = 
'/home/bk/Documents/OPSLim/Pose/graph_models/mobilenet_thin/graph_opt.pb'

with tf.gfile.GFile(graph_path, 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())


graph = tf.get_default_graph()
tf_new_image = tf.placeholder(shape=(1, 368, 368, 3), dtype='float32', 
name='new_image')
tf.import_graph_def(graph_def, name='TfPoseEstimator', input_map= {"image:0": tf_new_image})

Upvotes: 4

Views: 1924

Answers (0)

Related Questions