I have a Tensorflow model trained in Python and frozen with the freeze_graph script. I've succesfully loaded the model in c++ and made inference for a single image. However, it seems freeze_graph sets the batchsize to only a single image at a time, since I am unable to pass the model a tensor with more than one image.
Does anyone know a way of changing this? I haven't been able to locate where in the script it actually happens.
Thanks!
EDIT:
Okay, so I scrapped Keras just to eliminate any black magic that might be doing, and I set a batch size of 16 when defining the network with Tensorflow.
If I print the graph def, the placeholder has a shape:
node {
name: "inputs"
op: "Placeholder"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "shape"
value {
shape {
dim {
size: 16
}
dim {
size: 50
}
dim {
size: 50
}
dim {
size: 3
}
}
}
}
}
However, when I attempt to load and run the model in c++ with a tensor of shape 16 x 50 x 50 x 3, I get this error:
tensorflow/core/framework/tensor.cc:433] Check failed: 1 == NumElements() (1 vs. 16)Must have a one element tensor
Something must be happening somewhere when I freeze the graph?
freeze_graphdoesn't 'set' the batch size of the model. How were you feeding the inputs in your original model?freeze_graphmust do something in the case of a placeholder with a dimension of variable size, but I might be wrong. Is there a way I can check what the shape of the placeholder actually is?graph.as_graph_def()and see if the placeholder has the shape attribute set.freeze_graph? It will be useful to show the one afterfreeze_graph.