hello, I have a tensorflow .pb model, it is ok when inferencing with tensorflow,
but when I use it on tensorrt, it went wrong and reported like this:
TensorRT] ERROR: UffParser: Parser error: conv2d_25/Max: Order size is not matching the number dimensions of TensorRT
[TensorRT] ERROR: Network must have at least one output
I don’t know why and how to fix it, my enviroment is :
ubuntu 16.04
cuda9.0 + tensorrt 5.1.2.2
python3.5
the model created by this :
def res_block(x,sz,filter_sz=3,in_conv_size=1):
xi = x
for i in range(in_conv_size):
xi = Conv2D(sz, filter_sz, activation='linear', padding='same')(xi)
xi = BatchNormalization()(xi)
xi = Activation('relu')(xi)
xi = Conv2D(sz, filter_sz, activation='linear', padding='same')(xi)
xi = BatchNormalization()(xi)
xi = Add()([xi,x])
xi = Activation('relu')(xi)
return xi
def conv_batch(_input,fsz,csz,activation='relu',padding='same',strides=(1,1)):
output = Conv2D(fsz, csz, activation='linear', padding=padding, strides=strides)(_input)
output = BatchNormalization()(output)
output = Activation(activation)(output)
return output
def end_block(x):
xprobs = Conv2D(2, 3, activation='softmax', padding='same')(x)
xbbox = Conv2D(6, 3, activation='linear' , padding='same')(x)
print ("xprobs.shape", xprobs.shape)
print ("xbbox.shape", xbbox.shape)
return Concatenate(3)([xprobs,xbbox])
def create_model_eccv():
input_layer = Input(shape=(None,None,3),name='input')
print ("input shape : ", input_layer.shape)
x = conv_batch(input_layer, 16, 3)
x = conv_batch(x, 16, 3)
x = MaxPooling2D(pool_size=(2,2))(x)
x = conv_batch(x, 32, 3)
x = res_block(x, 32)
x = MaxPooling2D(pool_size=(2,2))(x)
x = conv_batch(x, 64, 3)
x = res_block(x,64)
x = res_block(x,64)
x = MaxPooling2D(pool_size=(2,2))(x)
x = conv_batch(x, 64, 3)
x = res_block(x,64)
x = res_block(x,64)
x = MaxPooling2D(pool_size=(2,2))(x)
x = conv_batch(x, 128, 3)
x = res_block(x,128)
x = res_block(x,128)
x = res_block(x,128)
x = res_block(x,128)
x = end_block(x)
return Model(inputs=input_layer,outputs=x)
the code I use is from samples in Tensorrt 5.1.2:
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
def build_engine(model_file):
print ("model_file", model_file)
# For more information on TRT basics, refer to the introductory samples.
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
# Parse the Uff Network
parser.register_input("input", (1, 3, 208, 208))
parser.register_output("concatenate_1/concat")
parser.parse(model_file, network)
# Build and return an engine.
return builder.build_cuda_engine(network)
def main():
model_file = "./wpod-net_update1.uff"
with build_engine(model_file) as engine:
trt.utils.write_engine_to_file(args.out, engine.serialize())
if __name__ == '__main__':
main()