Hi,
i’m trying to convert and run inference with a Tensorflow model.
I generate a Tensorflow model with tf.keras:
model = Sequential()
model.add(Conv2D(64, kernel_size=3, activation='relu', input_shape=(224,224,3), name='image'))
model.add(Conv2D(32, kernel_size=3, activation='relu'))
model.add(Flatten())
model.add(Dense(num_classes, activation='softmax', name='output'))
i train the model then i convert the file saving a .pb tensorflow frozen graph file, converted to UFF with:
uff_model = uff.from_tensorflow_frozen_model(
frozen_file="model/tensorflow/simplemodel.pb",
output_nodes=["output/Softmax"],
output_filename="model/tensorrt/simplemodel.uff")
When i parse the model with:
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
builder = trt.Builder(TRT_LOGGER)
network = builder.create_network()
parser = trt.UffParser()
parser.register_input("image_input", (1, 224, 224, 3))
parser.register_output("output/SoftMax")
parser.parse("model/tensorrt/simplemodel.uff", network)
i got this error:
[TensorRT] INFO: UFFParser: parsing image_input
[TensorRT] INFO: UFFParser: parsing image/kernel
[TensorRT] INFO: UFFParser: parsing image/Conv2D
[TensorRT] INFO: UFFParser: parsing image/bias
[TensorRT] INFO: UFFParser: parsing image/BiasAdd
[TensorRT] ERROR: image/Conv2D: kernel weights has count 1728 but 129024 was expected
[TensorRT] ERROR: UFFParser: Parser error: image/BiasAdd: The input to the Scale Layer is required to have a minimum of 3 dimensions.
Why the error about kernel weights count ? I set the input shape with correct size (224,244,3…), this is my model:
Layer (type) Output Shape Param #
=================================================================
image (Conv2D) (None, 222, 222, 64) 1792
_________________________________________________________________
conv2d (Conv2D) (None, 220, 220, 32) 18464
_________________________________________________________________
flatten (Flatten) (None, 1548800) 0
_________________________________________________________________
output (Dense) (None, 6) 9292806
=================================================================
Total params: 9,313,062
Trainable params: 9,313,062
Non-trainable params: 0
Thanks,
Igor