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

fix decode permute rgb (#3198)

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