I have a Tensorflow model (.pb file) that I want to convert into a TensorRT model (.plan file). I am able to successfully convert a base version of the network from Tensorflow to TensorRT. However, after adding some pre-processing layers into the network, conversion to a .plan file now fails.
I simply added 3 layers (ExpandDims, Transpose, and Div) to the beginning of my frozen Tensorflow model in a manner similar to this: https://stackoverflow.com/questions/44585310/add-low-layers-in-a-tensorflow-model
Here is what the input layers to the base model look like (also attached): https://imgur.com/a/K7v9cVI
Here is what the input layers to my modified model look like (also attached): https://imgur.com/a/3SHGpC9
Here is the error that it produces when I try to convert it to a .plan file (after successfully re-freezing the Tensorflow model and converting it to UFF) (also attached): https://imgur.com/a/V9cYjQx
Since the error says “Order size is not matching the number dimensions of TensorRT” for the Conv2D layer immediately after my pre-processing layers, it seems that my dimensions are not matching up. But I was able to successfully add the pre-processing layers in Tensorflow and re-freeze the model without any errors, and then my conversion from .pb to .uff was done successfully. Also, it seems like the dimensions should match up:
Base model has an input of shape: 1x3x608x960
Modified model has an input of shape: 608x960x3 -> ExpandDims (1x608x960x3) -> Transpose (1x3x608x960) -> Div (1x3x608x960)
So both models should be feeding a 1x3x608x960 tensor into the Conv2D layer.
Does anyone have any insight into why this error is happening or what other approaches I could use to successfully convert my Tensorflow model into TensorRT? I am new to TensorRT conversion so any help would be greatly appreciated!