From 22973cb9be4b39759cea0db6aee60b1cdef87b4f Mon Sep 17 00:00:00 2001 From: zhiboniu <31800336+zhiboniu@users.noreply.github.com> Date: Tue, 16 Aug 2022 18:32:15 +0800 Subject: [PATCH] update vehicle plate trt params (#6658) * fix trt params * update config to make safe of trt input shape --- .../examples/infer_cfg_illegal_parking.yml | 2 +- .../examples/infer_cfg_vehicle_plate.yml | 2 +- deploy/pipeline/config/infer_cfg_ppvehicle.yml | 2 +- deploy/pipeline/download.py | 2 ++ deploy/pipeline/ppvehicle/vehicle_plate.py | 1 - .../pipeline/ppvehicle/vehicle_plateutils.py | 5 ++--- deploy/python/preprocess.py | 18 ++++++------------ 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml b/deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml index 18c2915fc..a8e7d85d4 100644 --- a/deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml +++ b/deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml @@ -10,7 +10,7 @@ MOT: VEHICLE_PLATE: det_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_det_infer.tar.gz - det_limit_side_len: 480 + det_limit_side_len: 736 det_limit_type: "max" rec_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_rec_infer.tar.gz rec_image_shape: [3, 48, 320] diff --git a/deploy/pipeline/config/examples/infer_cfg_vehicle_plate.yml b/deploy/pipeline/config/examples/infer_cfg_vehicle_plate.yml index 9f8d0740a..bf745f9cc 100644 --- a/deploy/pipeline/config/examples/infer_cfg_vehicle_plate.yml +++ b/deploy/pipeline/config/examples/infer_cfg_vehicle_plate.yml @@ -15,7 +15,7 @@ MOT: VEHICLE_PLATE: det_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_det_infer.tar.gz det_limit_side_len: 736 - det_limit_type: "min" + det_limit_type: "max" rec_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_rec_infer.tar.gz rec_image_shape: [3, 48, 320] rec_batch_num: 6 diff --git a/deploy/pipeline/config/infer_cfg_ppvehicle.yml b/deploy/pipeline/config/infer_cfg_ppvehicle.yml index 11880ebd5..fc4e2413c 100644 --- a/deploy/pipeline/config/infer_cfg_ppvehicle.yml +++ b/deploy/pipeline/config/infer_cfg_ppvehicle.yml @@ -15,7 +15,7 @@ MOT: VEHICLE_PLATE: det_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_det_infer.tar.gz det_limit_side_len: 736 - det_limit_type: "min" + det_limit_type: "max" rec_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_rec_infer.tar.gz rec_image_shape: [3, 48, 320] rec_batch_num: 6 diff --git a/deploy/pipeline/download.py b/deploy/pipeline/download.py index fd385e7ec..a166b3ba1 100644 --- a/deploy/pipeline/download.py +++ b/deploy/pipeline/download.py @@ -36,6 +36,8 @@ MODEL_URL_MD5_DICT = { '64fa0e0701efd93c7db52a9b685b3de6', "https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_l_36e_ppvehicle.zip": "3859d1a26e0c498285c2374b1a347013", + "https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_s_36e_ppvehicle.zip": + "4ed58b546be2a76d8ccbb138f64874ac", "https://bj.bcebos.com/v1/paddledet/models/pipeline/dark_hrnet_w32_256x192.zip": "a20d5f6ca087bff0e9f2b18df45a36f2", "https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.zip": diff --git a/deploy/pipeline/ppvehicle/vehicle_plate.py b/deploy/pipeline/ppvehicle/vehicle_plate.py index 954687fe1..d12637937 100644 --- a/deploy/pipeline/ppvehicle/vehicle_plate.py +++ b/deploy/pipeline/ppvehicle/vehicle_plate.py @@ -123,7 +123,6 @@ class PlateDetector(object): img, shape_list = self.preprocess(image) if img is None: return None, 0 - self.input_tensor.copy_from_cpu(img) self.predictor.run() outputs = [] diff --git a/deploy/pipeline/ppvehicle/vehicle_plateutils.py b/deploy/pipeline/ppvehicle/vehicle_plateutils.py index 431b64720..4a7b792da 100644 --- a/deploy/pipeline/ppvehicle/vehicle_plateutils.py +++ b/deploy/pipeline/ppvehicle/vehicle_plateutils.py @@ -61,14 +61,13 @@ def create_predictor(args, cfg, mode): 'trt_fp32': inference.PrecisionType.Float32, 'trt_fp16': inference.PrecisionType.Half } + min_subgraph_size = 15 if args.run_mode in precision_map.keys(): config.enable_tensorrt_engine( workspace_size=(1 << 25) * batch_size, max_batch_size=batch_size, min_subgraph_size=min_subgraph_size, - precision_mode=precision_map[args.run_mode], - use_static=False, - use_calib_mode=trt_calib_mode) + precision_mode=precision_map[args.run_mode]) use_dynamic_shape = True if mode == "det": diff --git a/deploy/python/preprocess.py b/deploy/python/preprocess.py index d447c744b..4fc80d1a3 100644 --- a/deploy/python/preprocess.py +++ b/deploy/python/preprocess.py @@ -89,21 +89,15 @@ class Resize_Mult32(object): # limit the max side if self.limit_type == 'max': - if max(h, w) > limit_side_len: - if h > w: - ratio = float(limit_side_len) / h - else: - ratio = float(limit_side_len) / w + if h > w: + ratio = float(limit_side_len) / h else: - ratio = 1. + ratio = float(limit_side_len) / w elif self.limit_type == 'min': - if min(h, w) < limit_side_len: - if h < w: - ratio = float(limit_side_len) / h - else: - ratio = float(limit_side_len) / w + if h < w: + ratio = float(limit_side_len) / h else: - ratio = 1. + ratio = float(limit_side_len) / w elif self.limit_type == 'resize_long': ratio = float(limit_side_len) / max(h, w) else: -- GitLab