未验证 提交 d585c310 编写于 作者: G George Ni 提交者: GitHub

fix decode permute rgb (#3198)

上级 6b74c762
...@@ -3,15 +3,17 @@ TrainReader: ...@@ -3,15 +3,17 @@ TrainReader:
inputs_def: inputs_def:
image_shape: [3, 608, 1088] image_shape: [3, 608, 1088]
sample_transforms: sample_transforms:
- Decode: {to_rgb: False} - Decode: {}
- AugmentHSV: {is_bgr: True} - RGBReverse: {}
- AugmentHSV: {}
- LetterBoxResize: {target_size: [608, 1088]} - LetterBoxResize: {target_size: [608, 1088]}
- MOTRandomAffine: {reject_outside: False} - MOTRandomAffine: {reject_outside: False}
- RandomFlip: {} - RandomFlip: {}
- BboxXYXY2XYWH: {} - BboxXYXY2XYWH: {}
- NormalizeBox: {} - NormalizeBox: {}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]}
- Permute: {to_rgb: True} - RGBReverse: {}
- Permute: {}
batch_transforms: batch_transforms:
- Gt2FairMOTTarget: {} - Gt2FairMOTTarget: {}
batch_size: 6 batch_size: 6
...@@ -23,10 +25,10 @@ EvalMOTReader: ...@@ -23,10 +25,10 @@ EvalMOTReader:
inputs_def: inputs_def:
image_shape: [3, 608, 1088] image_shape: [3, 608, 1088]
sample_transforms: sample_transforms:
- Decode: {to_rgb: False} - Decode: {}
- LetterBoxResize: {target_size: [608, 1088]} - LetterBoxResize: {target_size: [608, 1088]}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]}
- Permute: {to_rgb: True} - Permute: {}
batch_size: 1 batch_size: 1
...@@ -36,5 +38,5 @@ TestMOTReader: ...@@ -36,5 +38,5 @@ TestMOTReader:
sample_transforms: sample_transforms:
- LetterBoxResize: {target_size: [608, 1088]} - LetterBoxResize: {target_size: [608, 1088]}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1]}
- Permute: {to_rgb: True} - Permute: {}
batch_size: 1 batch_size: 1
...@@ -2,6 +2,7 @@ worker_num: 2 ...@@ -2,6 +2,7 @@ worker_num: 2
TrainReader: TrainReader:
sample_transforms: sample_transforms:
- Decode: {} - Decode: {}
- RGBReverse: {}
- AugmentHSV: {} - AugmentHSV: {}
- LetterBoxResize: {target_size: [608, 1088]} - LetterBoxResize: {target_size: [608, 1088]}
- MOTRandomAffine: {} - MOTRandomAffine: {}
...@@ -9,6 +10,7 @@ TrainReader: ...@@ -9,6 +10,7 @@ TrainReader:
- BboxXYXY2XYWH: {} - BboxXYXY2XYWH: {}
- NormalizeBox: {} - NormalizeBox: {}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}
- RGBReverse: {}
- Permute: {} - Permute: {}
batch_transforms: batch_transforms:
- Gt2JDETargetThres: - Gt2JDETargetThres:
......
...@@ -2,6 +2,7 @@ worker_num: 2 ...@@ -2,6 +2,7 @@ worker_num: 2
TrainReader: TrainReader:
sample_transforms: sample_transforms:
- Decode: {} - Decode: {}
- RGBReverse: {}
- AugmentHSV: {} - AugmentHSV: {}
- LetterBoxResize: {target_size: [320, 576]} - LetterBoxResize: {target_size: [320, 576]}
- MOTRandomAffine: {} - MOTRandomAffine: {}
...@@ -9,11 +10,12 @@ TrainReader: ...@@ -9,11 +10,12 @@ TrainReader:
- BboxXYXY2XYWH: {} - BboxXYXY2XYWH: {}
- NormalizeBox: {} - NormalizeBox: {}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}
- RGBReverse: {}
- Permute: {} - Permute: {}
batch_transforms: batch_transforms:
- Gt2JDETargetThres: - Gt2JDETargetThres:
anchor_masks: [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]] anchor_masks: [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
anchors: [[[85,255], [120,320], [170,320], [340,320]], anchors: [[[85,255], [120,360], [170,420], [340,420]],
[[21,64], [30,90], [43,128], [60,180]], [[21,64], [30,90], [43,128], [60,180]],
[[6,16], [8,23], [11,32], [16,45]]] [[6,16], [8,23], [11,32], [16,45]]]
downsample_ratios: [32, 16, 8] downsample_ratios: [32, 16, 8]
......
...@@ -2,6 +2,7 @@ worker_num: 2 ...@@ -2,6 +2,7 @@ worker_num: 2
TrainReader: TrainReader:
sample_transforms: sample_transforms:
- Decode: {} - Decode: {}
- RGBReverse: {}
- AugmentHSV: {} - AugmentHSV: {}
- LetterBoxResize: {target_size: [480, 864]} - LetterBoxResize: {target_size: [480, 864]}
- MOTRandomAffine: {} - MOTRandomAffine: {}
...@@ -9,6 +10,7 @@ TrainReader: ...@@ -9,6 +10,7 @@ TrainReader:
- BboxXYXY2XYWH: {} - BboxXYXY2XYWH: {}
- NormalizeBox: {} - NormalizeBox: {}
- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True} - NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}
- RGBReverse: {}
- Permute: {} - Permute: {}
batch_transforms: batch_transforms:
- Gt2JDETargetThres: - Gt2JDETargetThres:
......
...@@ -20,7 +20,7 @@ YOLOv3: ...@@ -20,7 +20,7 @@ YOLOv3:
for_mot: True for_mot: True
YOLOv3Head: YOLOv3Head:
anchors: [[85,255], [120,320], [170,320], [340,320], anchors: [[85,255], [120,360], [170,420], [340,420],
[21,64], [30,90], [43,128], [60,180], [21,64], [30,90], [43,128], [60,180],
[6,16], [8,23], [11,32], [16,45]] [6,16], [8,23], [11,32], [16,45]]
anchor_masks: [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]] anchor_masks: [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
......
...@@ -36,11 +36,25 @@ from ppdet.utils.logger import setup_logger ...@@ -36,11 +36,25 @@ from ppdet.utils.logger import setup_logger
logger = setup_logger(__name__) logger = setup_logger(__name__)
__all__ = [ __all__ = [
'LetterBoxResize', 'MOTRandomAffine', 'Gt2JDETargetThres', 'RGBReverse', 'LetterBoxResize', 'MOTRandomAffine', 'Gt2JDETargetThres',
'Gt2JDETargetMax', 'Gt2FairMOTTarget' 'Gt2JDETargetMax', 'Gt2FairMOTTarget'
] ]
@register_op
class RGBReverse(BaseOperator):
"""RGB to BGR, or BGR to RGB, sensitive to MOTRandomAffine
"""
def __init__(self):
super(RGBReverse, self).__init__()
def apply(self, sample, context=None):
im = sample['image']
sample['image'] = np.ascontiguousarray(im[:, :, ::-1])
return sample
@register_op @register_op
class LetterBoxResize(BaseOperator): class LetterBoxResize(BaseOperator):
def __init__(self, target_size): def __init__(self, target_size):
......
...@@ -107,12 +107,10 @@ class BaseOperator(object): ...@@ -107,12 +107,10 @@ class BaseOperator(object):
@register_op @register_op
class Decode(BaseOperator): class Decode(BaseOperator):
def __init__(self, to_rgb=True): def __init__(self):
""" Transform the image data to numpy format following the rgb format """ Transform the image data to numpy format following the rgb format
""" """
super(Decode, self).__init__() super(Decode, self).__init__()
# TODO: remove this parameter
self.to_rgb = to_rgb
def apply(self, sample, context=None): def apply(self, sample, context=None):
""" load image if 'im_file' field is not empty but 'image' is""" """ load image if 'im_file' field is not empty but 'image' is"""
...@@ -126,7 +124,6 @@ class Decode(BaseOperator): ...@@ -126,7 +124,6 @@ class Decode(BaseOperator):
im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode
if 'keep_ori_im' in sample and sample['keep_ori_im']: if 'keep_ori_im' in sample and sample['keep_ori_im']:
sample['ori_image'] = im sample['ori_image'] = im
if self.to_rgb:
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
sample['image'] = im sample['image'] = im
...@@ -154,18 +151,14 @@ class Decode(BaseOperator): ...@@ -154,18 +151,14 @@ class Decode(BaseOperator):
@register_op @register_op
class Permute(BaseOperator): class Permute(BaseOperator):
def __init__(self, to_rgb=False): def __init__(self):
""" """
Change the channel to be (C, H, W) Change the channel to be (C, H, W)
""" """
super(Permute, self).__init__() super(Permute, self).__init__()
# TODO: remove this parameter
self.to_rgb = to_rgb
def apply(self, sample, context=None): def apply(self, sample, context=None):
im = sample['image'] im = sample['image']
if self.to_rgb:
im = np.ascontiguousarray(im[:, :, ::-1])
im = im.transpose((2, 0, 1)) im = im.transpose((2, 0, 1))
sample['image'] = im sample['image'] = im
return sample return sample
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册