From 1c582c26910cdc025304a8479bcf1074f31db9c6 Mon Sep 17 00:00:00 2001 From: George Ni Date: Thu, 13 May 2021 20:46:40 +0800 Subject: [PATCH] [MOT] Fix JDE gt_ide, transform and nms (#2993) * fix hsv randomaffine * fix nms return_index * fix gt_ide by tid_start_index --- configs/mot/jde/_base_/jde_reader_1088x608.yml | 2 +- configs/mot/jde/jde_darknet53_30e_1088x608.yml | 1 + ppdet/data/source/mot.py | 3 +++ ppdet/data/transform/operators.py | 16 ++++++++++++---- ppdet/modeling/layers.py | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/configs/mot/jde/_base_/jde_reader_1088x608.yml b/configs/mot/jde/_base_/jde_reader_1088x608.yml index fc98fe374..8855041a2 100644 --- a/configs/mot/jde/_base_/jde_reader_1088x608.yml +++ b/configs/mot/jde/_base_/jde_reader_1088x608.yml @@ -4,7 +4,7 @@ TrainReader: - Decode: {} - AugmentHSV: {} - LetterBoxResize: {target_size: [608, 1088]} - - RandomAffine: {} + - MOTRandomAffine: {} - RandomFlip: {} - BboxXYXY2XYWH: {} - NormalizeBox: {} diff --git a/configs/mot/jde/jde_darknet53_30e_1088x608.yml b/configs/mot/jde/jde_darknet53_30e_1088x608.yml index 2549e2811..9aa2eaa96 100644 --- a/configs/mot/jde/jde_darknet53_30e_1088x608.yml +++ b/configs/mot/jde/jde_darknet53_30e_1088x608.yml @@ -44,3 +44,4 @@ JDEBBoxPostProcess: nms_threshold: 0.4 nms_top_k: 2000 normalized: true + return_index: true diff --git a/ppdet/data/source/mot.py b/ppdet/data/source/mot.py index e38432c9b..ba7e9d205 100644 --- a/ppdet/data/source/mot.py +++ b/ppdet/data/source/mot.py @@ -214,6 +214,9 @@ class MOTDataSet(DetDataset): gt_class = labels[:, 0:1].astype('int32') gt_score = np.ones((len(labels), 1)).astype('float32') gt_ide = labels[:, 1:2].astype('int32') + for i, _ in enumerate(gt_ide): + if gt_ide[i] > -1: + gt_ide[i] += self.tid_start_index[data_name] mot_rec = { 'im_file': img_file, diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index 2af79df15..cc6218857 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -2014,7 +2014,7 @@ class Rbox2Poly(BaseOperator): @register_op class AugmentHSV(BaseOperator): - def __init__(self, fraction=0.50, is_bgr=True): + def __init__(self, fraction=0.50, is_bgr=False): """ Augment the SV channel of image data. Args: @@ -2075,7 +2075,7 @@ class Norm2PixelBbox(BaseOperator): @register_op -class RandomAffine(BaseOperator): +class MOTRandomAffine(BaseOperator): def __init__(self, degrees=(-5, 5), translate=(0.10, 0.10), @@ -2083,9 +2083,17 @@ class RandomAffine(BaseOperator): shear=(-2, 2), borderValue=(127.5, 127.5, 127.5)): """ - Transform the image data with random affine + Affine transform to image and coords to achieve the rotate, scale and + shift effect for training image. + + Args: + degrees (tuple): rotation value + translate (tuple): xy coords translation value + scale (tuple): scale value + shear (tuple): shear value + borderValue (tuple): border color value """ - super(RandomAffine, self).__init__() + super(MOTRandomAffine, self).__init__() self.degrees = degrees self.translate = translate self.scale = scale diff --git a/ppdet/modeling/layers.py b/ppdet/modeling/layers.py index b6c13f38a..b420d51fe 100644 --- a/ppdet/modeling/layers.py +++ b/ppdet/modeling/layers.py @@ -410,6 +410,7 @@ class MultiClassNMS(object): nms_threshold=.5, normalized=True, nms_eta=1.0, + return_index=False, return_rois_num=True): super(MultiClassNMS, self).__init__() self.score_threshold = score_threshold @@ -418,6 +419,7 @@ class MultiClassNMS(object): self.nms_threshold = nms_threshold self.normalized = normalized self.nms_eta = nms_eta + self.return_index = return_index self.return_rois_num = return_rois_num def __call__(self, bboxes, score, background_label=-1): -- GitLab