From de39e70332c899a7ef9b19b014ac6a7973b7281c Mon Sep 17 00:00:00 2001 From: LokeZhou Date: Thu, 26 Jan 2023 23:41:25 +0800 Subject: [PATCH] pipeline.py add tracking module time info (#7627) * pipeline.py add tracking module time fix infer_cfg_vehicle_violation.yml for examples * pipeline examples infer_cfg_vehicle_violation.yml delete irrelevant config * fix infer_cfg_vehicle_violation.yml enable --- .../examples/infer_cfg_vehicle_violation.yml | 7 ++-- deploy/pipeline/config/tracker_config.yml | 35 ++++++++++++++++--- deploy/pipeline/pipeline.py | 4 ++- deploy/pptracking/python/mot_utils.py | 34 ++++++++++++++++++ 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/deploy/pipeline/config/examples/infer_cfg_vehicle_violation.yml b/deploy/pipeline/config/examples/infer_cfg_vehicle_violation.yml index 822ef66f4..5c3119b8f 100644 --- a/deploy/pipeline/config/examples/infer_cfg_vehicle_violation.yml +++ b/deploy/pipeline/config/examples/infer_cfg_vehicle_violation.yml @@ -24,7 +24,8 @@ VEHICLE_RETROGRADE: frame_len: 8 sample_freq: 7 enable: True - filter_horizontal_flag: False - deviation: 23 + filter_horizontal_flag: True + keep_right_flag: True + deviation: 45 move_scale: 0.01 - fence_line: [] #[x1,y1,x2,y2] y2>y1. + fence_line: [570, 163, 1030, 752] #[x1,y1,x2,y2] y2>y1. diff --git a/deploy/pipeline/config/tracker_config.yml b/deploy/pipeline/config/tracker_config.yml index c4f3c8946..c4a3f6026 100644 --- a/deploy/pipeline/config/tracker_config.yml +++ b/deploy/pipeline/config/tracker_config.yml @@ -1,11 +1,12 @@ -# config of tracker for MOT SDE Detector, use 'JDETracker' as default. +# config of tracker for MOT SDE Detector, use 'OCSORTTracker' as default, 'JDETracker' here is just BYTETracker. # The tracker of MOT JDE Detector (such as FairMOT) is exported together with the model. # Here 'min_box_area' and 'vertical_ratio' are set for pedestrian, you can modify for other objects tracking. -type: OCSORTTracker # choose one tracker in ['JDETracker', 'OCSORTTracker'] +type: BOTSORTTracker # choose one tracker in ['JDETracker', 'OCSORTTracker', 'DeepSORTTracker','BOTSORTTracker'] +# When using for MTMCT(Multi-Target Multi-Camera Tracking), you should modify to 'DeepSORTTracker' -# BYTETracker +# just as BYTETracker, used for FairMOT in PP-Tracking project and for ByteTrack in PP-Humanv1 project JDETracker: use_byte: True det_thresh: 0.3 @@ -16,6 +17,7 @@ JDETracker: vertical_ratio: 0 # 1.6 for pedestrian +# used for OC-SORT in PP-Humanv2 project and PP-Vehicle project OCSORTTracker: det_thresh: 0.4 max_age: 30 @@ -23,6 +25,31 @@ OCSORTTracker: iou_threshold: 0.3 delta_t: 3 inertia: 0.2 - vertical_ratio: 0 min_box_area: 0 + vertical_ratio: 0 use_byte: False + use_angle_cost: False + + +# used for DeepSORT and MTMCT in PP-Tracking project +DeepSORTTracker: + input_size: [64, 192] # An unique operation to scale the sub-image of the selected detected boxes to a fixed size + min_box_area: 0 + vertical_ratio: -1 + budget: 100 + max_age: 70 + n_init: 3 + metric_type: cosine + matching_threshold: 0.2 + max_iou_distance: 0.9 + +BOTSORTTracker: + track_high_thresh: 0.3 + track_low_thresh: 0.2 + new_track_thresh: 0.4 + match_thresh: 0.7 + track_buffer: 30 + min_box_area: 0 + camera_motion: False + cmc_method: 'sparseOptFlow' # only camera_motion is True, + # sparseOptFlow | files (Vidstab GMC) | orb | ecc diff --git a/deploy/pipeline/pipeline.py b/deploy/pipeline/pipeline.py index 049e6272c..80af8c521 100644 --- a/deploy/pipeline/pipeline.py +++ b/deploy/pipeline/pipeline.py @@ -530,6 +530,7 @@ class PipePredictor(object): else: self.predict_image(input) self.pipe_timer.info() + self.mot_predictor.det_times.tracking_info(average=True) def predict_image(self, input): # det @@ -747,7 +748,8 @@ class PipePredictor(object): res = self.mot_predictor.predict_image( [copy.deepcopy(frame_rgb)], visual=False, - reuse_det_result=reuse_det_result) + reuse_det_result=reuse_det_result, + frame_count=frame_id) # mot output format: id, class, score, xmin, ymin, xmax, ymax mot_res = parse_mot_res(res) diff --git a/deploy/pptracking/python/mot_utils.py b/deploy/pptracking/python/mot_utils.py index 3b2553402..9d7b18f92 100644 --- a/deploy/pptracking/python/mot_utils.py +++ b/deploy/pptracking/python/mot_utils.py @@ -271,6 +271,40 @@ class Timer(Times): format(preprocess_time * 1000, inference_time * 1000, postprocess_time * 1000)) + def tracking_info(self, average=True): + pre_time = self.preprocess_time_s.value() + infer_time = self.inference_time_s.value() + post_time = self.postprocess_time_s.value() + track_time = self.tracking_time_s.value() + + total_time = pre_time + infer_time + post_time + if self.with_tracker: + total_time = total_time + track_time + total_time = round(total_time, 4) + print( + "------------------ Tracking Module Time Info ----------------------" + ) + + preprocess_time = round(pre_time / max(1, self.img_num), + 4) if average else pre_time + postprocess_time = round(post_time / max(1, self.img_num), + 4) if average else post_time + inference_time = round(infer_time / max(1, self.img_num), + 4) if average else infer_time + tracking_time = round(track_time / max(1, self.img_num), + 4) if average else track_time + + if self.with_tracker: + print( + "preprocess_time(ms): {:.2f}, inference_time(ms): {:.2f}, postprocess_time(ms): {:.2f}, tracking_time(ms): {:.2f}". + format(preprocess_time * 1000, inference_time * 1000, + postprocess_time * 1000, tracking_time * 1000)) + else: + print( + "preprocess_time(ms): {:.2f}, inference_time(ms): {:.2f}, postprocess_time(ms): {:.2f}". + format(preprocess_time * 1000, inference_time * 1000, + postprocess_time * 1000)) + def report(self, average=False): dic = {} pre_time = self.preprocess_time_s.value() -- GitLab