Failed to convert .pb model to .trt model on nx by following the steps provided in samples/python/uff_ssd

Description

My .pb model has FusedBatchNorm layer. I have successfuly converted the .pb model to .uff model, but I failed to convert to .trt model. I got the following error messages when I tried to build_cuda_engine():

[TensorRT] ERROR: cr/bn0/Const: constant weights has count 0 but 1 was expected
[TensorRT] ERROR: UffParser: Parser error: cr/bn0/FusedBatchNorm: Invalid Batchnorm inputs for layer cr/bn0/FusedBatchNorm

So I took a look at the batchnorm layer of my .pb model and .uff model. I noticed both of the mean and variance have a size of 0 as shown in the images attached.

It seems the UffParser needs the mean and variance of the batchnorm layer have a size of 1 (for example, mean = [0], variance = [1]). Could anyone help me resolve this? Thanks in advance.

Hi,

You can attach one when you converts the .pb file into .uff.

Ex. config.py

dummy_const = gs.create_node(name="dummy_const", op="Const", dtype=tf.float32, value=np.array([1, 1], dtype=np.float32))

...
def preprocess(dynamic_graph):
    ...
    dynamic_graph.find_nodes_by_op("FusedBatchNorm")[0].input.append("dummy_const")

Thanks.