def build_engine(uff_model_path, trt_logger, trt_engine_datatype=trt.DataType.FLOAT, batch_size=1, silent=False):
    with trt.Builder(trt_logger) as builder, builder.create_network() as network, builder.create_builder_config() as config, trt.UffParser() as parser, trt.Runtime(trt_logger) as runtime:
        config.max_workspace_size = (1 << 30)
        if (trt_engine_datatype == trt.DataType.HALF):
            config.set_flag(trt.BuilderFlag.FP16)
        builder.max_batch_size = batch_size
        parser.register_input(ModelData.INPUT_NAME, ModelData.INPUT_SHAPE)
        parser.register_output('MarkOutput_0')
        parser.parse(uff_model_path, network)
        if (not silent):
            print('Building TensorRT engine. This may take few minutes.')
        plan = builder.build_serialized_network(network, config)
        return runtime.deserialize_cuda_engine(plan)
def build_engine(uff_model_path, trt_logger, trt_engine_datatype=trt.DataType.FLOAT, batch_size=1, silent=False):
    with trt.Builder(trt_logger) as builder, builder.create_network() as network, builder.create_builder_config() as config, trt.UffParser() as parser, trt.Runtime(trt_logger) as runtime:
        config.max_workspace_size = (1 << 30)
        if (trt_engine_datatype == trt.DataType.HALF):
            config.set_flag(trt.BuilderFlag.FP16)
        builder.max_batch_size = batch_size
        parser.register_input(ModelData.INPUT_NAME, ModelData.INPUT_SHAPE)
        parser.register_output('MarkOutput_0')
        parser.parse(uff_model_path, network)
        if (not silent):
            print('Building TensorRT engine. This may take few minutes.')
        plan = builder.build_serialized_network(network, config)
        return runtime.deserialize_cuda_engine(plan)