diff --git a/pdseg/data_aug.py b/pdseg/data_aug.py index 30a6d004459bf66391acd791cc1ba4fb9721acca..474fba9a1236ee8db478a45dd5355f225c875afb 100644 --- a/pdseg/data_aug.py +++ b/pdseg/data_aug.py @@ -410,7 +410,7 @@ def rand_crop(crop_img, crop_seg, mode=ModelPhase.TRAIN): 0, pad_width, cv2.BORDER_CONSTANT, - value=cfg.MEAN) + value=cfg.DATASET.PADDING_VALUE) if crop_seg is not None: crop_seg = cv2.copyMakeBorder( crop_seg, diff --git a/pdseg/reader.py b/pdseg/reader.py index c839828cf99b89ceff62837cd6877a5659f80d06..e53b5912e07b1591d4014314f809e6997d925731 100644 --- a/pdseg/reader.py +++ b/pdseg/reader.py @@ -246,7 +246,7 @@ class SegDataset(object): img, grt, rich_crop_max_rotation=cfg.AUG.RICH_CROP.MAX_ROTATION, - mean_value=cfg.MEAN) + mean_value=cfg.DATASET.PADDING_VALUE) img, grt = aug.rand_scale_aspect( img, diff --git a/pdseg/train.py b/pdseg/train.py index 295468ef14b87d8f4886fe0203d362bef3611a42..22a430f7f1bd3ff4c5c1e5ee28a624badc3cac41 100644 --- a/pdseg/train.py +++ b/pdseg/train.py @@ -292,7 +292,7 @@ def train(cfg): for var in load_vars: print("Parameter[{}] loaded sucessfully!".format(var.name)) for var in load_fail_vars: - print("Parameter[{}] shape does not match current network, skip" + print("Parameter[{}] don't exist or shape does not match current network, skip" " to load it.".format(var.name)) print("{}/{} pretrained parameters loaded successfully!".format( len(load_vars), diff --git a/pdseg/utils/collect.py b/pdseg/utils/collect.py index 010a5c4bcc7bc84b9bb21cdf4f845c4ad3de3dbc..6b8f2f4eb0b4c98ce3078812f41dacafc3097bc1 100644 --- a/pdseg/utils/collect.py +++ b/pdseg/utils/collect.py @@ -97,6 +97,8 @@ class SegConfig(dict): raise KeyError( 'DATASET.IMAGE_TYPE config error, only support `rgb`, `gray` and `rgba`' ) + if self.MEAN is not None: + self.DATASET.PADDING_VALUE = [x*255.0 for x in self.MEAN] if not self.TRAIN_CROP_SIZE: raise ValueError( diff --git a/pdseg/utils/config.py b/pdseg/utils/config.py index c7ffcb4c9e78ea644b2348c6fb8d5eb052110922..332a5143cfb837160be674c0ccc0bf8edc428000 100644 --- a/pdseg/utils/config.py +++ b/pdseg/utils/config.py @@ -65,6 +65,8 @@ cfg.DATASET.DATA_DIM = 3 cfg.DATASET.SEPARATOR = ' ' # 忽略的像素标签值, 默认为255,一般无需改动 cfg.DATASET.IGNORE_INDEX = 255 +# 数据增强是图像的padding值 +cfg.DATASET.PADDING_VALUE = [127.5,127.5,127.5] ########################### 数据增强配置 ###################################### # 图像镜像左右翻转