From cb7933cf82e1d12394a6757b9b526e829a256257 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Wed, 11 Nov 2020 20:57:09 +0800 Subject: [PATCH 01/35] update `category` to `class` --- dygraph/paddleseg/core/val.py | 10 +++++----- dygraph/paddleseg/utils/metrics.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dygraph/paddleseg/core/val.py b/dygraph/paddleseg/core/val.py index 07952d22ee..d7f605def8 100644 --- a/dygraph/paddleseg/core/val.py +++ b/dygraph/paddleseg/core/val.py @@ -132,13 +132,13 @@ def evaluate(model, eval_dataset=None, iter_id=None, num_workers=0): if local_rank == 0: progbar_val.update(iter + 1) - category_iou, miou = metrics.mean_iou(intersect_area_all, pred_area_all, - label_area_all) - category_acc, acc = metrics.accuracy(intersect_area_all, pred_area_all) + class_iou, miou = metrics.mean_iou(intersect_area_all, pred_area_all, + label_area_all) + class_acc, acc = metrics.accuracy(intersect_area_all, pred_area_all) kappa = metrics.kappa(intersect_area_all, pred_area_all, label_area_all) logger.info("[EVAL] #Images={} mIoU={:.4f} Acc={:.4f} Kappa={:.4f} ".format( len(eval_dataset), miou, acc, kappa)) - logger.info("[EVAL] Category IoU: \n" + str(np.round(category_iou, 4))) - logger.info("[EVAL] Category Acc: \n" + str(np.round(category_acc, 4))) + logger.info("[EVAL] Class IoU: \n" + str(np.round(class_iou, 4))) + logger.info("[EVAL] Class Acc: \n" + str(np.round(class_acc, 4))) return miou, acc diff --git a/dygraph/paddleseg/utils/metrics.py b/dygraph/paddleseg/utils/metrics.py index 7106d8e3c0..ad5b3c9758 100644 --- a/dygraph/paddleseg/utils/metrics.py +++ b/dygraph/paddleseg/utils/metrics.py @@ -88,15 +88,15 @@ def mean_iou(intersect_area, pred_area, label_area): pred_area = pred_area.numpy() label_area = label_area.numpy() union = pred_area + label_area - intersect_area - category_iou = [] + class_iou = [] for i in range(len(intersect_area)): if union[i] == 0: iou = 0 else: iou = intersect_area[i] / union[i] - category_iou.append(iou) - miou = np.mean(category_iou) - return np.array(category_iou), miou + class_iou.append(iou) + miou = np.mean(class_iou) + return np.array(class_iou), miou def accuracy(intersect_area, pred_area): @@ -113,15 +113,15 @@ def accuracy(intersect_area, pred_area): """ intersect_area = intersect_area.numpy() pred_area = pred_area.numpy() - category_acc = [] + class_acc = [] for i in range(len(intersect_area)): if pred_area[i] == 0: acc = 0 else: acc = intersect_area[i] / pred_area[i] - category_acc.append(acc) + class_acc.append(acc) macc = np.sum(intersect_area) / np.sum(pred_area) - return np.array(category_acc), macc + return np.array(class_acc), macc def kappa(intersect_area, pred_area, label_area): From ed0e1a3052e4960debe2c26d51b81107b1400e23 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 13 Nov 2020 10:41:40 +0800 Subject: [PATCH 02/35] add voc and ade20k config --- dygraph/configs/_base_/ade20k.yml | 6 ++- dygraph/configs/_base_/pascal_voc12.yml | 47 +++++++++++++++++++ dygraph/configs/_base_/pascal_voc12aug.yml | 41 +--------------- .../fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml | 14 ++++++ 4 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 dygraph/configs/_base_/pascal_voc12.yml create mode 100644 dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/_base_/ade20k.yml b/dygraph/configs/_base_/ade20k.yml index e5ad008d66..115a9371ba 100644 --- a/dygraph/configs/_base_/ade20k.yml +++ b/dygraph/configs/_base_/ade20k.yml @@ -1,5 +1,5 @@ batch_size: 4 -iters: 160000 +iters: 80000 train_dataset: type: ADE20K @@ -12,6 +12,10 @@ train_dataset: - type: RandomPaddingCrop crop_size: [512, 512] - type: RandomHorizontalFlip + - type: RandomDistort + brightness_range: 0.4 + contrast_range: 0.4 + saturation_range: 0.4 - type: Normalize mode: train diff --git a/dygraph/configs/_base_/pascal_voc12.yml b/dygraph/configs/_base_/pascal_voc12.yml new file mode 100644 index 0000000000..d307a77721 --- /dev/null +++ b/dygraph/configs/_base_/pascal_voc12.yml @@ -0,0 +1,47 @@ +batch_size: 4 +iters: 40000 + +train_dataset: + type: PascalVOC + dataset_root: data/VOCdevkit/ + transforms: + - type: ResizeStepScaling + min_scale_factor: 0.5 + max_scale_factor: 2.0 + scale_step_size: 0.25 + - type: RandomPaddingCrop + crop_size: [512, 512] + - type: RandomHorizontalFlip + - type: RandomDistort + brightness_range: 0.4 + contrast_range: 0.4 + saturation_range: 0.4 + - type: Normalize + mode: train + +val_dataset: + type: PascalVOC + dataset_root: data/VOCdevkit/ + transforms: + - type: Padding + target_size: [512, 512] + - type: Normalize + mode: val + + +optimizer: + type: sgd + momentum: 0.9 + weight_decay: 4.0e-5 + +learning_rate: + value: 0.01 + decay: + type: poly + power: 0.9 + end_lr: 0.0 + +loss: + types: + - type: CrossEntropyLoss + coef: [1] diff --git a/dygraph/configs/_base_/pascal_voc12aug.yml b/dygraph/configs/_base_/pascal_voc12aug.yml index d85700b02e..66fec2a5e2 100644 --- a/dygraph/configs/_base_/pascal_voc12aug.yml +++ b/dygraph/configs/_base_/pascal_voc12aug.yml @@ -1,43 +1,4 @@ -batch_size: 4 -iters: 40000 +_base_: './pascal_voc12.yml' train_dataset: - type: PascalVOC - dataset_root: data/VOCdevkit/ - transforms: - - type: ResizeStepScaling - min_scale_factor: 0.5 - max_scale_factor: 2.0 - scale_step_size: 0.25 - - type: RandomPaddingCrop - crop_size: [512, 512] - - type: RandomHorizontalFlip - - type: Normalize mode: trainaug - -val_dataset: - type: PascalVOC - dataset_root: data/VOCdevkit/ - transforms: - - type: Padding - target_size: [512, 512] - - type: Normalize - mode: val - - -optimizer: - type: sgd - momentum: 0.9 - weight_decay: 4.0e-5 - -learning_rate: - value: 0.01 - decay: - type: poly - power: 0.9 - end_lr: 0.0 - -loss: - types: - - type: CrossEntropyLoss - coef: [1] diff --git a/dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml b/dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..4003814df2 --- /dev/null +++ b/dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml @@ -0,0 +1,14 @@ +_base_: '../_base_/pascal_voc12aug.yml' + +model: + type: FCN + backbone: + type: HRNet_W18 + align_corners: False + pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w18_ssld.tar.gz + num_classes: 21 + pretrained: Null + backbone_indices: [-1] + +optimizer: + weight_decay: 0.0005 From c6a0e903f4592eccf0789c2868b9bb7ea883a84e Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Fri, 13 Nov 2020 10:44:02 +0800 Subject: [PATCH 03/35] add ms_flip and sliding window (#576) --- dygraph/configs/ann/README.md | 8 +- dygraph/configs/deeplabv3/README.md | 8 +- dygraph/configs/deeplabv3p/README.md | 8 +- ...p_resnet101_os8_cityscapes_769x769_80k.yml | 18 ++ dygraph/configs/fastscnn/README.md | 6 +- dygraph/configs/fcn/README.md | 8 +- dygraph/configs/gcnet/README.md | 8 +- dygraph/configs/ocrnet/README.md | 8 +- dygraph/configs/pspnet/README.md | 8 +- dygraph/configs/unet/README.md | 6 +- dygraph/paddleseg/core/__init__.py | 3 +- dygraph/paddleseg/core/infer.py | 233 ++++++++++++++++++ dygraph/paddleseg/core/predict.py | 60 +++-- dygraph/paddleseg/core/train.py | 2 +- dygraph/paddleseg/core/val.py | 79 +++--- dygraph/predict.py | 63 ++++- dygraph/val.py | 60 ++++- 17 files changed, 481 insertions(+), 105 deletions(-) create mode 100644 dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml create mode 100644 dygraph/paddleseg/core/infer.py diff --git a/dygraph/configs/ann/README.md b/dygraph/configs/ann/README.md index 847d03e631..959e7d2b70 100644 --- a/dygraph/configs/ann/README.md +++ b/dygraph/configs/ann/README.md @@ -8,7 +8,7 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|ANN|ResNet50_OS8|1024x512|80000|79.09%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=b849c8e06b6ccd33514d436635b9e102)| -|ANN|ResNet101_OS8|1024x512|80000|80.61%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=ed1cb9321385f1480dda418db71bd4c0)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|ANN|ResNet50_OS8|1024x512|80000|79.09%|79.31%|79.56%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=b849c8e06b6ccd33514d436635b9e102)| +|ANN|ResNet101_OS8|1024x512|80000|80.61%|80.98%|81.25%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/ann_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=ed1cb9321385f1480dda418db71bd4c0)| diff --git a/dygraph/configs/deeplabv3/README.md b/dygraph/configs/deeplabv3/README.md index 52eead50fb..2949ea40a7 100644 --- a/dygraph/configs/deeplabv3/README.md +++ b/dygraph/configs/deeplabv3/README.md @@ -8,7 +8,7 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|DeepLabV3|ResNet50_OS8|1024x512|80000|79.90%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=7e30d1cb34cd94400e1e1266538dfb6c)| -|DeepLabV3|ResNet101_OS8|1024x512|80000|80.85%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=1ff25b7f3c5e88a051b9dd273625f942)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|DeepLabV3|ResNet50_OS8|1024x512|80000|79.90%|80.22%|80.47%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=7e30d1cb34cd94400e1e1266538dfb6c)| +|DeepLabV3|ResNet101_OS8|1024x512|80000|80.85%|81.09%|81.54%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=1ff25b7f3c5e88a051b9dd273625f942)| diff --git a/dygraph/configs/deeplabv3p/README.md b/dygraph/configs/deeplabv3p/README.md index 65b3467890..13f03c59ae 100644 --- a/dygraph/configs/deeplabv3p/README.md +++ b/dygraph/configs/deeplabv3p/README.md @@ -8,6 +8,8 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|DeepLabV3P|ResNet50_OS8|1024x512|80000|80.36%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=860bd0049ba5495d629a96d5aaf1bf75)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|DeepLabV3P|ResNet50_OS8|1024x512|80000|80.36%|80.57%|80.81%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=860bd0049ba5495d629a96d5aaf1bf75)| +|DeepLabV3P|ResNet101_OS8|1024x512|80000|81.10%|81.38%|81.24%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=8b11e75b8977a0fd74180145350c27de)| +|DeepLabV3P|ResNet101_OS8|769x769|80000|81.53%|81.88%|82.12%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet101_os8_cityscapes_769x769_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/deeplabv3p_resnet101_os8_cityscapes_769x769_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=420039406361cbc3cf7ec14c1084d886)| diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml b/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml new file mode 100644 index 0000000000..752a3d926f --- /dev/null +++ b/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml @@ -0,0 +1,18 @@ +_base_: '../_base_/cityscapes_769x769.yml' + +batch_size: 2 +iters: 80000 + +model: + type: DeepLabV3P + backbone: + type: ResNet101_vd + output_stride: 8 + multi_grid: [1, 2, 4] + pretrained: https://bj.bcebos.com/paddleseg/dygraph/resnet101_vd_ssld.tar.gz + num_classes: 19 + backbone_indices: [0, 3] + aspp_ratios: [1, 12, 24, 36] + aspp_out_channels: 256 + align_corners: True + pretrained: null diff --git a/dygraph/configs/fastscnn/README.md b/dygraph/configs/fastscnn/README.md index 6ded1f0ce5..541fea2a88 100644 --- a/dygraph/configs/fastscnn/README.md +++ b/dygraph/configs/fastscnn/README.md @@ -8,6 +8,6 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|Fast SCNN|-|1024x1024|160000|69.31%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fastscnn_cityscapes_1024x1024_160k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fastscnn_cityscapes_1024x1024_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=3b4c3f01c9213cac14e53c69d262a337)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|Fast SCNN|-|1024x1024|160000|69.31%|-|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fastscnn_cityscapes_1024x1024_160k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fastscnn_cityscapes_1024x1024_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=3b4c3f01c9213cac14e53c69d262a337)| diff --git a/dygraph/configs/fcn/README.md b/dygraph/configs/fcn/README.md index bcacfdca18..8fbe94e976 100644 --- a/dygraph/configs/fcn/README.md +++ b/dygraph/configs/fcn/README.md @@ -7,7 +7,7 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|FCN|HRNet_W18|1024x512|80000|80.34%|-|[model](https://paddleseg.bj.bcebos.com/dygraph/fcn_hrnetw18_cityscapes_1024x512_80k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/fcn_hrnetw18_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=141ed1c7aa77474ec2a2d063713570f9)| -|FCN|HRNet_W48|1024x512|80000|81.17%|-|[model](https://paddleseg.bj.bcebos.com/dygraph/fcn_hrnetw48_cityscapes_1024x512_80k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/fcn_hrnetw48_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=6f219d4b9bab266385ab6023ea097aa6)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|FCN|HRNet_W18|1024x512|80000|78.97%|79.49%|79.74%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=bebec8e1a3802c4babd3c69e1bf50d51)| +|FCN|HRNet_W48|1024x512|80000|80.70%|81.24%|81.56%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw48_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw48_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=ae1cb76014cdc54406c36f1e3dc2a530)| diff --git a/dygraph/configs/gcnet/README.md b/dygraph/configs/gcnet/README.md index f49ce03442..06899ed741 100644 --- a/dygraph/configs/gcnet/README.md +++ b/dygraph/configs/gcnet/README.md @@ -8,7 +8,7 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|GCNet|ResNet50_OS8|1024x512|80000|79.50%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=e3801edb9a6f5b33eb890f5a1ae6ed7b)| -|GCNet|ResNet101_OS8|1024x512|80000|81.01%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://www.paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=aa88e7980f4d6839537662a3a3d18851)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|GCNet|ResNet50_OS8|1024x512|80000|79.50%|79.77%|79.69%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=e3801edb9a6f5b33eb890f5a1ae6ed7b)| +|GCNet|ResNet101_OS8|1024x512|80000|81.01%|81.30%|81.64%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://www.paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=aa88e7980f4d6839537662a3a3d18851)| diff --git a/dygraph/configs/ocrnet/README.md b/dygraph/configs/ocrnet/README.md index 8710390c48..51a224c616 100644 --- a/dygraph/configs/ocrnet/README.md +++ b/dygraph/configs/ocrnet/README.md @@ -8,7 +8,7 @@ ### CityScapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|-|-|-|-|-|-|-| -|OCRNet|HRNet_w18|1024x512|160000|80.67%||[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=901a5d0a78b71ca56f06002f05547837)| -|OCRNet|HRNet_w48|1024x512|160000|82.15%||[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=176bf6ca4d89957ffe62ac7c30fcd039) | +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|OCRNet|HRNet_w18|1024x512|160000|80.67%|81.21%|81.30|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=901a5d0a78b71ca56f06002f05547837)| +|OCRNet|HRNet_w48|1024x512|160000|82.15%|82.59%|82.85|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=176bf6ca4d89957ffe62ac7c30fcd039) | diff --git a/dygraph/configs/pspnet/README.md b/dygraph/configs/pspnet/README.md index ac27272939..d6a4651985 100644 --- a/dygraph/configs/pspnet/README.md +++ b/dygraph/configs/pspnet/README.md @@ -8,7 +8,7 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|PSPNet|ResNet50_OS8|1024x512|80000|78.83%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=2758d49b826d614abc53fb79562ebd10)| -|PSPNet|ResNet101_OS8|1024x512|80000|80.48%|-|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=899c080f0c38e0f5481e0dd28038bb6f)| +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|PSPNet|ResNet50_OS8|1024x512|80000|78.83%|79.03%|79.32%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=2758d49b826d614abc53fb79562ebd10)| +|PSPNet|ResNet101_OS8|1024x512|80000|80.48%|80.74%|81.04%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/pspnet_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=899c080f0c38e0f5481e0dd28038bb6f)| diff --git a/dygraph/configs/unet/README.md b/dygraph/configs/unet/README.md index f8d7adf2c5..84c9091e52 100644 --- a/dygraph/configs/unet/README.md +++ b/dygraph/configs/unet/README.md @@ -7,6 +7,6 @@ ### Cityscapes -| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (multi-scale) | Links | -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|UNet|-|1024x512|160000|62.20%|-|[model](https://paddleseg.bj.bcebos.com/dygraph/unet_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/unet_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=cbf444781f46612a30dbab5efc4d6715)| +| Model | Backbone | Resolution | Training Iters | Batch Size | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|UNet|-|1024x512|160000|4|65.00%|66.02%|66.89%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/unet_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/unet_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=67b3338de34ad09f0cb5e7c6856305cc)| diff --git a/dygraph/paddleseg/core/__init__.py b/dygraph/paddleseg/core/__init__.py index c6c1775d6d..35189064a6 100644 --- a/dygraph/paddleseg/core/__init__.py +++ b/dygraph/paddleseg/core/__init__.py @@ -15,5 +15,6 @@ from .train import train from .val import evaluate from .predict import predict +from . import infer -__all__ = ['train', 'evaluate', 'infer'] +__all__ = ['train', 'evaluate', 'predict'] diff --git a/dygraph/paddleseg/core/infer.py b/dygraph/paddleseg/core/infer.py new file mode 100644 index 0000000000..816106a6e9 --- /dev/null +++ b/dygraph/paddleseg/core/infer.py @@ -0,0 +1,233 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from itertools import combinations + +import numpy as np +import paddle +import paddle.nn.functional as F + + +def get_reverse_list(ori_shape, transforms): + """ + get reverse list of transform. + + Args: + ori_shape (list): Origin shape of image. + transforms (list): List of transform. + + Returns: + list: List of tuple, there are two format: + ('resize', (h, w)) The image shape before resize, + ('padding', (h, w)) The image shape before padding. + """ + reverse_list = [] + h, w = ori_shape[0], ori_shape[1] + for op in transforms: + if op.__class__.__name__ in ['Resize', 'ResizeByLong']: + reverse_list.append(('resize', (h, w))) + h, w = op.target_size[0], op.target_size[1] + if op.__class__.__name__ in ['Padding']: + reverse_list.append(('padding', (h, w))) + w, h = op.target_size[0], op.target_size[1] + return reverse_list + + +def reverse_transform(pred, ori_shape, transforms): + """recover pred to origin shape""" + reverse_list = get_reverse_list(ori_shape, transforms) + for item in reverse_list[::-1]: + if item[0] == 'resize': + h, w = item[1][0], item[1][1] + pred = F.interpolate(pred, (h, w), mode='nearest') + elif item[0] == 'padding': + h, w = item[1][0], item[1][1] + pred = pred[:, :, 0:h, 0:w] + else: + raise Exception("Unexpected info '{}' in im_info".format(item[0])) + return pred + + +def flip_combination(flip_horizontal=False, flip_vertical=False): + """ + Get flip combination. + + Args: + flip_horizontal (bool): Whether to flip horizontally. Default: False. + flip_vertical (bool): Whether to flip vertically. Default: False. + + Returns: + list: List of tuple. The first element of tuple is whether to flip horizontally, + and the second is whether to flip vertically. + """ + + flip_comb = [(False, False)] + if flip_horizontal: + flip_comb.append((True, False)) + if flip_vertical: + flip_comb.append((False, True)) + if flip_horizontal: + flip_comb.append((True, True)) + return flip_comb + + +def tensor_flip(x, flip): + """Flip tensor according directions""" + if flip[0]: + x = x[:, :, :, ::-1] + if flip[1]: + x = x[:, :, ::-1, :] + return x + + +def slide_inference(model, im, crop_size, stride): + """ + Infer by sliding window. + + Args: + model (paddle.nn.Layer): model to get logits of image. + im (Tensor): the input image. + crop_size (tuple|list). The size of sliding window, (w, h). + stride (tuple|list). The size of stride, (w, h). + + Return: + Tensor: The logit of input image. + """ + h_im, w_im = im.shape[-2:] + w_crop, h_crop = crop_size + w_stride, h_stride = stride + # calculate the crop nums + rows = np.int(np.ceil(1.0 * (h_im - h_crop) / h_stride)) + 1 + cols = np.int(np.ceil(1.0 * (w_im - w_crop) / w_stride)) + 1 + # TODO 'Tensor' object does not support item assignment. If support, use tensor to calculation. + final_logit = None + count = np.zeros([1, 1, h_im, w_im]) + for r in range(rows): + for c in range(cols): + h1 = r * h_stride + w1 = c * w_stride + h2 = min(h1 + h_crop, h_im) + w2 = min(w1 + w_crop, w_im) + h1 = max(h2 - h_crop, 0) + w1 = max(w2 - w_crop, 0) + im_crop = im[:, :, h1:h2, w1:w2] + im_pad = F.pad(im_crop, [0, w_crop, 0, h_crop]) + logit = model(im_crop)[0].numpy() + if final_logit is None: + final_logit = np.zeros([1, logit.shape[1], h_im, w_im]) + final_logit[:, :, h1:h2, w1:w2] += logit[:, :, :h2 - h1, :w2 - w1] + count[:, :, h1:h2, w1:w2] += 1 + if np.sum(count == 0) != 0: + raise RuntimeError( + 'There are pixel not predicted. It is possible that stride is greater than crop_size' + ) + final_logit = final_logit / count + final_logit = paddle.to_tensor(final_logit) + return final_logit + + +def inference(model, + im, + ori_shape=None, + transforms=None, + is_slide=False, + stride=None, + crop_size=None): + """ + Inference for image. + + Args: + model (paddle.nn.Layer): model to get logits of image. + im (Tensor): the input image. + ori_shape (list): Origin shape of image. + transforms (list): Transforms for image. + is_slide (bool): Whether to infer by sliding window. Default: False. + crop_size (tuple|list). The size of sliding window, (w, h). It should be probided if is_slide is True. + stride (tuple|list). The size of stride, (w, h). It should be probided if is_slide is True. + + Returns: + Tensor: If ori_shape is not None, a prediction with shape (1, 1, h, w) is returned. + If ori_shape is None, a logit with shape (1, num_classes, h, w) is returned. + """ + if not is_slide: + logits = model(im) + logit = logits[0] + else: + logit = slide_inference(model, im, crop_size=crop_size, stride=stride) + if ori_shape is not None: + pred = paddle.argmax(logit, axis=1, keepdim=True, dtype='int32') + pred = reverse_transform(pred, ori_shape, transforms) + return pred + else: + return logit + + +def aug_inference(model, + im, + ori_shape, + transforms, + scales=1.0, + flip_horizontal=False, + flip_vertical=False, + is_slide=False, + stride=None, + crop_size=None): + """ + Infer with augmentation. + + Args: + model (paddle.nn.Layer): model to get logits of image. + im (Tensor): the input image. + ori_shape (list): Origin shape of image. + transforms (list): Transforms for image. + scales (float|tuple|list): Scales for resize. Default: 1. + flip_horizontal (bool): Whether to flip horizontally. Default: False. + flip_vertical (bool): Whether to flip vertically. Default: False. + is_slide (bool): Whether to infer by sliding wimdow. Default: False. + crop_size (tuple|list). The size of sliding window, (w, h). It should be probided if is_slide is True. + stride (tuple|list). The size of stride, (w, h). It should be probided if is_slide is True. + + Returns: + Tensor: Prediction of image with shape (1, 1, h, w) is returned. + """ + if isinstance(scales, float): + scales = [scales] + elif not isinstance(scales, (tuple, list)): + raise TypeError( + '`scales` expects float/tuple/list type, but received {}'.format( + type(scales))) + final_logit = 0 + h_input, w_input = im.shape[-2], im.shape[-1] + flip_comb = flip_combination(flip_horizontal, flip_vertical) + for scale in scales: + h = int(h_input * scale + 0.5) + w = int(w_input * scale + 0.5) + im = F.interpolate(im, (h, w), mode='bilinear') + for flip in flip_comb: + im_flip = tensor_flip(im, flip) + logit = inference( + model, + im_flip, + is_slide=is_slide, + crop_size=crop_size, + stride=stride) + logit = tensor_flip(logit, flip) + logit = F.interpolate(logit, (h_input, w_input), mode='bilinear') + + logit = F.softmax(logit, axis=1) + final_logit = final_logit + logit + + pred = paddle.argmax(final_logit, axis=1, keepdim=True, dtype='int32') + pred = reverse_transform(pred, ori_shape, transforms) + return pred diff --git a/dygraph/paddleseg/core/predict.py b/dygraph/paddleseg/core/predict.py index 4fc38e8161..0aa424a37f 100644 --- a/dygraph/paddleseg/core/predict.py +++ b/dygraph/paddleseg/core/predict.py @@ -17,10 +17,10 @@ import cv2 import numpy as np import paddle -import tqdm from paddleseg import utils -import paddleseg.utils.logger as logger +from paddleseg.core import infer +from paddleseg.utils import logger, progbar def mkdir(path): @@ -34,7 +34,14 @@ def predict(model, transforms, image_list, image_dir=None, - save_dir='output'): + save_dir='output', + aug_pred=False, + scales=1.0, + flip_horizontal=True, + flip_vertical=False, + is_slide=False, + stride=None, + crop_size=None): """ predict and visualize the image_list. @@ -55,24 +62,37 @@ def predict(model, pred_saved_dir = os.path.join(save_dir, 'pseudo_color_prediction') logger.info("Start to predict...") - for im_path in tqdm.tqdm(image_list): - im, im_info, _ = transforms(im_path) + progbar_pred = progbar.Progbar(target=len(image_list), verbose=1) + for i, im_path in enumerate(image_list): + im = cv2.imread(im_path) + ori_shape = im.shape[:2] + im, _ = transforms(im) im = im[np.newaxis, ...] im = paddle.to_tensor(im) - logits = model(im) - pred = paddle.argmax(logits[0], axis=1) - pred = pred.numpy() - pred = np.squeeze(pred).astype('uint8') - for info in im_info[::-1]: - if info[0] == 'resize': - h, w = info[1][0], info[1][1] - pred = cv2.resize(pred, (w, h), cv2.INTER_NEAREST) - elif info[0] == 'padding': - h, w = info[1][0], info[1][1] - pred = pred[0:h, 0:w] - else: - raise ValueError("Unexpected info '{}' in im_info".format( - info[0])) + + if aug_pred: + pred = infer.aug_inference( + model, + im, + ori_shape=ori_shape, + transforms=transforms.transforms, + scales=scales, + flip_horizontal=flip_horizontal, + flip_vertical=flip_vertical, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + else: + pred = infer.inference( + model, + im, + ori_shape=ori_shape, + transforms=transforms.transforms, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + pred = paddle.squeeze(pred) + pred = pred.numpy().astype('uint8') # get the saved name if image_dir is not None: @@ -93,3 +113,5 @@ def predict(model, pred_saved_path = os.path.join(pred_saved_dir, im_file) mkdir(pred_saved_path) cv2.imwrite(pred_saved_path, pred_im) + + progbar_pred.update(i + 1) diff --git a/dygraph/paddleseg/core/train.py b/dygraph/paddleseg/core/train.py index beb8161415..f0b4179abe 100644 --- a/dygraph/paddleseg/core/train.py +++ b/dygraph/paddleseg/core/train.py @@ -152,7 +152,7 @@ def train(model, if (iter % save_interval == 0 or iter == iters) and (val_dataset is not None): mean_iou, acc = evaluate( - model, val_dataset, iter_id=iter, num_workers=num_workers) + model, val_dataset, num_workers=num_workers) model.train() if (iter % save_interval == 0 or iter == iters) and local_rank == 0: diff --git a/dygraph/paddleseg/core/val.py b/dygraph/paddleseg/core/val.py index d7f605def8..5455038912 100644 --- a/dygraph/paddleseg/core/val.py +++ b/dygraph/paddleseg/core/val.py @@ -19,51 +19,21 @@ import paddle.nn.functional as F from paddleseg.utils import metrics, Timer, calculate_eta, logger, progbar +from paddleseg.core import infer np.set_printoptions(suppress=True) -def get_reverse_list(ori_label, transforms): - """ - get reverse list of transform. - - Args: - ori_label (Tensor): Origin label - transforms (List): List of transform. - - Returns: - list: List of tuple, there are two format: - ('resize', (h, w)) The image shape before resize, - ('padding', (h, w)) The image shape before padding. - """ - reverse_list = [] - h, w = ori_label.shape[-2], ori_label.shape[-1] - for op in transforms: - if op.__class__.__name__ in ['Resize', 'ResizeByLong']: - reverse_list.append(('resize', (h, w))) - h, w = op.target_size[0], op.target_size[1] - if op.__class__.__name__ in ['Padding']: - reverse_list.append(('padding', (h, w))) - w, h = op.target_size[0], op.target_size[1] - return reverse_list - - -def reverse_transform(pred, ori_label, transforms): - """recover pred to origin shape""" - reverse_list = get_reverse_list(ori_label, transforms) - for item in reverse_list[::-1]: - if item[0] == 'resize': - h, w = item[1][0], item[1][1] - pred = F.interpolate(pred, (h, w), mode='nearest') - elif item[0] == 'padding': - h, w = item[1][0], item[1][1] - pred = pred[:, :, 0:h, 0:w] - else: - raise Exception("Unexpected info '{}' in im_info".format(item[0])) - return pred - - -def evaluate(model, eval_dataset=None, iter_id=None, num_workers=0): +def evaluate(model, + eval_dataset, + aug_eval=False, + scales=1.0, + flip_horizontal=True, + flip_vertical=False, + is_slide=False, + stride=None, + crop_size=None, + num_workers=0): model.eval() nranks = paddle.distributed.ParallelEnv().nranks local_rank = paddle.distributed.ParallelEnv().local_rank @@ -92,11 +62,28 @@ def evaluate(model, eval_dataset=None, iter_id=None, num_workers=0): for iter, (im, label) in enumerate(loader): label = label.astype('int64') - logits = model(im) - pred = logits[0] - pred = paddle.argmax(pred, axis=1, keepdim=True, dtype='int32') - pred = reverse_transform(pred, label, - eval_dataset.transforms.transforms) + ori_shape = label.shape[-2:] + if aug_eval: + pred = infer.aug_inference( + model, + im, + ori_shape=ori_shape, + transforms=eval_dataset.transforms.transforms, + scales=scales, + flip_horizontal=flip_horizontal, + flip_vertical=flip_vertical, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + else: + pred = infer.inference( + model, + im, + ori_shape=ori_shape, + transforms=eval_dataset.transforms.transforms, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) intersect_area, pred_area, label_area = metrics.calculate_area( pred, diff --git a/dygraph/predict.py b/dygraph/predict.py index 792f6275d5..d262f04ad2 100644 --- a/dygraph/predict.py +++ b/dygraph/predict.py @@ -23,15 +23,15 @@ def parse_args(): - parser = argparse.ArgumentParser(description='Model evaluation') + parser = argparse.ArgumentParser(description='Model prediction') - # params of evaluate + # params of prediction parser.add_argument( "--config", dest="cfg", help="The config file.", default=None, type=str) parser.add_argument( '--model_path', dest='model_path', - help='The path of model for evaluation', + help='The path of model for prediction', type=str, default=None) parser.add_argument( @@ -48,6 +48,53 @@ def parse_args(): type=str, default='./output/result') + # augment for prediction + parser.add_argument( + '--aug_pred', + dest='aug_pred', + help='Whether to use mulit-scales and flip augment for prediction', + action='store_true') + parser.add_argument( + '--scales', + dest='scales', + nargs='+', + help='Scales for augment', + type=float, + default=1.0) + parser.add_argument( + '--flip_horizontal', + dest='flip_horizontal', + help='Whether to use flip horizontally augment', + action='store_true') + parser.add_argument( + '--flip_vertical', + dest='flip_vertical', + help='Whether to use flip vertically augment', + action='store_true') + + # sliding window prediction + parser.add_argument( + '--is_slide', + dest='is_slide', + help='Whether to prediction by sliding window', + action='store_true') + parser.add_argument( + '--crop_size', + dest='crop_size', + nargs=2, + help= + 'The crop size of sliding window, the first is width and the second is height.', + type=int, + default=None) + parser.add_argument( + '--stride', + dest='stride', + nargs=2, + help= + 'The stride of sliding window, the first is width and the second is height.', + type=int, + default=None) + return parser.parse_args() @@ -109,7 +156,15 @@ def main(args): transforms=transforms, image_list=image_list, image_dir=image_dir, - save_dir=args.save_dir) + save_dir=args.save_dir, + aug_pred=args.aug_pred, + scales=args.scales, + flip_horizontal=args.flip_horizontal, + flip_vertical=args.flip_vertical, + is_slide=args.is_slide, + crop_size=args.crop_size, + stride=args.stride, + ) if __name__ == '__main__': diff --git a/dygraph/val.py b/dygraph/val.py index a8a934dc53..9f02a0f52e 100644 --- a/dygraph/val.py +++ b/dygraph/val.py @@ -41,6 +41,53 @@ def parse_args(): type=int, default=0) + # augment for evaluation + parser.add_argument( + '--aug_eval', + dest='aug_eval', + help='Whether to use mulit-scales and flip augment for evaluation', + action='store_true') + parser.add_argument( + '--scales', + dest='scales', + nargs='+', + help='Scales for augment', + type=float, + default=1.0) + parser.add_argument( + '--flip_horizontal', + dest='flip_horizontal', + help='Whether to use flip horizontally augment', + action='store_true') + parser.add_argument( + '--flip_vertical', + dest='flip_vertical', + help='Whether to use flip vertically augment', + action='store_true') + + # sliding window evaluation + parser.add_argument( + '--is_slide', + dest='is_slide', + help='Whether to evaluate by sliding window', + action='store_true') + parser.add_argument( + '--crop_size', + dest='crop_size', + nargs=2, + help= + 'The crop size of sliding window, the first is width and the second is height.', + type=int, + default=None) + parser.add_argument( + '--stride', + dest='stride', + nargs=2, + help= + 'The stride of sliding window, the first is width and the second is height.', + type=int, + default=None) + return parser.parse_args() @@ -70,7 +117,18 @@ def main(args): model.set_dict(para_state_dict) logger.info('Loaded trained params of model successfully') - evaluate(model, val_dataset, num_workers=args.num_workers) + evaluate( + model, + val_dataset, + aug_eval=args.aug_eval, + scales=args.scales, + flip_horizontal=args.flip_horizontal, + flip_vertical=args.flip_vertical, + is_slide=args.is_slide, + crop_size=args.crop_size, + stride=args.stride, + num_workers=args.num_workers, + ) if __name__ == '__main__': From 946ef0ff088fc7f7c2ca8a2cb12ccc4adbbb9434 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 13 Nov 2020 11:45:07 +0800 Subject: [PATCH 04/35] add result of hrnetw18 on voc --- dygraph/configs/fcn/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dygraph/configs/fcn/README.md b/dygraph/configs/fcn/README.md index 8fbe94e976..726cdd7ebd 100644 --- a/dygraph/configs/fcn/README.md +++ b/dygraph/configs/fcn/README.md @@ -11,3 +11,9 @@ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |FCN|HRNet_W18|1024x512|80000|78.97%|79.49%|79.74%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=bebec8e1a3802c4babd3c69e1bf50d51)| |FCN|HRNet_W48|1024x512|80000|80.70%|81.24%|81.56%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw48_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw48_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=ae1cb76014cdc54406c36f1e3dc2a530)| + +### Pascal VOC 2012 + Aug + +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|FCN|HRNet_W18|512x512|40000|75.39%|76.04%|77.09%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=fbe6caaca0f7d7ea1dba1c60b8db2a7e)| From 9bc06efeece9027bdde07d4471e4f5f433a88df6 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 13 Nov 2020 12:44:00 +0800 Subject: [PATCH 05/35] update README.md --- dygraph/configs/fcn/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dygraph/configs/fcn/README.md b/dygraph/configs/fcn/README.md index 726cdd7ebd..3546e95a21 100644 --- a/dygraph/configs/fcn/README.md +++ b/dygraph/configs/fcn/README.md @@ -16,4 +16,4 @@ | Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|FCN|HRNet_W18|512x512|40000|75.39%|76.04%|77.09%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/fcn_hrnetw18_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=fbe6caaca0f7d7ea1dba1c60b8db2a7e)| +|FCN|HRNet_W18|512x512|40000|75.39%|76.04%|77.09%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw18_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw18_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=fbe6caaca0f7d7ea1dba1c60b8db2a7e)| From 3dd47736ec4b8af4ea48064351c8c08c7512b91e Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 16 Nov 2020 10:59:54 +0800 Subject: [PATCH 06/35] add results of hrnetw48 on voc12aug --- dygraph/configs/fcn/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/dygraph/configs/fcn/README.md b/dygraph/configs/fcn/README.md index 3546e95a21..8bb9786c53 100644 --- a/dygraph/configs/fcn/README.md +++ b/dygraph/configs/fcn/README.md @@ -17,3 +17,4 @@ | Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |FCN|HRNet_W18|512x512|40000|75.39%|76.04%|77.09%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw18_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw18_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=fbe6caaca0f7d7ea1dba1c60b8db2a7e)| +|FCN|HRNet_W48|512x512|40000|78.72%|79.52%|80.10%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw48_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/fcn_hrnetw48_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=20b404212fcbb5b7b329ab0c16124553)| From 3b474b7043ce48a221efa6b2571c352ccb002adf Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Tue, 17 Nov 2020 10:28:15 +0800 Subject: [PATCH 07/35] update progbar.py --- dygraph/paddleseg/utils/progbar.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/dygraph/paddleseg/utils/progbar.py b/dygraph/paddleseg/utils/progbar.py index 26a1753a3f..563cc5ebae 100644 --- a/dygraph/paddleseg/utils/progbar.py +++ b/dygraph/paddleseg/utils/progbar.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import sys import time @@ -22,7 +23,7 @@ class Progbar(object): """ Displays a progress bar. It refers to https://github.com/keras-team/keras/blob/keras-2/keras/utils/generic_utils.py - + Args: target (int): Total number of steps expected, None if unknown. width (int): Progress bar width on screen. @@ -51,8 +52,8 @@ def __init__(self, else: self.stateful_metrics = set() - self._dynamic_display = ((hasattr(sys.stdout, 'isatty') - and sys.stdout.isatty()) + self._dynamic_display = ((hasattr(sys.stderr, 'isatty') + and sys.stderr.isatty()) or 'ipykernel' in sys.modules or 'posix' in sys.modules or 'PYCHARM_HOSTED' in os.environ) @@ -114,10 +115,10 @@ def update(self, current, values=None, finalize=None): prev_total_width = self._total_width if self._dynamic_display: - sys.stdout.write('\b' * prev_total_width) - sys.stdout.write('\r') + sys.stderr.write('\b' * prev_total_width) + sys.stderr.write('\r') else: - sys.stdout.write('\n') + sys.stderr.write('\n') if self.target is not None: numdigits = int(np.log10(self.target)) + 1 @@ -136,7 +137,7 @@ def update(self, current, values=None, finalize=None): bar = '%7d/Unknown' % current self._total_width = len(bar) - sys.stdout.write(bar) + sys.stderr.write(bar) if current: time_per_unit = (now - self._start) / current @@ -181,8 +182,8 @@ def update(self, current, values=None, finalize=None): if finalize: info += '\n' - sys.stdout.write(info) - sys.stdout.flush() + sys.stderr.write(info) + sys.stderr.flush() elif self.verbose == 2: if finalize: @@ -199,8 +200,8 @@ def update(self, current, values=None, finalize=None): info += ' %.4e' % avg info += '\n' - sys.stdout.write(info) - sys.stdout.flush() + sys.stderr.write(info) + sys.stderr.flush() self._last_update = now From c61c178590183098e1f49a122492b1d0cc5584ae Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Thu, 19 Nov 2020 17:06:42 +0800 Subject: [PATCH 08/35] update BatchNorm to BatchNorm2D --- dygraph/paddleseg/models/layers/layer_libs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dygraph/paddleseg/models/layers/layer_libs.py b/dygraph/paddleseg/models/layers/layer_libs.py index dae6a26f54..1ce869f5e2 100644 --- a/dygraph/paddleseg/models/layers/layer_libs.py +++ b/dygraph/paddleseg/models/layers/layer_libs.py @@ -18,9 +18,9 @@ def SyncBatchNorm(*args, **kwargs): - """In cpu environment nn.SyncBatchNorm does not have kernel so use nn.BatchNorm instead""" + """In cpu environment nn.SyncBatchNorm does not have kernel so use nn.BatchNorm2D instead""" if paddle.get_device() == 'cpu': - return nn.BatchNorm(*args, **kwargs) + return nn.BatchNorm2D(*args, **kwargs) else: return nn.SyncBatchNorm(*args, **kwargs) From 6eee23fc53a28604081d0bae726a11f00a492f58 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 20 Nov 2020 11:53:00 +0800 Subject: [PATCH 09/35] add ms_flip and sliding window docs --- dygraph/docs/quick_start.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dygraph/docs/quick_start.md b/dygraph/docs/quick_start.md index dc529a7ce6..94f9275638 100644 --- a/dygraph/docs/quick_start.md +++ b/dygraph/docs/quick_start.md @@ -93,8 +93,29 @@ python val.py \ --model_path output/iter_1000/model.pdparams ``` +如果想进行多尺度翻转评估可通过传入`--aug_eval`进行开启,然后通过`--scales`传入尺度信息, +`--flip_horizontal`开启水平翻转, `flip_vertical`开启垂直翻转。使用示例如下: +```shell +python val.py \ + --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \ + --model_path output/iter_1000/model.pdparams 、 + --aug_eval \ + --scales 0.75 1.0 1.25 \ + --flip_horizontal +``` + +如果想进行滑窗评估可通过传入`--is_slide`进行开启, 通过`--crop_size`传入窗口大小, `--stride`传入步长。使用示例如下: +```shell +python val.py \ + --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \ + --model_path output/iter_1000/model.pdparams 、 + --is_slide \ + --crop_size 256 256 \ + --stride 128 128 +``` + ## 效果可视化 -当保存完模型后,可以通过PaddleSeg提供的脚本对模型预测结果进行可视化,查看分割效果 +当保存完模型后,可以通过PaddleSeg提供的脚本对模型预测结果进行可视化,查看分割效果。 ```shell python predict.py \ --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \ @@ -105,3 +126,5 @@ python predict.py \ 其中`image_path`也可以是一个目录,这时候将对目录内的所有图片进行预测并保存可视化结果图。效果如下: ![](images/quick_start_predict.jpg) +同样的,可以通过`--aug_pred`开启多尺度翻转预测, `--is_slide`开启滑窗预测。 + From de7efab04267155b760cf015946e91da31889696 Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Fri, 20 Nov 2020 11:54:35 +0800 Subject: [PATCH 10/35] Update quick_start.md --- dygraph/docs/quick_start.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dygraph/docs/quick_start.md b/dygraph/docs/quick_start.md index 94f9275638..2696ac93fb 100644 --- a/dygraph/docs/quick_start.md +++ b/dygraph/docs/quick_start.md @@ -98,7 +98,7 @@ python val.py \ ```shell python val.py \ --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \ - --model_path output/iter_1000/model.pdparams 、 + --model_path output/iter_1000/model.pdparams \ --aug_eval \ --scales 0.75 1.0 1.25 \ --flip_horizontal @@ -108,7 +108,7 @@ python val.py \ ```shell python val.py \ --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \ - --model_path output/iter_1000/model.pdparams 、 + --model_path output/iter_1000/model.pdparams \ --is_slide \ --crop_size 256 256 \ --stride 128 128 From 57db636a051fad43dd0a1441a3f648ff6419324b Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 20 Nov 2020 14:34:11 +0800 Subject: [PATCH 11/35] update hrnet.py --- dygraph/paddleseg/models/backbones/hrnet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dygraph/paddleseg/models/backbones/hrnet.py b/dygraph/paddleseg/models/backbones/hrnet.py index dd6e374a9c..2f6ecadf93 100644 --- a/dygraph/paddleseg/models/backbones/hrnet.py +++ b/dygraph/paddleseg/models/backbones/hrnet.py @@ -658,10 +658,10 @@ def HRNet_W18_Small_V2(**kwargs): stage2_num_modules=1, stage2_num_blocks=[2, 2], stage2_num_channels=[18, 36], - stage3_num_modules=1, + stage3_num_modules=3, stage3_num_blocks=[2, 2, 2], stage3_num_channels=[18, 36, 72], - stage4_num_modules=1, + stage4_num_modules=2, stage4_num_blocks=[2, 2, 2, 2], stage4_num_channels=[18, 36, 72, 144], **kwargs) From 890f1328695e90aa3e0ba1c2d9191987cdaf93fc Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 23 Nov 2020 11:03:24 +0800 Subject: [PATCH 12/35] limit num_workers for evaluation while training --- dygraph/paddleseg/core/train.py | 1 + dygraph/paddleseg/core/val.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dygraph/paddleseg/core/train.py b/dygraph/paddleseg/core/train.py index f0b4179abe..b9d4030a9d 100644 --- a/dygraph/paddleseg/core/train.py +++ b/dygraph/paddleseg/core/train.py @@ -151,6 +151,7 @@ def train(model, if (iter % save_interval == 0 or iter == iters) and (val_dataset is not None): + num_workers = 1 if num_workers > 0 else 0 mean_iou, acc = evaluate( model, val_dataset, num_workers=num_workers) model.train() diff --git a/dygraph/paddleseg/core/val.py b/dygraph/paddleseg/core/val.py index 5455038912..11f14cbc51 100644 --- a/dygraph/paddleseg/core/val.py +++ b/dygraph/paddleseg/core/val.py @@ -59,7 +59,9 @@ def evaluate(model, logger.info("Start evaluating (total_samples={}, total_iters={})...".format( len(eval_dataset), total_iters)) progbar_val = progbar.Progbar(target=total_iters, verbose=1) + timer = Timer() for iter, (im, label) in enumerate(loader): + reader_cost = timer.elapsed_time() label = label.astype('int64') ori_shape = label.shape[-2:] @@ -115,9 +117,12 @@ def evaluate(model, intersect_area_all = intersect_area_all + intersect_area pred_area_all = pred_area_all + pred_area label_area_all = label_area_all + label_area + batch_cost = timer.elapsed_time() + timer.restart() if local_rank == 0: - progbar_val.update(iter + 1) + progbar_val.update(iter + 1, [('batch_cost', batch_cost), + ('reader cost', reader_cost)]) class_iou, miou = metrics.mean_iou(intersect_area_all, pred_area_all, label_area_all) From ed282423244528130b56fea72be9c71eedae45f8 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 23 Nov 2020 11:43:26 +0800 Subject: [PATCH 13/35] update hrnet.py --- dygraph/paddleseg/models/backbones/hrnet.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dygraph/paddleseg/models/backbones/hrnet.py b/dygraph/paddleseg/models/backbones/hrnet.py index 2f6ecadf93..5de97497e5 100644 --- a/dygraph/paddleseg/models/backbones/hrnet.py +++ b/dygraph/paddleseg/models/backbones/hrnet.py @@ -434,7 +434,7 @@ class SELayer(nn.Layer): def __init__(self, num_channels, num_filters, reduction_ratio, name=None): super(SELayer, self).__init__() - self.pool2d_gap = nn.AdaptiveAvgPool2d(1) + self.pool2d_gap = nn.AdaptiveAvgPool2D(1) self._num_channels = num_channels @@ -443,23 +443,23 @@ def __init__(self, num_channels, num_filters, reduction_ratio, name=None): self.squeeze = nn.Linear( num_channels, med_ch, - act="relu", - param_attr=paddle.ParamAttr( + weight_attr=paddle.ParamAttr( initializer=nn.initializer.Uniform(-stdv, stdv))) stdv = 1.0 / math.sqrt(med_ch * 1.0) self.excitation = nn.Linear( med_ch, num_filters, - act="sigmoid", - param_attr=paddle.ParamAttr( + weight_attr=paddle.ParamAttr( initializer=nn.initializer.Uniform(-stdv, stdv))) def forward(self, x): pool = self.pool2d_gap(x) pool = paddle.reshape(pool, shape=[-1, self._num_channels]) squeeze = self.squeeze(pool) + squeeze = F.relu(squeeze) excitation = self.excitation(squeeze) + excitation = F.sigmoid(excitation) excitation = paddle.reshape( excitation, shape=[-1, self._num_channels, 1, 1]) out = x * excitation From 9f78ca4f266f532ce0315b84344dc2fe4c21a726 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Tue, 24 Nov 2020 16:16:33 +0800 Subject: [PATCH 14/35] rm name argument --- .../paddleseg/models/backbones/resnet_vd.py | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/dygraph/paddleseg/models/backbones/resnet_vd.py b/dygraph/paddleseg/models/backbones/resnet_vd.py index 3d953c2f62..36673e1ad2 100644 --- a/dygraph/paddleseg/models/backbones/resnet_vd.py +++ b/dygraph/paddleseg/models/backbones/resnet_vd.py @@ -36,7 +36,6 @@ def __init__( groups=1, is_vd_mode=False, act=None, - name=None, ): super(ConvBNLayer, self).__init__() @@ -73,16 +72,14 @@ def __init__(self, stride, shortcut=True, if_first=False, - dilation=1, - name=None): + dilation=1): super(BottleneckBlock, self).__init__() self.conv0 = ConvBNLayer( in_channels=in_channels, out_channels=out_channels, kernel_size=1, - act='relu', - name=name + "_branch2a") + act='relu') self.dilation = dilation @@ -92,14 +89,12 @@ def __init__(self, kernel_size=3, stride=stride, act='relu', - dilation=dilation, - name=name + "_branch2b") + dilation=dilation) self.conv2 = ConvBNLayer( in_channels=out_channels, out_channels=out_channels * 4, kernel_size=1, - act=None, - name=name + "_branch2c") + act=None) if not shortcut: self.short = ConvBNLayer( @@ -107,8 +102,7 @@ def __init__(self, out_channels=out_channels * 4, kernel_size=1, stride=1, - is_vd_mode=False if if_first or stride == 1 else True, - name=name + "_branch1") + is_vd_mode=False if if_first or stride == 1 else True) self.shortcut = shortcut @@ -142,8 +136,7 @@ def __init__(self, out_channels, stride, shortcut=True, - if_first=False, - name=None): + if_first=False): super(BasicBlock, self).__init__() self.stride = stride self.conv0 = ConvBNLayer( @@ -151,14 +144,12 @@ def __init__(self, out_channels=out_channels, kernel_size=3, stride=stride, - act='relu', - name=name + "_branch2a") + act='relu') self.conv1 = ConvBNLayer( in_channels=out_channels, out_channels=out_channels, kernel_size=3, - act=None, - name=name + "_branch2b") + act=None) if not shortcut: self.short = ConvBNLayer( @@ -166,8 +157,7 @@ def __init__(self, out_channels=out_channels, kernel_size=1, stride=1, - is_vd_mode=False if if_first else True, - name=name + "_branch1") + is_vd_mode=False if if_first else True) self.shortcut = shortcut @@ -225,26 +215,19 @@ def __init__(self, dilation_dict = {3: 2} self.conv1_1 = ConvBNLayer( - in_channels=3, - out_channels=32, - kernel_size=3, - stride=2, - act='relu', - name="conv1_1") + in_channels=3, out_channels=32, kernel_size=3, stride=2, act='relu') self.conv1_2 = ConvBNLayer( in_channels=32, out_channels=32, kernel_size=3, stride=1, - act='relu', - name="conv1_2") + act='relu') self.conv1_3 = ConvBNLayer( in_channels=32, out_channels=64, kernel_size=3, stride=1, - act='relu', - name="conv1_3") + act='relu') self.pool2d_max = nn.MaxPool2D(kernel_size=3, stride=2, padding=1) # self.block_list = [] @@ -283,7 +266,6 @@ def __init__(self, and dilation_rate == 1 else 1, shortcut=shortcut, if_first=block == i == 0, - name=conv_name, dilation=dilation_rate)) block_list.append(bottleneck_block) @@ -303,8 +285,7 @@ def __init__(self, out_channels=num_filters[block], stride=2 if i == 0 and block != 0 else 1, shortcut=shortcut, - if_first=block == i == 0, - name=conv_name)) + if_first=block == i == 0)) block_list.append(basic_block) shortcut = True self.stage_list.append(block_list) From 3c18d6d6d314b33ca971a592ba95f19e14e76e2e Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Tue, 24 Nov 2020 16:30:28 +0800 Subject: [PATCH 15/35] update resnet_vd.py --- dygraph/paddleseg/models/backbones/resnet_vd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dygraph/paddleseg/models/backbones/resnet_vd.py b/dygraph/paddleseg/models/backbones/resnet_vd.py index 36673e1ad2..64a01842be 100644 --- a/dygraph/paddleseg/models/backbones/resnet_vd.py +++ b/dygraph/paddleseg/models/backbones/resnet_vd.py @@ -169,7 +169,8 @@ def forward(self, inputs): short = inputs else: short = self.short(inputs) - y = paddle.elementwise_add(x=short, y=conv1, act='relu') + y = paddle.add(x=short, y=conv1) + y = F.relu(y) return y From af249ac25c3052ae4e0a7228ab7bcc8947cd9878 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 30 Nov 2020 18:08:23 +0800 Subject: [PATCH 16/35] add gcnet and ocrnet result of voc12 --- .../fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml | 6 +++++ dygraph/configs/gcnet/README.md | 5 ++++ ...net_resnet101_os8_voc12aug_512x512_40k.yml | 6 +++++ ...cnet_resnet50_os8_voc12aug_512x512_40k.yml | 22 ++++++++++++++++ dygraph/configs/ocrnet/README.md | 11 ++++++-- .../ocrnet_hrnetw18_voc12aug_512x512_40k.yml | 25 +++++++++++++++++++ .../ocrnet_hrnetw48_voc12aug_512x512_40k.yml | 6 +++++ 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml create mode 100644 dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml create mode 100644 dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml create mode 100644 dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml create mode 100644 dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml b/dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..9315453f11 --- /dev/null +++ b/dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml @@ -0,0 +1,6 @@ +_base_: './fcn_hrnetw18_voc12aug_512x512_40k.yml' + +model: + backbone: + type: HRNet_W48 + pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w48_ssld.tar.gz diff --git a/dygraph/configs/gcnet/README.md b/dygraph/configs/gcnet/README.md index 06899ed741..ee49e31d2a 100644 --- a/dygraph/configs/gcnet/README.md +++ b/dygraph/configs/gcnet/README.md @@ -12,3 +12,8 @@ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |GCNet|ResNet50_OS8|1024x512|80000|79.50%|79.77%|79.69%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=e3801edb9a6f5b33eb890f5a1ae6ed7b)| |GCNet|ResNet101_OS8|1024x512|80000|81.01%|81.30%|81.64%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gcnet_resnet101_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://www.paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=aa88e7980f4d6839537662a3a3d18851)| + +### Pascal VOC 2012 + Aug + +|GCNet|ResNet50_OS8|512x512|40000|80.32%|80.39%|80.54%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet50_os8_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet50_os8_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=86cbaac3fe98fdbb635e246c2c02e87b)| +|GCNet|ResNet101_OS8|512x512|40000|79.64%|79.59%|79.94%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet101_os8_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet101_os8_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=73f0484b034f6c27bf481c7a3b05e9ae)| diff --git a/dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml b/dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..8411307f53 --- /dev/null +++ b/dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml @@ -0,0 +1,6 @@ +_base_: './gcnet_resnet50_os8_voc12aug_512x512_40k.yml' + +model: + backbone: + type: ResNet101_vd + pretrained: https://bj.bcebos.com/paddleseg/dygraph/resnet101_vd_ssld.tar.gz diff --git a/dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml b/dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..912de526e6 --- /dev/null +++ b/dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml @@ -0,0 +1,22 @@ +_base_: '../_base_/pascal_voc12aug.yml' + +learning_rate: + decay: + end_lr: 1.0e-5 + +loss: + types: + - type: CrossEntropyLoss + coef: [1, 0.4] + +model: + type: GCNet + backbone: + type: ResNet50_vd + output_stride: 8 + pretrained: https://bj.bcebos.com/paddleseg/dygraph/resnet50_vd_ssld_v2.tar.gz + gc_channels: 512 + ratio: 0.25 + enable_auxiliary_loss: True + align_corners: False + pretrained: null diff --git a/dygraph/configs/ocrnet/README.md b/dygraph/configs/ocrnet/README.md index 51a224c616..1fbac14b52 100644 --- a/dygraph/configs/ocrnet/README.md +++ b/dygraph/configs/ocrnet/README.md @@ -10,5 +10,12 @@ | Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|OCRNet|HRNet_w18|1024x512|160000|80.67%|81.21%|81.30|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=901a5d0a78b71ca56f06002f05547837)| -|OCRNet|HRNet_w48|1024x512|160000|82.15%|82.59%|82.85|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=176bf6ca4d89957ffe62ac7c30fcd039) | +|OCRNet|HRNet_w18|1024x512|160000|80.67%|81.21%|81.30%|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw18_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=901a5d0a78b71ca56f06002f05547837)| +|OCRNet|HRNet_w48|1024x512|160000|82.15%|82.59%|82.85%|[model](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/model.pdparams) \| [log](https://paddleseg.bj.bcebos.com/dygraph/ocrnet_hrnetw48_cityscapes_1024x512_160k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=176bf6ca4d89957ffe62ac7c30fcd039) | + +### Pascal VOC 2012 + Aug + +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|OCRNet|HRNet_w18|1024x512|160000|75.76%|76.39%|77.95%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/ocrnet_hrnetw18_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/ocrnet_hrnetw18_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=74707b83bc14b7d236146ac4ceaf6c9c)| +|OCRNet|HRNet_w48|1024x512|160000|79.98%|80.47%|81.02%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/ocrnet_hrnetw48_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/ocrnet_hrnetw48_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=8f695743c799f8966a72973f3259fad4) | diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml b/dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..f625bcc028 --- /dev/null +++ b/dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml @@ -0,0 +1,25 @@ +_base_: '../_base_/pascal_voc12aug.yml' + +model: + type: OCRNet + backbone: + type: HRNet_W18 + pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w18_ssld.tar.gz + num_classes: 19 + backbone_indices: [0] + +optimizer: + type: sgd + +learning_rate: + value: 0.01 + decay: + type: poly + power: 0.9 + + +loss: + types: + - type: CrossEntropyLoss + - type: CrossEntropyLoss + coef: [1, 1] diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml b/dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml new file mode 100644 index 0000000000..2599f5d338 --- /dev/null +++ b/dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml @@ -0,0 +1,6 @@ +_base_: './ocrnet_hrnetw18_voc12aug_512x512_40k.yml' + +model: + backbone: + type: HRNet_W48 + pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w48_ssld.tar.gz From f0a4ce9031bebf867a7c02e69172d48b3e9e8c53 Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Mon, 30 Nov 2020 19:36:24 +0800 Subject: [PATCH 17/35] Update README.md --- dygraph/configs/gcnet/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dygraph/configs/gcnet/README.md b/dygraph/configs/gcnet/README.md index ee49e31d2a..e330abdc6a 100644 --- a/dygraph/configs/gcnet/README.md +++ b/dygraph/configs/gcnet/README.md @@ -15,5 +15,7 @@ ### Pascal VOC 2012 + Aug +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |GCNet|ResNet50_OS8|512x512|40000|80.32%|80.39%|80.54%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet50_os8_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet50_os8_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=86cbaac3fe98fdbb635e246c2c02e87b)| |GCNet|ResNet101_OS8|512x512|40000|79.64%|79.59%|79.94%|[model](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet101_os8_voc12aug_512x512_40k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pascal_voc12/gcnet_renet101_os8_voc12aug_512x512_40k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=73f0484b034f6c27bf481c7a3b05e9ae)| From 96f5777670bb22524c90c975b28d2583060b484f Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 4 Dec 2020 11:05:40 +0800 Subject: [PATCH 18/35] make dygraph as home page --- README.md | 122 +++----- README_CN.md | 260 ++++------------- .../benchmark => benchmark}/deeplabv3p.yml | 0 {dygraph/benchmark => benchmark}/hrnet.yml | 0 {dygraph/configs => configs}/README.md | 0 .../configs => configs}/_base_/ade20k.yml | 0 .../configs => configs}/_base_/cityscapes.yml | 0 .../_base_/cityscapes_1024x1024.yml | 0 .../_base_/cityscapes_769x769.yml | 0 .../_base_/pascal_voc12.yml | 0 .../_base_/pascal_voc12aug.yml | 0 {dygraph/configs => configs}/ann/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...ann_resnet101_os8_voc12aug_512x512_40k.yml | 0 ...n_resnet50_os8_cityscapes_1024x512_80k.yml | 0 .../ann_resnet50_os8_voc12aug_512x512_40k.yml | 0 .../configs => configs}/bisenet/README.md | 0 .../bisenet_cityscapes_1024x1024_160k.yml | 0 {dygraph/configs => configs}/danet/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...t_resnet50_os8_cityscapes_1024x512_80k.yml | 0 .../configs => configs}/deeplabv3/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...bv3_resnet101_os8_voc12aug_512x512_40k.yml | 0 ...3_resnet50_os8_cityscapes_1024x512_80k.yml | 0 ...abv3_resnet50_os8_voc12aug_512x512_40k.yml | 0 .../configs => configs}/deeplabv3p/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...p_resnet101_os8_cityscapes_769x769_80k.yml | 0 ...v3p_resnet101_os8_voc12aug_512x512_40k.yml | 0 ...p_resnet50_os8_cityscapes_1024x512_80k.yml | 0 ...bv3p_resnet50_os8_voc12aug_512x512_40k.yml | 0 .../configs => configs}/fastscnn/README.md | 0 .../fastscnn_cityscapes_1024x1024_160k.yml | 0 {dygraph/configs => configs}/fcn/README.md | 0 .../fcn_hrnetw18_cityscapes_1024x512_80k.yml | 0 .../fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml | 0 .../fcn_hrnetw48_cityscapes_1024x512_80k.yml | 0 .../fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml | 0 {dygraph/configs => configs}/gcnet/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...net_resnet101_os8_voc12aug_512x512_40k.yml | 0 ...t_resnet50_os8_cityscapes_1024x512_80k.yml | 0 ...cnet_resnet50_os8_voc12aug_512x512_40k.yml | 0 {dygraph/configs => configs}/ocrnet/README.md | 0 ...rnet_hrnetw18_cityscapes_1024x512_160k.yml | 0 .../ocrnet_hrnetw18_voc12aug_512x512_40k.yml | 0 ...rnet_hrnetw48_cityscapes_1024x512_160k.yml | 0 .../ocrnet_hrnetw48_voc12aug_512x512_40k.yml | 0 {dygraph/configs => configs}/pspnet/README.md | 0 ..._resnet101_os8_cityscapes_1024x512_80k.yml | 0 ...net_resnet101_os8_voc12aug_512x512_40k.yml | 0 ...t_resnet50_os8_cityscapes_1024x512_80k.yml | 0 ...pnet_resnet50_os8_voc12aug_512x512_40k.yml | 0 .../bisenet_optic_disc_512x512_1k.yml | 0 {dygraph/configs => configs}/unet/README.md | 0 .../unet/unet_cityscapes_1024x512_160k.yml | 0 .../remote_sensing/README.md | 0 .../fcn_hrnetw48_ccf_256x256_160k.yml | 0 .../ocrnet_hrnetw48_ccf_256x256_80k.yml | 0 {dygraph/docs => docs}/add_new_model.md | 0 {dygraph/docs => docs}/apis/README.md | 0 {dygraph/docs => docs}/apis/backbones.md | 0 {dygraph/docs => docs}/apis/core.md | 0 {dygraph/docs => docs}/apis/cvlibs.md | 0 {dygraph/docs => docs}/apis/datasets.md | 0 {dygraph/docs => docs}/apis/models.md | 0 {dygraph/docs => docs}/apis/transforms.md | 0 {dygraph/docs => docs}/apis/utils.md | 0 docs/data_prepare.md | 275 +++++++----------- .../images/quick_start_predict.jpg | Bin .../docs => docs}/images/quick_start_vdl.jpg | Bin {dygraph/docs => docs}/quick_start.md | 0 dygraph/README.md | 85 ------ dygraph/README_CN.md | 74 ----- dygraph/docs/data_prepare.md | 100 ------- legacy/README.md | 115 ++++++++ legacy/README_CN.md | 230 +++++++++++++++ .../configs}/cityscape_fast_scnn.yaml | 0 .../configs}/deepglobe_road_extraction.yaml | 0 .../deeplabv3p_mobilenet-1-0_pet.yaml | 0 .../deeplabv3p_mobilenetv2_cityscapes.yaml | 0 ...eplabv3p_mobilenetv3_large_cityscapes.yaml | 0 .../deeplabv3p_resnet50_vd_cityscapes.yaml | 0 .../deeplabv3p_xception65_cityscapes.yaml | 0 .../configs}/deeplabv3p_xception65_optic.yaml | 0 .../configs}/fast_scnn_pet.yaml | 0 {configs => legacy/configs}/hrnet_optic.yaml | 0 {configs => legacy/configs}/icnet_optic.yaml | 0 ...ovasz_hinge_deeplabv3p_mobilenet_road.yaml | 0 ...z_softmax_deeplabv3p_mobilenet_pascal.yaml | 0 .../configs}/ocrnet_w18_bn_cityscapes.yaml | 0 {configs => legacy/configs}/pspnet_optic.yaml | 0 {configs => legacy/configs}/unet_optic.yaml | 0 {contrib => legacy/contrib}/ACE2P/README.md | 0 {contrib => legacy/contrib}/ACE2P/__init__.py | 0 {contrib => legacy/contrib}/ACE2P/config.py | 0 .../contrib}/ACE2P/download_ACE2P.py | 0 .../contrib}/ACE2P/imgs/117676_2149260.jpg | Bin .../contrib}/ACE2P/imgs/117676_2149260.png | Bin .../contrib}/ACE2P/imgs/net.jpg | Bin .../contrib}/ACE2P/imgs/result.jpg | Bin {contrib => legacy/contrib}/ACE2P/infer.py | 0 {contrib => legacy/contrib}/ACE2P/reader.py | 0 .../contrib}/ACE2P/utils/__init__.py | 0 .../contrib}/ACE2P/utils/palette.py | 0 .../contrib}/ACE2P/utils/util.py | 0 .../contrib}/HumanSeg/README.md | 0 .../contrib}/HumanSeg/bg_replace.py | 0 .../contrib}/HumanSeg/data/background.jpg | Bin .../contrib}/HumanSeg/data/download_data.py | 0 .../contrib}/HumanSeg/data/human_image.jpg | Bin .../contrib}/HumanSeg/datasets/__init__.py | 0 .../contrib}/HumanSeg/datasets/dataset.py | 0 .../datasets/shared_queue/__init__.py | 0 .../HumanSeg/datasets/shared_queue/queue.py | 0 .../datasets/shared_queue/sharedmemory.py | 0 .../contrib}/HumanSeg/export.py | 0 {contrib => legacy/contrib}/HumanSeg/infer.py | 0 .../contrib}/HumanSeg/models/__init__.py | 0 .../contrib}/HumanSeg/models/humanseg.py | 0 .../contrib}/HumanSeg/models/load_model.py | 0 .../contrib}/HumanSeg/nets/__init__.py | 0 .../HumanSeg/nets/backbone/__init__.py | 0 .../HumanSeg/nets/backbone/mobilenet_v2.py | 0 .../HumanSeg/nets/backbone/xception.py | 0 .../contrib}/HumanSeg/nets/deeplabv3p.py | 0 .../contrib}/HumanSeg/nets/hrnet.py | 0 .../contrib}/HumanSeg/nets/libs.py | 0 .../contrib}/HumanSeg/nets/seg_modules.py | 0 .../contrib}/HumanSeg/nets/shufflenet_slim.py | 0 .../download_pretrained_weights.py | 0 .../contrib}/HumanSeg/quant_offline.py | 0 .../contrib}/HumanSeg/quant_online.py | 0 .../contrib}/HumanSeg/requirements.txt | 0 {contrib => legacy/contrib}/HumanSeg/train.py | 0 .../contrib}/HumanSeg/transforms/__init__.py | 0 .../HumanSeg/transforms/functional.py | 0 .../HumanSeg/transforms/transforms.py | 0 .../contrib}/HumanSeg/utils/__init__.py | 0 .../HumanSeg/utils/humanseg_postprocess.py | 0 .../contrib}/HumanSeg/utils/logging.py | 0 .../contrib}/HumanSeg/utils/metrics.py | 0 .../HumanSeg/utils/post_quantization.py | 0 .../contrib}/HumanSeg/utils/utils.py | 0 {contrib => legacy/contrib}/HumanSeg/val.py | 0 .../contrib}/HumanSeg/video_infer.py | 0 {contrib => legacy/contrib}/LaneNet/README.md | 0 .../contrib}/LaneNet/configs/lanenet.yaml | 0 .../contrib}/LaneNet/data_aug.py | 0 .../LaneNet/dataset/download_tusimple.py | 0 {contrib => legacy/contrib}/LaneNet/eval.py | 0 .../LaneNet/imgs/0005_pred_binary.png | Bin .../LaneNet/imgs/0005_pred_instance.png | Bin .../contrib}/LaneNet/imgs/0005_pred_lane.png | Bin {contrib => legacy/contrib}/LaneNet/loss.py | 0 .../contrib}/LaneNet/models/__init__.py | 0 .../contrib}/LaneNet/models/model_builder.py | 0 .../LaneNet/models/modeling/__init__.py | 0 .../LaneNet/models/modeling/lanenet.py | 0 {contrib => legacy/contrib}/LaneNet/reader.py | 0 .../contrib}/LaneNet/requirements.txt | 0 {contrib => legacy/contrib}/LaneNet/train.py | 0 .../contrib}/LaneNet/utils/__init__.py | 0 .../contrib}/LaneNet/utils/config.py | 0 .../contrib}/LaneNet/utils/dist_utils.py | 0 .../utils/generate_tusimple_dataset.py | 0 .../LaneNet/utils/lanenet_postprocess.py | 0 .../LaneNet/utils/load_model_utils.py | 0 {contrib => legacy/contrib}/LaneNet/vis.py | 0 ...download_mini_mechanical_industry_meter.py | 0 ...download_unet_mechanical_industry_meter.py | 0 .../imgs/1560143028.5_IMG_3091.JPG | Bin .../imgs/1560143028.5_IMG_3091.png | Bin .../unet_mechanical_meter.yaml | 0 {contrib => legacy/contrib}/README.md | 0 .../contrib}/RemoteSensing/README.md | 0 .../contrib}/RemoteSensing/__init__.py | 0 .../docs/data_analyse_and_check.md | 0 .../RemoteSensing/docs/data_prepare.md | 0 .../docs/imgs/data_distribution.png | Bin .../RemoteSensing/docs/imgs/dataset.png | Bin .../contrib}/RemoteSensing/docs/imgs/vis.png | Bin .../RemoteSensing/docs/imgs/visualdl.png | Bin .../contrib}/RemoteSensing/docs/transforms.md | 0 .../contrib}/RemoteSensing/models/__init__.py | 0 .../contrib}/RemoteSensing/models/base.py | 0 .../contrib}/RemoteSensing/models/hrnet.py | 0 .../RemoteSensing/models/load_model.py | 0 .../contrib}/RemoteSensing/models/unet.py | 0 .../RemoteSensing/models/utils/visualize.py | 0 .../contrib}/RemoteSensing/nets/__init__.py | 0 .../contrib}/RemoteSensing/nets/hrnet.py | 0 .../contrib}/RemoteSensing/nets/libs.py | 0 .../contrib}/RemoteSensing/nets/loss.py | 0 .../contrib}/RemoteSensing/nets/unet.py | 0 .../contrib}/RemoteSensing/predict_demo.py | 0 .../RemoteSensing/readers/__init__.py | 0 .../contrib}/RemoteSensing/readers/base.py | 0 .../contrib}/RemoteSensing/readers/reader.py | 0 .../contrib}/RemoteSensing/requirements.txt | 0 .../RemoteSensing/tools/cal_norm_coef.py | 0 .../tools/create_dataset_list.py | 0 .../tools/data_analyse_and_check.py | 0 .../tools/data_distribution_vis.py | 0 .../RemoteSensing/tools/split_dataset_list.py | 0 .../contrib}/RemoteSensing/train_demo.py | 0 .../RemoteSensing/transforms/__init__.py | 0 .../contrib}/RemoteSensing/transforms/ops.py | 0 .../RemoteSensing/transforms/transforms.py | 0 .../contrib}/RemoteSensing/utils/__init__.py | 0 .../contrib}/RemoteSensing/utils/logging.py | 0 .../contrib}/RemoteSensing/utils/metrics.py | 0 .../RemoteSensing/utils/pretrain_weights.py | 0 .../contrib}/RemoteSensing/utils/utils.py | 0 .../contrib}/RemoteSensing/visualize_demo.py | 0 .../contrib}/SpatialEmbeddings/README.md | 0 .../contrib}/SpatialEmbeddings/config.py | 0 .../data/kitti/0007/kitti_0007_000512.png | Bin .../data/kitti/0007/kitti_0007_000518.png | Bin .../contrib}/SpatialEmbeddings/data/test.txt | 0 .../download_SpatialEmbeddings_kitti.py | 0 .../imgs/kitti_0007_000518_ori.png | Bin .../imgs/kitti_0007_000518_pred.png | Bin .../contrib}/SpatialEmbeddings/infer.py | 0 .../contrib}/SpatialEmbeddings/models.py | 0 .../SpatialEmbeddings/utils/__init__.py | 0 .../SpatialEmbeddings/utils/data_util.py | 0 .../SpatialEmbeddings/utils/palette.py | 0 .../contrib}/SpatialEmbeddings/utils/util.py | 0 {dataset => legacy/dataset}/README.md | 0 .../dataset}/convert_voc2012.py | 0 .../dataset}/download_and_convert_voc2012.py | 0 .../dataset}/download_cityscapes.py | 0 ...download_mini_deepglobe_road_extraction.py | 0 {dataset => legacy/dataset}/download_optic.py | 0 {dataset => legacy/dataset}/download_pet.py | 0 {deploy => legacy/deploy}/README.md | 0 {deploy => legacy/deploy}/cpp/CMakeLists.txt | 0 .../deploy}/cpp/CMakeSettings.json | 0 {deploy => legacy/deploy}/cpp/INSTALL.md | 0 {deploy => legacy/deploy}/cpp/LICENSE | 0 {deploy => legacy/deploy}/cpp/README.md | 0 .../deploy}/cpp/conf/humanseg.yaml | 0 {deploy => legacy/deploy}/cpp/demo.cpp | 0 {deploy => legacy/deploy}/cpp/docs/demo.jpg | Bin .../deploy}/cpp/docs/demo_jpg.png | Bin .../deploy}/cpp/docs/linux_build.md | 0 {deploy => legacy/deploy}/cpp/docs/vis.md | 0 .../deploy}/cpp/docs/vis_result.png | Bin .../deploy}/cpp/docs/windows_vs2015_build.md | 0 .../deploy}/cpp/docs/windows_vs2019_build.md | 0 .../deploy}/cpp/external-cmake/yaml-cpp.cmake | 0 .../deploy}/cpp/images/humanseg/demo1.jpeg | Bin .../deploy}/cpp/images/humanseg/demo2.jpeg | Bin .../cpp/images/humanseg/demo2.jpeg_result.png | Bin .../images/humanseg/demo2_jpeg_recover.png | Bin .../deploy}/cpp/images/humanseg/demo3.jpeg | Bin .../deploy}/cpp/predictor/seg_predictor.cpp | 0 .../deploy}/cpp/predictor/seg_predictor.h | 0 .../deploy}/cpp/preprocessor/preprocessor.cpp | 0 .../deploy}/cpp/preprocessor/preprocessor.h | 0 .../cpp/preprocessor/preprocessor_seg.cpp | 0 .../cpp/preprocessor/preprocessor_seg.h | 0 .../deploy}/cpp/tools/visualize.py | 0 .../deploy}/cpp/utils/seg_conf_parser.h | 0 {deploy => legacy/deploy}/cpp/utils/utils.h | 0 {deploy => legacy/deploy}/lite/README.md | 0 .../deploy}/lite/example/human_1.png | Bin .../deploy}/lite/example/human_2.png | Bin .../deploy}/lite/example/human_3.png | Bin .../lite/human_segmentation_demo/.gitignore | 0 .../human_segmentation_demo/app/.gitignore | 0 .../human_segmentation_demo/app/build.gradle | 0 .../app/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../lite/human_segmentation_demo/app/gradlew | 0 .../human_segmentation_demo/app/gradlew.bat | 0 .../app/local.properties | 0 .../app/proguard-rules.pro | 0 .../lite/demo/ExampleInstrumentedTest.java | 0 .../app/src/main/AndroidManifest.xml | 0 .../image_segmentation/images/human.jpg | Bin .../image_segmentation/labels/label_list | 0 .../AppCompatPreferenceActivity.java | 0 .../lite/demo/segmentation/MainActivity.java | 0 .../lite/demo/segmentation/Predictor.java | 0 .../demo/segmentation/SettingsActivity.java | 0 .../paddle/lite/demo/segmentation/Utils.java | 0 .../lite/demo/segmentation/config/Config.java | 0 .../segmentation/preprocess/Preprocess.java | 0 .../demo/segmentation/visual/Visualize.java | 0 .../drawable-v24/ic_launcher_foreground.xml | 0 .../res/drawable/ic_launcher_background.xml | 0 .../app/src/main/res/layout/activity_main.xml | 0 .../src/main/res/menu/menu_action_options.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../res/mipmap-hdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../res/mipmap-mdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../res/mipmap-xhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin .../app/src/main/res/values/arrays.xml | 0 .../app/src/main/res/values/colors.xml | 0 .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/main/res/xml/settings.xml | 0 .../paddle/lite/demo/ExampleUnitTest.java | 0 .../lite/human_segmentation_demo/build.gradle | 0 .../human_segmentation_demo/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../lite/human_segmentation_demo/gradlew | 0 .../lite/human_segmentation_demo/gradlew.bat | 0 .../human_segmentation_demo/settings.gradle | 0 .../deploy}/paddle-serving/README.md | 0 .../deploy}/paddle-serving/postprocess.py | 0 .../deploy}/paddle-serving/seg_client.py | 0 {deploy => legacy/deploy}/python/README.md | 0 .../python/docs/PaddleSeg_Infer_Benchmark.md | 0 .../docs/compile_paddle_with_tensorrt.md | 0 {deploy => legacy/deploy}/python/infer.py | 0 .../deploy}/python/requirements.txt | 0 .../deploy}/serving/COMPILE_GUIDE.md | 0 {deploy => legacy/deploy}/serving/README.md | 0 {deploy => legacy/deploy}/serving/UBUNTU.md | 0 .../deploy}/serving/requirements.txt | 0 .../serving/seg-serving/CMakeLists.txt | 0 .../serving/seg-serving/conf/gflags.conf | 0 .../seg-serving/conf/model_toolkit.prototxt | 0 .../seg-serving/conf/resource.prototxt | 0 .../serving/seg-serving/conf/seg_conf.yaml | 0 .../serving/seg-serving/conf/seg_conf2.yaml | 0 .../serving/seg-serving/conf/service.prototxt | 0 .../seg-serving/conf/workflow.prototxt | 0 .../data/model/paddle/fluid_reload_flag | 0 .../data/model/paddle/fluid_time_file | 0 .../serving/seg-serving/op/CMakeLists.txt | 0 .../serving/seg-serving/op/image_seg_op.cpp | 0 .../serving/seg-serving/op/image_seg_op.h | 0 .../serving/seg-serving/op/reader_op.cpp | 0 .../serving/seg-serving/op/reader_op.h | 0 .../serving/seg-serving/op/seg_conf.cpp | 0 .../deploy}/serving/seg-serving/op/seg_conf.h | 0 .../serving/seg-serving/op/write_json_op.cpp | 0 .../serving/seg-serving/op/write_json_op.h | 0 .../serving/seg-serving/proto/CMakeLists.txt | 0 .../serving/seg-serving/proto/image_seg.proto | 0 .../serving/seg-serving/scripts/start.sh | 0 .../deploy}/serving/tools/image_seg_client.py | 0 .../deploy}/serving/tools/images/1.jpg | Bin .../deploy}/serving/tools/images/2.jpg | Bin .../deploy}/serving/tools/images/3.jpg | Bin .../cityscapes_demo_dataset.yaml | 0 ...art_000021_000019_gtFine_labelTrainIds.png | Bin ...art_000072_000019_gtFine_labelTrainIds.png | Bin ...urt_000001_062250_gtFine_labelTrainIds.png | Bin ...urt_000001_063045_gtFine_labelTrainIds.png | Bin .../stuttgart_000021_000019_leftImg8bit.png | Bin .../stuttgart_000072_000019_leftImg8bit.png | Bin .../frankfurt_000001_062250_leftImg8bit.png | Bin .../frankfurt_000001_063045_leftImg8bit.png | Bin .../annotation/cityscapes_demo/train_list.txt | 0 .../annotation/cityscapes_demo/val_list.txt | 0 .../docs}/annotation/jingling2seg.md | 0 .../annotation/jingling_demo/jingling.jpg | Bin .../outputs/annotations/jingling.png | Bin .../jingling_demo/outputs/class_names.txt | 0 .../jingling_demo/outputs/jingling.json | 0 .../docs}/annotation/labelme2seg.md | 0 .../annotation/labelme_demo/2011_000025.jpg | Bin .../annotation/labelme_demo/2011_000025.json | 0 .../annotation/labelme_demo/class_names.txt | 0 {docs => legacy/docs}/check.md | 0 {docs => legacy/docs}/config.md | 0 {docs => legacy/docs}/configs/.gitkeep | 0 {docs => legacy/docs}/configs/basic_group.md | 0 .../docs}/configs/dataloader_group.md | 0 .../docs}/configs/dataset_group.md | 0 {docs => legacy/docs}/configs/freeze_group.md | 0 .../docs}/configs/model_deeplabv3p_group.md | 0 {docs => legacy/docs}/configs/model_group.md | 0 .../docs}/configs/model_hrnet_group.md | 0 .../docs}/configs/model_icnet_group.md | 0 .../docs}/configs/model_pspnet_group.md | 0 .../docs}/configs/model_unet_group.md | 0 {docs => legacy/docs}/configs/solver_group.md | 0 {docs => legacy/docs}/configs/test_group.md | 0 {docs => legacy/docs}/configs/train_group.md | 0 {docs => legacy/docs}/data_aug.md | 0 legacy/docs/data_prepare.md | 175 +++++++++++ {docs => legacy/docs}/deploy.md | 0 {docs => legacy/docs}/dice_loss.md | 0 {docs => legacy/docs}/faq.md | 0 {docs => legacy/docs}/imgs/VOC2012.png | Bin .../docs}/imgs/annotation/image-1.png | Bin .../docs}/imgs/annotation/image-10.jpg | Bin .../docs}/imgs/annotation/image-11.png | Bin .../docs}/imgs/annotation/image-2.png | Bin .../docs}/imgs/annotation/image-3.png | Bin .../docs}/imgs/annotation/image-4-1.png | Bin .../docs}/imgs/annotation/image-4-2.png | Bin .../docs}/imgs/annotation/image-5.png | Bin .../docs}/imgs/annotation/image-6-2.png | Bin .../docs}/imgs/annotation/image-6.png | Bin .../docs}/imgs/annotation/image-7.png | Bin .../docs}/imgs/annotation/jingling-1.png | Bin .../docs}/imgs/annotation/jingling-2.png | Bin .../docs}/imgs/annotation/jingling-3.png | Bin .../docs}/imgs/annotation/jingling-4.png | Bin .../docs}/imgs/annotation/jingling-5.png | Bin {docs => legacy/docs}/imgs/aug_method.png | Bin {docs => legacy/docs}/imgs/cityscapes.png | Bin .../docs}/imgs/cosine_decay_example.png | Bin .../docs}/imgs/data_aug_example.png | Bin .../docs}/imgs/data_aug_flip_mirror.png | Bin {docs => legacy/docs}/imgs/data_aug_flow.png | Bin {docs => legacy/docs}/imgs/deepglobe.png | Bin {docs => legacy/docs}/imgs/deeplabv3p.png | Bin {docs => legacy/docs}/imgs/dice.png | Bin {docs => legacy/docs}/imgs/dice2.png | Bin {docs => legacy/docs}/imgs/dice3.png | Bin {docs => legacy/docs}/imgs/fast-scnn.png | Bin {docs => legacy/docs}/imgs/file_list.png | Bin {docs => legacy/docs}/imgs/file_list2.png | Bin {docs => legacy/docs}/imgs/gn.png | Bin {docs => legacy/docs}/imgs/hrnet.png | Bin {docs => legacy/docs}/imgs/icnet.png | Bin .../docs}/imgs/loss_comparison.png | Bin .../docs}/imgs/lovasz-hinge-vis.png | Bin {docs => legacy/docs}/imgs/lovasz-hinge.png | Bin {docs => legacy/docs}/imgs/lovasz-softmax.png | Bin .../docs}/imgs/piecewise_decay_example.png | Bin .../docs}/imgs/poly_decay_example.png | Bin {docs => legacy/docs}/imgs/pspnet.png | Bin {docs => legacy/docs}/imgs/pspnet2.png | Bin {docs => legacy/docs}/imgs/qq_group2.png | Bin {docs => legacy/docs}/imgs/rangescale.png | Bin {docs => legacy/docs}/imgs/seg_news_icon.png | Bin {docs => legacy/docs}/imgs/softmax_loss.png | Bin {docs => legacy/docs}/imgs/unet.png | Bin {docs => legacy/docs}/imgs/usage_vis_demo.jpg | Bin {docs => legacy/docs}/imgs/visualdl_image.png | Bin .../docs}/imgs/visualdl_scalar.png | Bin .../imgs/warmup_with_poly_decay_example.png | Bin {docs => legacy/docs}/loss_select.md | 0 {docs => legacy/docs}/lovasz_loss.md | 0 {docs => legacy/docs}/model_export.md | 0 {docs => legacy/docs}/model_zoo.md | 0 {docs => legacy/docs}/models.md | 0 ...le_gpus_train_and_mixed_precision_train.md | 0 {docs => legacy/docs}/release_notes.md | 0 {docs => legacy/docs}/usage.md | 0 {pdseg => legacy/pdseg}/__init__.py | 0 {pdseg => legacy/pdseg}/check.py | 0 {pdseg => legacy/pdseg}/data_aug.py | 0 {pdseg => legacy/pdseg}/data_utils.py | 0 {pdseg => legacy/pdseg}/eval.py | 0 {pdseg => legacy/pdseg}/export_model.py | 0 .../pdseg}/export_serving_model.py | 0 {pdseg => legacy/pdseg}/loss.py | 0 {pdseg => legacy/pdseg}/lovasz_losses.py | 0 {pdseg => legacy/pdseg}/metrics.py | 0 {pdseg => legacy/pdseg}/models/__init__.py | 0 .../pdseg}/models/backbone/__init__.py | 0 .../pdseg}/models/backbone/mobilenet_v2.py | 0 .../pdseg}/models/backbone/mobilenet_v3.py | 0 .../pdseg}/models/backbone/resnet.py | 0 .../pdseg}/models/backbone/resnet_vd.py | 0 .../pdseg}/models/backbone/vgg.py | 0 .../pdseg}/models/backbone/xception.py | 0 .../pdseg}/models/libs/__init__.py | 0 .../pdseg}/models/libs/model_libs.py | 0 .../pdseg}/models/model_builder.py | 0 .../pdseg}/models/modeling/__init__.py | 0 .../pdseg}/models/modeling/deeplab.py | 0 .../pdseg}/models/modeling/fast_scnn.py | 0 .../pdseg}/models/modeling/hrnet.py | 0 .../pdseg}/models/modeling/icnet.py | 0 .../pdseg}/models/modeling/ocrnet.py | 0 .../pdseg}/models/modeling/pspnet.py | 0 .../pdseg}/models/modeling/unet.py | 0 {pdseg => legacy/pdseg}/reader.py | 0 {pdseg => legacy/pdseg}/solver.py | 0 {pdseg => legacy/pdseg}/tools/__init__.py | 0 .../pdseg}/tools/create_dataset_list.py | 0 .../pdseg}/tools/gray2pseudo_color.py | 0 {pdseg => legacy/pdseg}/tools/jingling2seg.py | 0 {pdseg => legacy/pdseg}/tools/labelme2seg.py | 0 {pdseg => legacy/pdseg}/train.py | 0 {pdseg => legacy/pdseg}/utils/__init__.py | 0 {pdseg => legacy/pdseg}/utils/collect.py | 0 {pdseg => legacy/pdseg}/utils/config.py | 0 {pdseg => legacy/pdseg}/utils/dist_utils.py | 0 {pdseg => legacy/pdseg}/utils/fp16_utils.py | 0 .../pdseg}/utils/load_model_utils.py | 0 {pdseg => legacy/pdseg}/utils/paddle_utils.py | 0 {pdseg => legacy/pdseg}/utils/timer.py | 0 {pdseg => legacy/pdseg}/vis.py | 0 .../pretrained_model}/download_model.py | 0 {dygraph => legacy}/requirements.txt | 3 - {slim => legacy/slim}/distillation/README.md | 0 .../slim}/distillation/cityscape.yaml | 0 .../slim}/distillation/cityscape_teacher.yaml | 0 .../slim}/distillation/model_builder.py | 0 .../slim}/distillation/train_distill.py | 0 {slim => legacy/slim}/nas/README.md | 0 {slim => legacy/slim}/nas/deeplab.py | 0 {slim => legacy/slim}/nas/eval_nas.py | 0 .../slim}/nas/mobilenetv2_search_space.py | 0 {slim => legacy/slim}/nas/model_builder.py | 0 {slim => legacy/slim}/nas/train_nas.py | 0 {slim => legacy/slim}/prune/README.md | 0 {slim => legacy/slim}/prune/eval_prune.py | 0 {slim => legacy/slim}/prune/train_prune.py | 0 {slim => legacy/slim}/quantization/README.md | 0 .../slim}/quantization/deploy/README.md | 0 .../slim}/quantization/deploy/infer.py | 0 .../slim}/quantization/eval_quant.py | 0 .../slim}/quantization/export_model.py | 0 .../quantization/images/ConvertToInt8Pass.png | Bin .../slim}/quantization/images/FreezePass.png | Bin .../images/TransformForMobilePass.png | Bin .../quantization/images/TransformPass.png | Bin .../slim}/quantization/train_quant.py | 0 {test => legacy/test}/ci/check_code_style.sh | 0 .../test}/ci/test_download_dataset.sh | 0 .../deeplabv3p_xception65_cityscapes.yaml | 0 {test => legacy/test}/configs/unet_pet.yaml | 0 .../test}/local_test_cityscapes.py | 0 {test => legacy/test}/local_test_pet.py | 0 {test => legacy/test}/test_utils.py | 0 .../tutorial}/finetune_deeplabv3plus.md | 0 .../tutorial}/finetune_fast_scnn.md | 0 .../tutorial}/finetune_hrnet.md | 0 .../tutorial}/finetune_icnet.md | 0 .../tutorial}/finetune_ocrnet.md | 0 .../tutorial}/finetune_pspnet.md | 0 .../tutorial}/finetune_unet.md | 0 {tutorial => legacy/tutorial}/imgs/optic.png | Bin .../tutorial}/imgs/optic_deeplab.png | Bin .../tutorial}/imgs/optic_hrnet.png | Bin .../tutorial}/imgs/optic_icnet.png | Bin .../tutorial}/imgs/optic_pspnet.png | Bin .../tutorial}/imgs/optic_unet.png | Bin {dygraph/paddleseg => paddleseg}/__init__.py | 0 .../paddleseg => paddleseg}/core/__init__.py | 0 .../paddleseg => paddleseg}/core/infer.py | 0 .../paddleseg => paddleseg}/core/predict.py | 0 .../paddleseg => paddleseg}/core/train.py | 0 {dygraph/paddleseg => paddleseg}/core/val.py | 0 .../cvlibs/__init__.py | 0 .../cvlibs/callbacks.py | 0 .../paddleseg => paddleseg}/cvlibs/config.py | 0 .../paddleseg => paddleseg}/cvlibs/manager.py | 0 .../cvlibs/param_init.py | 0 .../datasets/__init__.py | 0 .../paddleseg => paddleseg}/datasets/ade.py | 0 .../datasets/cityscapes.py | 0 .../datasets/dataset.py | 0 .../datasets/optic_disc_seg.py | 0 .../paddleseg => paddleseg}/datasets/voc.py | 0 .../models/__init__.py | 0 .../paddleseg => paddleseg}/models/ann.py | 0 .../models/backbones/__init__.py | 0 .../models/backbones/hrnet.py | 0 .../models/backbones/mobilenetv3.py | 0 .../models/backbones/resnet_vd.py | 0 .../models/backbones/xception_deeplab.py | 0 .../paddleseg => paddleseg}/models/bisenet.py | 0 .../paddleseg => paddleseg}/models/danet.py | 0 .../paddleseg => paddleseg}/models/deeplab.py | 0 .../models/fast_scnn.py | 0 .../paddleseg => paddleseg}/models/fcn.py | 0 .../paddleseg => paddleseg}/models/gcnet.py | 0 .../models/layers/__init__.py | 0 .../models/layers/activation.py | 0 .../models/layers/layer_libs.py | 0 .../models/layers/pyramid_pool.py | 0 .../models/losses/__init__.py | 0 .../models/losses/cross_entroy_loss.py | 0 .../paddleseg => paddleseg}/models/ocrnet.py | 0 .../paddleseg => paddleseg}/models/pspnet.py | 0 .../paddleseg => paddleseg}/models/unet.py | 0 .../transforms/__init__.py | 0 .../transforms/functional.py | 0 .../transforms/transforms.py | 0 .../paddleseg => paddleseg}/utils/__init__.py | 0 .../paddleseg => paddleseg}/utils/download.py | 0 .../utils/env/__init__.py | 0 .../utils/env/seg_env.py | 0 .../utils/env/sys_env.py | 0 .../paddleseg => paddleseg}/utils/logger.py | 0 .../paddleseg => paddleseg}/utils/metrics.py | 0 .../paddleseg => paddleseg}/utils/progbar.py | 0 .../paddleseg => paddleseg}/utils/timer.py | 0 .../paddleseg => paddleseg}/utils/utils.py | 0 .../utils/visualize.py | 0 dygraph/predict.py => predict.py | 0 requirements.txt | 3 + .../tools => tools}/convert_cityscapes.py | 0 {dygraph/tools => tools}/voc_augment.py | 0 dygraph/train.py => train.py | 0 dygraph/val.py => val.py | 0 610 files changed, 721 insertions(+), 721 deletions(-) rename {dygraph/benchmark => benchmark}/deeplabv3p.yml (100%) rename {dygraph/benchmark => benchmark}/hrnet.yml (100%) rename {dygraph/configs => configs}/README.md (100%) rename {dygraph/configs => configs}/_base_/ade20k.yml (100%) rename {dygraph/configs => configs}/_base_/cityscapes.yml (100%) rename {dygraph/configs => configs}/_base_/cityscapes_1024x1024.yml (100%) rename {dygraph/configs => configs}/_base_/cityscapes_769x769.yml (100%) rename {dygraph/configs => configs}/_base_/pascal_voc12.yml (100%) rename {dygraph/configs => configs}/_base_/pascal_voc12aug.yml (100%) rename {dygraph/configs => configs}/ann/README.md (100%) rename {dygraph/configs => configs}/ann/ann_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/ann/ann_resnet101_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/ann/ann_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/ann/ann_resnet50_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/bisenet/README.md (100%) rename {dygraph/configs => configs}/bisenet/bisenet_cityscapes_1024x1024_160k.yml (100%) rename {dygraph/configs => configs}/danet/README.md (100%) rename {dygraph/configs => configs}/danet/danet_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/danet/danet_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3/README.md (100%) rename {dygraph/configs => configs}/deeplabv3/deeplabv3_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3/deeplabv3_resnet101_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3/deeplabv3_resnet50_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/deeplabv3p/README.md (100%) rename {dygraph/configs => configs}/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3p/deeplabv3p_resnet101_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/deeplabv3p/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/deeplabv3p/deeplabv3p_resnet50_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/fastscnn/README.md (100%) rename {dygraph/configs => configs}/fastscnn/fastscnn_cityscapes_1024x1024_160k.yml (100%) rename {dygraph/configs => configs}/fcn/README.md (100%) rename {dygraph/configs => configs}/fcn/fcn_hrnetw18_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/fcn/fcn_hrnetw48_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/gcnet/README.md (100%) rename {dygraph/configs => configs}/gcnet/gcnet_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/gcnet/gcnet_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/ocrnet/README.md (100%) rename {dygraph/configs => configs}/ocrnet/ocrnet_hrnetw18_cityscapes_1024x512_160k.yml (100%) rename {dygraph/configs => configs}/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/ocrnet/ocrnet_hrnetw48_cityscapes_1024x512_160k.yml (100%) rename {dygraph/configs => configs}/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/pspnet/README.md (100%) rename {dygraph/configs => configs}/pspnet/pspnet_resnet101_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/pspnet/pspnet_resnet101_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/pspnet/pspnet_resnet50_os8_cityscapes_1024x512_80k.yml (100%) rename {dygraph/configs => configs}/pspnet/pspnet_resnet50_os8_voc12aug_512x512_40k.yml (100%) rename {dygraph/configs => configs}/quick_start/bisenet_optic_disc_512x512_1k.yml (100%) rename {dygraph/configs => configs}/unet/README.md (100%) rename {dygraph/configs => configs}/unet/unet_cityscapes_1024x512_160k.yml (100%) rename {dygraph/contrib => contrib}/remote_sensing/README.md (100%) rename {dygraph/contrib => contrib}/remote_sensing/fcn_hrnetw48_ccf_256x256_160k.yml (100%) rename {dygraph/contrib => contrib}/remote_sensing/ocrnet_hrnetw48_ccf_256x256_80k.yml (100%) rename {dygraph/docs => docs}/add_new_model.md (100%) rename {dygraph/docs => docs}/apis/README.md (100%) rename {dygraph/docs => docs}/apis/backbones.md (100%) rename {dygraph/docs => docs}/apis/core.md (100%) rename {dygraph/docs => docs}/apis/cvlibs.md (100%) rename {dygraph/docs => docs}/apis/datasets.md (100%) rename {dygraph/docs => docs}/apis/models.md (100%) rename {dygraph/docs => docs}/apis/transforms.md (100%) rename {dygraph/docs => docs}/apis/utils.md (100%) rename {dygraph/docs => docs}/images/quick_start_predict.jpg (100%) rename {dygraph/docs => docs}/images/quick_start_vdl.jpg (100%) rename {dygraph/docs => docs}/quick_start.md (100%) delete mode 100644 dygraph/README.md delete mode 100644 dygraph/README_CN.md delete mode 100644 dygraph/docs/data_prepare.md create mode 100644 legacy/README.md create mode 100644 legacy/README_CN.md rename {configs => legacy/configs}/cityscape_fast_scnn.yaml (100%) rename {configs => legacy/configs}/deepglobe_road_extraction.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_mobilenet-1-0_pet.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_mobilenetv2_cityscapes.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_mobilenetv3_large_cityscapes.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_resnet50_vd_cityscapes.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_xception65_cityscapes.yaml (100%) rename {configs => legacy/configs}/deeplabv3p_xception65_optic.yaml (100%) rename {configs => legacy/configs}/fast_scnn_pet.yaml (100%) rename {configs => legacy/configs}/hrnet_optic.yaml (100%) rename {configs => legacy/configs}/icnet_optic.yaml (100%) rename {configs => legacy/configs}/lovasz_hinge_deeplabv3p_mobilenet_road.yaml (100%) rename {configs => legacy/configs}/lovasz_softmax_deeplabv3p_mobilenet_pascal.yaml (100%) rename {configs => legacy/configs}/ocrnet_w18_bn_cityscapes.yaml (100%) rename {configs => legacy/configs}/pspnet_optic.yaml (100%) rename {configs => legacy/configs}/unet_optic.yaml (100%) rename {contrib => legacy/contrib}/ACE2P/README.md (100%) rename {contrib => legacy/contrib}/ACE2P/__init__.py (100%) rename {contrib => legacy/contrib}/ACE2P/config.py (100%) rename {contrib => legacy/contrib}/ACE2P/download_ACE2P.py (100%) rename {contrib => legacy/contrib}/ACE2P/imgs/117676_2149260.jpg (100%) rename {contrib => legacy/contrib}/ACE2P/imgs/117676_2149260.png (100%) rename {contrib => legacy/contrib}/ACE2P/imgs/net.jpg (100%) rename {contrib => legacy/contrib}/ACE2P/imgs/result.jpg (100%) rename {contrib => legacy/contrib}/ACE2P/infer.py (100%) rename {contrib => legacy/contrib}/ACE2P/reader.py (100%) rename {contrib => legacy/contrib}/ACE2P/utils/__init__.py (100%) rename {contrib => legacy/contrib}/ACE2P/utils/palette.py (100%) rename {contrib => legacy/contrib}/ACE2P/utils/util.py (100%) rename {contrib => legacy/contrib}/HumanSeg/README.md (100%) rename {contrib => legacy/contrib}/HumanSeg/bg_replace.py (100%) rename {contrib => legacy/contrib}/HumanSeg/data/background.jpg (100%) rename {contrib => legacy/contrib}/HumanSeg/data/download_data.py (100%) rename {contrib => legacy/contrib}/HumanSeg/data/human_image.jpg (100%) rename {contrib => legacy/contrib}/HumanSeg/datasets/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/datasets/dataset.py (100%) rename {contrib => legacy/contrib}/HumanSeg/datasets/shared_queue/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/datasets/shared_queue/queue.py (100%) rename {contrib => legacy/contrib}/HumanSeg/datasets/shared_queue/sharedmemory.py (100%) rename {contrib => legacy/contrib}/HumanSeg/export.py (100%) rename {contrib => legacy/contrib}/HumanSeg/infer.py (100%) rename {contrib => legacy/contrib}/HumanSeg/models/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/models/humanseg.py (100%) rename {contrib => legacy/contrib}/HumanSeg/models/load_model.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/backbone/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/backbone/mobilenet_v2.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/backbone/xception.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/deeplabv3p.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/hrnet.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/libs.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/seg_modules.py (100%) rename {contrib => legacy/contrib}/HumanSeg/nets/shufflenet_slim.py (100%) rename {contrib => legacy/contrib}/HumanSeg/pretrained_weights/download_pretrained_weights.py (100%) rename {contrib => legacy/contrib}/HumanSeg/quant_offline.py (100%) rename {contrib => legacy/contrib}/HumanSeg/quant_online.py (100%) rename {contrib => legacy/contrib}/HumanSeg/requirements.txt (100%) rename {contrib => legacy/contrib}/HumanSeg/train.py (100%) rename {contrib => legacy/contrib}/HumanSeg/transforms/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/transforms/functional.py (100%) rename {contrib => legacy/contrib}/HumanSeg/transforms/transforms.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/__init__.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/humanseg_postprocess.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/logging.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/metrics.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/post_quantization.py (100%) rename {contrib => legacy/contrib}/HumanSeg/utils/utils.py (100%) rename {contrib => legacy/contrib}/HumanSeg/val.py (100%) rename {contrib => legacy/contrib}/HumanSeg/video_infer.py (100%) rename {contrib => legacy/contrib}/LaneNet/README.md (100%) rename {contrib => legacy/contrib}/LaneNet/configs/lanenet.yaml (100%) rename {contrib => legacy/contrib}/LaneNet/data_aug.py (100%) rename {contrib => legacy/contrib}/LaneNet/dataset/download_tusimple.py (100%) rename {contrib => legacy/contrib}/LaneNet/eval.py (100%) rename {contrib => legacy/contrib}/LaneNet/imgs/0005_pred_binary.png (100%) rename {contrib => legacy/contrib}/LaneNet/imgs/0005_pred_instance.png (100%) rename {contrib => legacy/contrib}/LaneNet/imgs/0005_pred_lane.png (100%) rename {contrib => legacy/contrib}/LaneNet/loss.py (100%) rename {contrib => legacy/contrib}/LaneNet/models/__init__.py (100%) rename {contrib => legacy/contrib}/LaneNet/models/model_builder.py (100%) rename {contrib => legacy/contrib}/LaneNet/models/modeling/__init__.py (100%) rename {contrib => legacy/contrib}/LaneNet/models/modeling/lanenet.py (100%) rename {contrib => legacy/contrib}/LaneNet/reader.py (100%) rename {contrib => legacy/contrib}/LaneNet/requirements.txt (100%) rename {contrib => legacy/contrib}/LaneNet/train.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/__init__.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/config.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/dist_utils.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/generate_tusimple_dataset.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/lanenet_postprocess.py (100%) rename {contrib => legacy/contrib}/LaneNet/utils/load_model_utils.py (100%) rename {contrib => legacy/contrib}/LaneNet/vis.py (100%) rename {contrib => legacy/contrib}/MechanicalIndustryMeter/download_mini_mechanical_industry_meter.py (100%) rename {contrib => legacy/contrib}/MechanicalIndustryMeter/download_unet_mechanical_industry_meter.py (100%) rename {contrib => legacy/contrib}/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.JPG (100%) rename {contrib => legacy/contrib}/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.png (100%) rename {contrib => legacy/contrib}/MechanicalIndustryMeter/unet_mechanical_meter.yaml (100%) rename {contrib => legacy/contrib}/README.md (100%) rename {contrib => legacy/contrib}/RemoteSensing/README.md (100%) rename {contrib => legacy/contrib}/RemoteSensing/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/data_analyse_and_check.md (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/data_prepare.md (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/imgs/data_distribution.png (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/imgs/dataset.png (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/imgs/vis.png (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/imgs/visualdl.png (100%) rename {contrib => legacy/contrib}/RemoteSensing/docs/transforms.md (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/base.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/hrnet.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/load_model.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/unet.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/models/utils/visualize.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/nets/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/nets/hrnet.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/nets/libs.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/nets/loss.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/nets/unet.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/predict_demo.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/readers/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/readers/base.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/readers/reader.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/requirements.txt (100%) rename {contrib => legacy/contrib}/RemoteSensing/tools/cal_norm_coef.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/tools/create_dataset_list.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/tools/data_analyse_and_check.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/tools/data_distribution_vis.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/tools/split_dataset_list.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/train_demo.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/transforms/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/transforms/ops.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/transforms/transforms.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/utils/__init__.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/utils/logging.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/utils/metrics.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/utils/pretrain_weights.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/utils/utils.py (100%) rename {contrib => legacy/contrib}/RemoteSensing/visualize_demo.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/README.md (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/config.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/data/kitti/0007/kitti_0007_000512.png (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/data/kitti/0007/kitti_0007_000518.png (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/data/test.txt (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/download_SpatialEmbeddings_kitti.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/imgs/kitti_0007_000518_ori.png (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/imgs/kitti_0007_000518_pred.png (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/infer.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/models.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/utils/__init__.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/utils/data_util.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/utils/palette.py (100%) rename {contrib => legacy/contrib}/SpatialEmbeddings/utils/util.py (100%) rename {dataset => legacy/dataset}/README.md (100%) rename {dataset => legacy/dataset}/convert_voc2012.py (100%) rename {dataset => legacy/dataset}/download_and_convert_voc2012.py (100%) rename {dataset => legacy/dataset}/download_cityscapes.py (100%) rename {dataset => legacy/dataset}/download_mini_deepglobe_road_extraction.py (100%) rename {dataset => legacy/dataset}/download_optic.py (100%) rename {dataset => legacy/dataset}/download_pet.py (100%) rename {deploy => legacy/deploy}/README.md (100%) rename {deploy => legacy/deploy}/cpp/CMakeLists.txt (100%) rename {deploy => legacy/deploy}/cpp/CMakeSettings.json (100%) rename {deploy => legacy/deploy}/cpp/INSTALL.md (100%) rename {deploy => legacy/deploy}/cpp/LICENSE (100%) rename {deploy => legacy/deploy}/cpp/README.md (100%) rename {deploy => legacy/deploy}/cpp/conf/humanseg.yaml (100%) rename {deploy => legacy/deploy}/cpp/demo.cpp (100%) rename {deploy => legacy/deploy}/cpp/docs/demo.jpg (100%) rename {deploy => legacy/deploy}/cpp/docs/demo_jpg.png (100%) rename {deploy => legacy/deploy}/cpp/docs/linux_build.md (100%) rename {deploy => legacy/deploy}/cpp/docs/vis.md (100%) rename {deploy => legacy/deploy}/cpp/docs/vis_result.png (100%) rename {deploy => legacy/deploy}/cpp/docs/windows_vs2015_build.md (100%) rename {deploy => legacy/deploy}/cpp/docs/windows_vs2019_build.md (100%) rename {deploy => legacy/deploy}/cpp/external-cmake/yaml-cpp.cmake (100%) rename {deploy => legacy/deploy}/cpp/images/humanseg/demo1.jpeg (100%) rename {deploy => legacy/deploy}/cpp/images/humanseg/demo2.jpeg (100%) rename {deploy => legacy/deploy}/cpp/images/humanseg/demo2.jpeg_result.png (100%) rename {deploy => legacy/deploy}/cpp/images/humanseg/demo2_jpeg_recover.png (100%) rename {deploy => legacy/deploy}/cpp/images/humanseg/demo3.jpeg (100%) rename {deploy => legacy/deploy}/cpp/predictor/seg_predictor.cpp (100%) rename {deploy => legacy/deploy}/cpp/predictor/seg_predictor.h (100%) rename {deploy => legacy/deploy}/cpp/preprocessor/preprocessor.cpp (100%) rename {deploy => legacy/deploy}/cpp/preprocessor/preprocessor.h (100%) rename {deploy => legacy/deploy}/cpp/preprocessor/preprocessor_seg.cpp (100%) rename {deploy => legacy/deploy}/cpp/preprocessor/preprocessor_seg.h (100%) rename {deploy => legacy/deploy}/cpp/tools/visualize.py (100%) rename {deploy => legacy/deploy}/cpp/utils/seg_conf_parser.h (100%) rename {deploy => legacy/deploy}/cpp/utils/utils.h (100%) rename {deploy => legacy/deploy}/lite/README.md (100%) rename {deploy => legacy/deploy}/lite/example/human_1.png (100%) rename {deploy => legacy/deploy}/lite/example/human_2.png (100%) rename {deploy => legacy/deploy}/lite/example/human_3.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/.gitignore (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/.gitignore (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/build.gradle (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.jar (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.properties (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/gradlew (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/gradlew.bat (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/local.properties (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/proguard-rules.pro (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/androidTest/java/com/baidu/paddle/lite/demo/ExampleInstrumentedTest.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/AndroidManifest.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/images/human.jpg (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/labels/label_list (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/AppCompatPreferenceActivity.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/MainActivity.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Predictor.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/SettingsActivity.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Utils.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/config/Config.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/preprocess/Preprocess.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/visual/Visualize.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/drawable/ic_launcher_background.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/layout/activity_main.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/menu/menu_action_options.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/values/arrays.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/values/colors.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/values/strings.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/values/styles.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/main/res/xml/settings.xml (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/app/src/test/java/com/baidu/paddle/lite/demo/ExampleUnitTest.java (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/build.gradle (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/gradle.properties (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.jar (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.properties (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/gradlew (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/gradlew.bat (100%) rename {deploy => legacy/deploy}/lite/human_segmentation_demo/settings.gradle (100%) rename {deploy => legacy/deploy}/paddle-serving/README.md (100%) rename {deploy => legacy/deploy}/paddle-serving/postprocess.py (100%) rename {deploy => legacy/deploy}/paddle-serving/seg_client.py (100%) rename {deploy => legacy/deploy}/python/README.md (100%) rename {deploy => legacy/deploy}/python/docs/PaddleSeg_Infer_Benchmark.md (100%) rename {deploy => legacy/deploy}/python/docs/compile_paddle_with_tensorrt.md (100%) rename {deploy => legacy/deploy}/python/infer.py (100%) rename {deploy => legacy/deploy}/python/requirements.txt (100%) rename {deploy => legacy/deploy}/serving/COMPILE_GUIDE.md (100%) rename {deploy => legacy/deploy}/serving/README.md (100%) rename {deploy => legacy/deploy}/serving/UBUNTU.md (100%) rename {deploy => legacy/deploy}/serving/requirements.txt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/CMakeLists.txt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/gflags.conf (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/model_toolkit.prototxt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/resource.prototxt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/seg_conf.yaml (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/seg_conf2.yaml (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/service.prototxt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/conf/workflow.prototxt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/data/model/paddle/fluid_reload_flag (100%) rename {deploy => legacy/deploy}/serving/seg-serving/data/model/paddle/fluid_time_file (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/CMakeLists.txt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/image_seg_op.cpp (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/image_seg_op.h (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/reader_op.cpp (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/reader_op.h (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/seg_conf.cpp (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/seg_conf.h (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/write_json_op.cpp (100%) rename {deploy => legacy/deploy}/serving/seg-serving/op/write_json_op.h (100%) rename {deploy => legacy/deploy}/serving/seg-serving/proto/CMakeLists.txt (100%) rename {deploy => legacy/deploy}/serving/seg-serving/proto/image_seg.proto (100%) rename {deploy => legacy/deploy}/serving/seg-serving/scripts/start.sh (100%) rename {deploy => legacy/deploy}/serving/tools/image_seg_client.py (100%) rename {deploy => legacy/deploy}/serving/tools/images/1.jpg (100%) rename {deploy => legacy/deploy}/serving/tools/images/2.jpg (100%) rename {deploy => legacy/deploy}/serving/tools/images/3.jpg (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/cityscapes_demo_dataset.yaml (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/train_list.txt (100%) rename {docs => legacy/docs}/annotation/cityscapes_demo/val_list.txt (100%) rename {docs => legacy/docs}/annotation/jingling2seg.md (100%) rename {docs => legacy/docs}/annotation/jingling_demo/jingling.jpg (100%) rename {docs => legacy/docs}/annotation/jingling_demo/outputs/annotations/jingling.png (100%) rename {docs => legacy/docs}/annotation/jingling_demo/outputs/class_names.txt (100%) rename {docs => legacy/docs}/annotation/jingling_demo/outputs/jingling.json (100%) rename {docs => legacy/docs}/annotation/labelme2seg.md (100%) rename {docs => legacy/docs}/annotation/labelme_demo/2011_000025.jpg (100%) rename {docs => legacy/docs}/annotation/labelme_demo/2011_000025.json (100%) rename {docs => legacy/docs}/annotation/labelme_demo/class_names.txt (100%) rename {docs => legacy/docs}/check.md (100%) rename {docs => legacy/docs}/config.md (100%) rename {docs => legacy/docs}/configs/.gitkeep (100%) rename {docs => legacy/docs}/configs/basic_group.md (100%) rename {docs => legacy/docs}/configs/dataloader_group.md (100%) rename {docs => legacy/docs}/configs/dataset_group.md (100%) rename {docs => legacy/docs}/configs/freeze_group.md (100%) rename {docs => legacy/docs}/configs/model_deeplabv3p_group.md (100%) rename {docs => legacy/docs}/configs/model_group.md (100%) rename {docs => legacy/docs}/configs/model_hrnet_group.md (100%) rename {docs => legacy/docs}/configs/model_icnet_group.md (100%) rename {docs => legacy/docs}/configs/model_pspnet_group.md (100%) rename {docs => legacy/docs}/configs/model_unet_group.md (100%) rename {docs => legacy/docs}/configs/solver_group.md (100%) rename {docs => legacy/docs}/configs/test_group.md (100%) rename {docs => legacy/docs}/configs/train_group.md (100%) rename {docs => legacy/docs}/data_aug.md (100%) create mode 100644 legacy/docs/data_prepare.md rename {docs => legacy/docs}/deploy.md (100%) rename {docs => legacy/docs}/dice_loss.md (100%) rename {docs => legacy/docs}/faq.md (100%) rename {docs => legacy/docs}/imgs/VOC2012.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-1.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-10.jpg (100%) rename {docs => legacy/docs}/imgs/annotation/image-11.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-2.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-3.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-4-1.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-4-2.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-5.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-6-2.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-6.png (100%) rename {docs => legacy/docs}/imgs/annotation/image-7.png (100%) rename {docs => legacy/docs}/imgs/annotation/jingling-1.png (100%) rename {docs => legacy/docs}/imgs/annotation/jingling-2.png (100%) rename {docs => legacy/docs}/imgs/annotation/jingling-3.png (100%) rename {docs => legacy/docs}/imgs/annotation/jingling-4.png (100%) rename {docs => legacy/docs}/imgs/annotation/jingling-5.png (100%) rename {docs => legacy/docs}/imgs/aug_method.png (100%) rename {docs => legacy/docs}/imgs/cityscapes.png (100%) rename {docs => legacy/docs}/imgs/cosine_decay_example.png (100%) rename {docs => legacy/docs}/imgs/data_aug_example.png (100%) rename {docs => legacy/docs}/imgs/data_aug_flip_mirror.png (100%) rename {docs => legacy/docs}/imgs/data_aug_flow.png (100%) rename {docs => legacy/docs}/imgs/deepglobe.png (100%) rename {docs => legacy/docs}/imgs/deeplabv3p.png (100%) rename {docs => legacy/docs}/imgs/dice.png (100%) rename {docs => legacy/docs}/imgs/dice2.png (100%) rename {docs => legacy/docs}/imgs/dice3.png (100%) rename {docs => legacy/docs}/imgs/fast-scnn.png (100%) rename {docs => legacy/docs}/imgs/file_list.png (100%) rename {docs => legacy/docs}/imgs/file_list2.png (100%) rename {docs => legacy/docs}/imgs/gn.png (100%) rename {docs => legacy/docs}/imgs/hrnet.png (100%) rename {docs => legacy/docs}/imgs/icnet.png (100%) rename {docs => legacy/docs}/imgs/loss_comparison.png (100%) rename {docs => legacy/docs}/imgs/lovasz-hinge-vis.png (100%) rename {docs => legacy/docs}/imgs/lovasz-hinge.png (100%) rename {docs => legacy/docs}/imgs/lovasz-softmax.png (100%) rename {docs => legacy/docs}/imgs/piecewise_decay_example.png (100%) rename {docs => legacy/docs}/imgs/poly_decay_example.png (100%) rename {docs => legacy/docs}/imgs/pspnet.png (100%) rename {docs => legacy/docs}/imgs/pspnet2.png (100%) rename {docs => legacy/docs}/imgs/qq_group2.png (100%) rename {docs => legacy/docs}/imgs/rangescale.png (100%) rename {docs => legacy/docs}/imgs/seg_news_icon.png (100%) rename {docs => legacy/docs}/imgs/softmax_loss.png (100%) rename {docs => legacy/docs}/imgs/unet.png (100%) rename {docs => legacy/docs}/imgs/usage_vis_demo.jpg (100%) rename {docs => legacy/docs}/imgs/visualdl_image.png (100%) rename {docs => legacy/docs}/imgs/visualdl_scalar.png (100%) rename {docs => legacy/docs}/imgs/warmup_with_poly_decay_example.png (100%) rename {docs => legacy/docs}/loss_select.md (100%) rename {docs => legacy/docs}/lovasz_loss.md (100%) rename {docs => legacy/docs}/model_export.md (100%) rename {docs => legacy/docs}/model_zoo.md (100%) rename {docs => legacy/docs}/models.md (100%) rename {docs => legacy/docs}/multiple_gpus_train_and_mixed_precision_train.md (100%) rename {docs => legacy/docs}/release_notes.md (100%) rename {docs => legacy/docs}/usage.md (100%) rename {pdseg => legacy/pdseg}/__init__.py (100%) rename {pdseg => legacy/pdseg}/check.py (100%) rename {pdseg => legacy/pdseg}/data_aug.py (100%) rename {pdseg => legacy/pdseg}/data_utils.py (100%) rename {pdseg => legacy/pdseg}/eval.py (100%) rename {pdseg => legacy/pdseg}/export_model.py (100%) rename {pdseg => legacy/pdseg}/export_serving_model.py (100%) rename {pdseg => legacy/pdseg}/loss.py (100%) rename {pdseg => legacy/pdseg}/lovasz_losses.py (100%) rename {pdseg => legacy/pdseg}/metrics.py (100%) rename {pdseg => legacy/pdseg}/models/__init__.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/__init__.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/mobilenet_v2.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/mobilenet_v3.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/resnet.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/resnet_vd.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/vgg.py (100%) rename {pdseg => legacy/pdseg}/models/backbone/xception.py (100%) rename {pdseg => legacy/pdseg}/models/libs/__init__.py (100%) rename {pdseg => legacy/pdseg}/models/libs/model_libs.py (100%) rename {pdseg => legacy/pdseg}/models/model_builder.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/__init__.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/deeplab.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/fast_scnn.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/hrnet.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/icnet.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/ocrnet.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/pspnet.py (100%) rename {pdseg => legacy/pdseg}/models/modeling/unet.py (100%) rename {pdseg => legacy/pdseg}/reader.py (100%) rename {pdseg => legacy/pdseg}/solver.py (100%) rename {pdseg => legacy/pdseg}/tools/__init__.py (100%) rename {pdseg => legacy/pdseg}/tools/create_dataset_list.py (100%) rename {pdseg => legacy/pdseg}/tools/gray2pseudo_color.py (100%) rename {pdseg => legacy/pdseg}/tools/jingling2seg.py (100%) rename {pdseg => legacy/pdseg}/tools/labelme2seg.py (100%) rename {pdseg => legacy/pdseg}/train.py (100%) rename {pdseg => legacy/pdseg}/utils/__init__.py (100%) rename {pdseg => legacy/pdseg}/utils/collect.py (100%) rename {pdseg => legacy/pdseg}/utils/config.py (100%) rename {pdseg => legacy/pdseg}/utils/dist_utils.py (100%) rename {pdseg => legacy/pdseg}/utils/fp16_utils.py (100%) rename {pdseg => legacy/pdseg}/utils/load_model_utils.py (100%) rename {pdseg => legacy/pdseg}/utils/paddle_utils.py (100%) rename {pdseg => legacy/pdseg}/utils/timer.py (100%) rename {pdseg => legacy/pdseg}/vis.py (100%) rename {pretrained_model => legacy/pretrained_model}/download_model.py (100%) rename {dygraph => legacy}/requirements.txt (69%) rename {slim => legacy/slim}/distillation/README.md (100%) rename {slim => legacy/slim}/distillation/cityscape.yaml (100%) rename {slim => legacy/slim}/distillation/cityscape_teacher.yaml (100%) rename {slim => legacy/slim}/distillation/model_builder.py (100%) rename {slim => legacy/slim}/distillation/train_distill.py (100%) rename {slim => legacy/slim}/nas/README.md (100%) rename {slim => legacy/slim}/nas/deeplab.py (100%) rename {slim => legacy/slim}/nas/eval_nas.py (100%) rename {slim => legacy/slim}/nas/mobilenetv2_search_space.py (100%) rename {slim => legacy/slim}/nas/model_builder.py (100%) rename {slim => legacy/slim}/nas/train_nas.py (100%) rename {slim => legacy/slim}/prune/README.md (100%) rename {slim => legacy/slim}/prune/eval_prune.py (100%) rename {slim => legacy/slim}/prune/train_prune.py (100%) rename {slim => legacy/slim}/quantization/README.md (100%) rename {slim => legacy/slim}/quantization/deploy/README.md (100%) rename {slim => legacy/slim}/quantization/deploy/infer.py (100%) rename {slim => legacy/slim}/quantization/eval_quant.py (100%) rename {slim => legacy/slim}/quantization/export_model.py (100%) rename {slim => legacy/slim}/quantization/images/ConvertToInt8Pass.png (100%) rename {slim => legacy/slim}/quantization/images/FreezePass.png (100%) rename {slim => legacy/slim}/quantization/images/TransformForMobilePass.png (100%) rename {slim => legacy/slim}/quantization/images/TransformPass.png (100%) rename {slim => legacy/slim}/quantization/train_quant.py (100%) rename {test => legacy/test}/ci/check_code_style.sh (100%) rename {test => legacy/test}/ci/test_download_dataset.sh (100%) rename {test => legacy/test}/configs/deeplabv3p_xception65_cityscapes.yaml (100%) rename {test => legacy/test}/configs/unet_pet.yaml (100%) rename {test => legacy/test}/local_test_cityscapes.py (100%) rename {test => legacy/test}/local_test_pet.py (100%) rename {test => legacy/test}/test_utils.py (100%) rename {tutorial => legacy/tutorial}/finetune_deeplabv3plus.md (100%) rename {tutorial => legacy/tutorial}/finetune_fast_scnn.md (100%) rename {tutorial => legacy/tutorial}/finetune_hrnet.md (100%) rename {tutorial => legacy/tutorial}/finetune_icnet.md (100%) rename {tutorial => legacy/tutorial}/finetune_ocrnet.md (100%) rename {tutorial => legacy/tutorial}/finetune_pspnet.md (100%) rename {tutorial => legacy/tutorial}/finetune_unet.md (100%) rename {tutorial => legacy/tutorial}/imgs/optic.png (100%) rename {tutorial => legacy/tutorial}/imgs/optic_deeplab.png (100%) rename {tutorial => legacy/tutorial}/imgs/optic_hrnet.png (100%) rename {tutorial => legacy/tutorial}/imgs/optic_icnet.png (100%) rename {tutorial => legacy/tutorial}/imgs/optic_pspnet.png (100%) rename {tutorial => legacy/tutorial}/imgs/optic_unet.png (100%) rename {dygraph/paddleseg => paddleseg}/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/core/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/core/infer.py (100%) rename {dygraph/paddleseg => paddleseg}/core/predict.py (100%) rename {dygraph/paddleseg => paddleseg}/core/train.py (100%) rename {dygraph/paddleseg => paddleseg}/core/val.py (100%) rename {dygraph/paddleseg => paddleseg}/cvlibs/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/cvlibs/callbacks.py (100%) rename {dygraph/paddleseg => paddleseg}/cvlibs/config.py (100%) rename {dygraph/paddleseg => paddleseg}/cvlibs/manager.py (100%) rename {dygraph/paddleseg => paddleseg}/cvlibs/param_init.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/ade.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/cityscapes.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/dataset.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/optic_disc_seg.py (100%) rename {dygraph/paddleseg => paddleseg}/datasets/voc.py (100%) rename {dygraph/paddleseg => paddleseg}/models/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/models/ann.py (100%) rename {dygraph/paddleseg => paddleseg}/models/backbones/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/models/backbones/hrnet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/backbones/mobilenetv3.py (100%) rename {dygraph/paddleseg => paddleseg}/models/backbones/resnet_vd.py (100%) rename {dygraph/paddleseg => paddleseg}/models/backbones/xception_deeplab.py (100%) rename {dygraph/paddleseg => paddleseg}/models/bisenet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/danet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/deeplab.py (100%) rename {dygraph/paddleseg => paddleseg}/models/fast_scnn.py (100%) rename {dygraph/paddleseg => paddleseg}/models/fcn.py (100%) rename {dygraph/paddleseg => paddleseg}/models/gcnet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/layers/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/models/layers/activation.py (100%) rename {dygraph/paddleseg => paddleseg}/models/layers/layer_libs.py (100%) rename {dygraph/paddleseg => paddleseg}/models/layers/pyramid_pool.py (100%) rename {dygraph/paddleseg => paddleseg}/models/losses/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/models/losses/cross_entroy_loss.py (100%) rename {dygraph/paddleseg => paddleseg}/models/ocrnet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/pspnet.py (100%) rename {dygraph/paddleseg => paddleseg}/models/unet.py (100%) rename {dygraph/paddleseg => paddleseg}/transforms/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/transforms/functional.py (100%) rename {dygraph/paddleseg => paddleseg}/transforms/transforms.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/download.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/env/__init__.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/env/seg_env.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/env/sys_env.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/logger.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/metrics.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/progbar.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/timer.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/utils.py (100%) rename {dygraph/paddleseg => paddleseg}/utils/visualize.py (100%) rename dygraph/predict.py => predict.py (100%) rename {dygraph/tools => tools}/convert_cityscapes.py (100%) rename {dygraph/tools => tools}/voc_augment.py (100%) rename dygraph/train.py => train.py (100%) rename dygraph/val.py => val.py (100%) diff --git a/README.md b/README.md index 963c23fc3a..0d3460bab8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ English | [简体中文](README_CN.md) -# PaddleSeg +# PaddleSeg(Dynamic Graph) [![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) @@ -8,108 +8,78 @@ English | [简体中文](README_CN.md) ![python version](https://img.shields.io/badge/python-3.6+-orange.svg) ![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg) - *[2020-12-02] PaddleSeg has released the [dynamic graph](./dygraph) version, which supports PaddlePaddle 2.0rc. For the static graph, we only fix bugs without adding new features. See detailed [release notes](./docs/release_notes.md).* +Welcome to the dynamic version! PaddleSeg is the first development kit which supports PaddlePaddle 2.0. Currently, we provide an experimental version that allows developers to have full-featured experience on dynamic graph. In the near future, the dynamic version will be set as default, and the static one will be moved to "legacy" directory. -## Introduction +The full-detailed documents and tutorials are coming soon. So far there are minimum tutorials that help you to enjoy the strengths of dynamic version. -PaddleSeg is an end-to-end image segmentation development kit based on PaddlePaddle, which aims to help developers in the whole process of training models, optimizing performance and inference speed, and deploying models. Currently PaddleSeg supports seven efficient segmentation models, including DeepLabv3+, U-Net, ICNet, PSPNet, HRNet, Fast-SCNN, and OCRNet, which are extensively used in both academia and industry. Enjoy your Seg journey! +## Model Zoo -![demo](./docs/imgs/cityscapes.png) +|Model\Backbone|ResNet50|ResNet101|HRNetw18|HRNetw48| +|-|-|-|-|-| +|[ANN](./configs/ann)|✔|✔||| +|[BiSeNetv2](./configs/bisenet)|-|-|-|-| +|[DANet](./configs/danet)|✔|✔||| +|[Deeplabv3](./configs/deeplabv3)|✔|✔||| +|[Deeplabv3P](./configs/deeplabv3p)|✔|✔||| +|[Fast-SCNN](./configs/fastscnn)|-|-|-|-| +|[FCN](./configs/fcn)|||✔|✔| +|[GCNet](./configs/gcnet)|✔|✔||| +|[OCRNet](./configs/ocrnet/)|||✔|✔| +|[PSPNet](./configs/pspnet)|✔|✔||| +|[UNet](./configs/unet)|-|-|-|-| -## Main Features +## Dataset -- **Practical Data Augmentation Techniques** - -PaddleSeg provides 10+ data augmentation techniques, which are developed from the product-level applications in Baidu. The techniques are able to help developers improve the generalization and robustness ability of their customized models. - -- **Modular Design** - -PaddleSeg supports seven popular segmentation models, including U-Net, DeepLabv3+, ICNet, PSPNet, HRNet, Fast-SCNN, and OCRNet. Combing with different components, such as pre-trained models, adjustable backbone architectures and loss functions, developer can easily build an efficient segmentation model according to their practical performance requirements. - -- **High Performance** - -PaddleSeg supports the efficient acceleration strategies, such as multi-processing I/O operations, and multi-GPUs parallel training. Moreover, integrating GPU memory optimization techniques in the PaddlePaddle framework, PaddleSeg significantly reduces training overhead of the segmentation models, which helps developers complete the segmentation tasks in a high-efficient way. - -- **Industry-Level Deployment** - -PaddleSeg supports the industry-level deployment in both **server** and **mobile devices** with the high-performance inference engine and image processing ability, which helps developers achieve the high-performance deployment and integration of segmentation model efficiently. Particularly, using another paddle tool [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite), the segmentation models trained in PaddleSeg are able to be deployed on mobile/embedded devices quickly and easily. - -- **Rich Practical Cases** - -PaddleSeg provides rich practical cases in industry, such as human segmentation, mechanical meter segmentation, lane segmentation, remote sensing image segmentation, human parsing, and industry inspection, etc. The practical cases allow developers to get a closer look at the image segmentation area, and get more hand-on experiences on the real practice. +- [x] Cityscapes +- [x] Pascal VOC +- [x] ADE20K +- [ ] Pascal Context +- [ ] COCO stuff ## Installation -### 1. Install PaddlePaddle +1. Install PaddlePaddle System Requirements: -* PaddlePaddle >= 1.7.0 and < 2.0 -* Python >= 3.5+ +* PaddlePaddle >= 2.0.0rc +* Python >= 3.6+ -> Note: the above requirements are for the **static** graph version. If you intent to use the dynamic one, please refers to [here](./dygraph). +> Note: the above requirements are for the **dynamic** graph version. If you intent to use the static one, please refers to [here](../README.md). Highly recommend you install the GPU version of PaddlePaddle, due to large overhead of segmentation models, otherwise it could be out of memory while running the models. -For more detailed installation tutorials, please refer to the official website of [PaddlePaddle](https://www.paddlepaddle.org.cn/install/quick)。 +For more detailed installation tutorials, please refer to the official website of [PaddlePaddle](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-beta/install/index_cn.html)。 -### 2. Download PaddleSeg + +### Download PaddleSeg ``` git clone https://github.com/PaddlePaddle/PaddleSeg ``` -### 3. Install Dependencies +### Install Dependencies Install the python dependencies via the following commands,and please make sure execute it at least once in your branch. -``` -cd PaddleSeg +```shell +cd PaddleSeg/dygraph +export PYTHONPATH=`pwd` +# Run the following one on Windows +# set PYTHONPATH=%cd% pip install -r requirements.txt ``` -## Tutorials - -For a better understanding of PaddleSeg, we provide comprehensive tutorials to show the whole process of using PaddleSeg on model training, evaluation and deployment. Besides the basic usages of PaddleSeg, the design insights will be also mentioned in the tutorials. - -### Quick Start - -* [PaddleSeg Start](./docs/usage.md) - -### Basic Usages - -* [Customized Data Preparation](./docs/data_prepare.md) -* [Scripts and Config Guide](./docs/config.md) -* [Data and Config Verification](./docs/check.md) -* [Segmentation Models](./docs/models.md) -* [Pretrained Models](./docs/model_zoo.md) -* [DeepLabv3+ Tutorial](./tutorial/finetune_deeplabv3plus.md) - -### Inference and Deployment - -* [Model Export](./docs/model_export.md) -* [Python Inference](./deploy/python/) -* [C++ Inference](./deploy/cpp/) -* [Paddle-Lite Mobile Inference & Deployment](./deploy/lite/) -* [PaddleServing Inference & Deployment](./deploy/paddle-serving) - - -### Advanced features - -* [Data Augmentation](./docs/data_aug.md) -* [Loss Functions](./docs/loss_select.md) -* [Practical Cases](./contrib) -* [Multiprocessing and Mixed-Precision Training](./docs/multiple_gpus_train_and_mixed_precision_train.md) -* Model Compression ([Quantization](./slim/quantization/README.md), [Distillation](./slim/distillation/README.md), [Pruning](./slim/prune/README.md), [NAS](./slim/nas/README.md)) - +## Quick Training +```shell +python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml +``` -### Online Tutorials +## Tutorials -We further provide a few online tutorials in Baidu AI Studio:[Get Started](https://aistudio.baidu.com/aistudio/projectdetail/100798), [U-Net](https://aistudio.baidu.com/aistudio/projectDetail/102889), [DeepLabv3+](https://aistudio.baidu.com/aistudio/projectDetail/226703), [Industry Inspection](https://aistudio.baidu.com/aistudio/projectdetail/184392), [HumanSeg](https://aistudio.baidu.com/aistudio/projectdetail/475345), [More](https://aistudio.baidu.com/aistudio/projectdetail/226710). +* [Get Started](./docs/quick_start.md) +* [Data Preparation](./docs/data_prepare.md) +* [Training Configuration](./configs/) +* [Add New Components](./docs/add_new_model.md) ## Feedbacks and Contact -* If your question is not answered properly in [FAQ](./docs/faq.md) or you have an idea on PaddleSeg, please report an issue via [Github Issues](https://github.com/PaddlePaddle/PaddleSeg/issues). +* The dynamic version is still under development, if you find any issue or have an idea on new features, please don't hesitate to contact us via [GitHub Issues](https://github.com/PaddlePaddle/PaddleSeg/issues). * PaddleSeg User Group (QQ): 850378321 or 793114768 - - -## Contributing - -All contributions and suggestions are welcomed. If you want to contribute to PaddleSeg,please summit an issue or create a pull request directly. diff --git a/README_CN.md b/README_CN.md index c953b3cca0..084f5ad903 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,230 +1,74 @@ 简体中文 | [English](README.md) -# PaddleSeg +# PaddleSeg(动态图版本) + +本目录提供了PaddleSeg的动态图版本,目前已经完成了模型训练、评估、数据处理等功能,在未来的版本中,PaddleSeg将会启动默认的动态图模式。目前该目录处于实验阶段,如果您在使用过程中遇到任何问题,请通过issue反馈给我们,我们将会在第一时间跟进处理。 + +## 模型库 + +|模型\骨干网络|ResNet50|ResNet101|HRNetw18|HRNetw48| +|-|-|-|-|-| +|[ANN](./configs/ann)|✔|✔||| +|[BiSeNetv2](./configs/bisenet)|-|-|-|-| +|[DANet](./configs/danet)|✔|✔||| +|[Deeplabv3](./configs/deeplabv3)|✔|✔||| +|[Deeplabv3P](./configs/deeplabv3p)|✔|✔||| +|[Fast-SCNN](./configs/fastscnn)|-|-|-|-| +|[FCN](./configs/fcn)|||✔|✔| +|[GCNet](./configs/gcnet)|✔|✔||| +|[OCRNet](./configs/ocrnet/)|||✔|✔| +|[PSPNet](./configs/pspnet)|✔|✔||| +|[UNet](./configs/unet)|-|-|-|-| + +## 数据集 + +- [x] Cityscapes +- [x] Pascal VOC +- [x] ADE20K +- [ ] Pascal Context +- [ ] COCO stuff -[![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg) -[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) -[![Version](https://img.shields.io/github/release/PaddlePaddle/PaddleSeg.svg)](https://github.com/PaddlePaddle/PaddleSeg/releases) -![python version](https://img.shields.io/badge/python-3.6+-orange.svg) -![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg) - - *[2020-12-02] PaddleSeg已经发布了全新的[动态图版本](./dygraph),全面适配 PaddlePaddle 2.0rc, 静态图版本只作维护不再添加新功能,更多信息请查看详细[更新日志](./docs/release_notes.md).* - -## 简介 - -PaddleSeg是基于[PaddlePaddle](https://www.paddlepaddle.org.cn)开发的端到端图像分割开发套件,覆盖了DeepLabv3+, U-Net, ICNet, PSPNet, HRNet, Fast-SCNN等主流分割网络。通过模块化的设计,以配置化方式驱动模型组合,帮助开发者更便捷地完成从训练到部署的全流程图像分割应用。 - -- [特点](#特点) -- [安装](#安装) -- [使用教程](#使用教程) - - [快速入门](#快速入门) - - [基础功能](#基础功能) - - [预测部署](#预测部署) - - [高级功能](#高级功能) -- [在线体验](#在线体验) -- [FAQ](#FAQ) -- [交流与反馈](#交流与反馈) -- [更新日志](#更新日志) -- [贡献代码](#贡献代码) - -## 特点 - -- **丰富的数据增强** - -基于百度视觉技术部的实际业务经验,内置10+种数据增强策略,可结合实际业务场景进行定制组合,提升模型泛化能力和鲁棒性。 - -- **模块化设计** - -支持U-Net, DeepLabv3+, ICNet, PSPNet, HRNet, Fast-SCNN六种主流分割网络,结合预训练模型和可调节的骨干网络,满足不同性能和精度的要求;选择不同的损失函数如Dice Loss, Lovasz Loss等方式可以强化小目标和不均衡样本场景下的分割精度。 - -- **高性能** - -PaddleSeg支持多进程I/O、多卡并行等训练加速策略,结合飞桨核心框架的显存优化功能,可大幅度减少分割模型的显存开销,让开发者更低成本、更高效地完成图像分割训练。 - -- **工业级部署** - -全面提供**服务端**和**移动端**的工业级部署能力,依托飞桨高性能推理引擎和高性能图像处理实现,开发者可以轻松完成高性能的分割模型部署和集成。通过[Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite),可以在移动设备或者嵌入式设备上完成轻量级、高性能的人像分割模型部署。 +## 安装 -- **产业实践案例** +1. 安装PaddlePaddle -PaddleSeg提供丰富地产业实践案例,如[人像分割](./contrib/HumanSeg)、[工业表计检测](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/contrib#%E5%B7%A5%E4%B8%9A%E8%A1%A8%E7%9B%98%E5%88%86%E5%89%B2)、[遥感分割](./contrib/RemoteSensing)、[人体解析](contrib/ACE2P),[工业质检](https://aistudio.baidu.com/aistudio/projectdetail/184392)等产业实践案例,助力开发者更便捷地落地图像分割技术。 +版本要求 -## 安装 +* PaddlePaddle >= 2.0.0rc -### 1. 安装PaddlePaddle +* Python >= 3.6+ -版本要求 -* PaddlePaddle >= 1.7.0 and < 2.0 -* Python >= 3.5+ +由于图像分割模型计算开销大,推荐在GPU版本的PaddlePaddle下使用PaddleSeg。推荐安装10.0以上的CUDA环境。 -由于图像分割模型计算开销大,推荐在GPU版本的PaddlePaddle下使用PaddleSeg. -安装教程请见[PaddlePaddle官网](https://www.paddlepaddle.org.cn/install/quick)。 +安装教程请见[PaddlePaddle官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-beta/install/index_cn.html)。 -### 2. 下载PaddleSeg代码 -``` +2. 下载PaddleSeg代码 +```shell git clone https://github.com/PaddlePaddle/PaddleSeg ``` -### 3. 安装PaddleSeg依赖 +3. 安装PaddleSeg依赖 通过以下命令安装python包依赖,请确保在该分支上至少执行过一次以下命令: -``` -cd PaddleSeg -pip install -r requirements.txt -``` - -## 使用教程 - -我们提供了一系列的使用教程,来说明如何使用PaddleSeg完成语义分割模型的训练、评估、部署。 - -这一系列的文档被分为**快速入门**、**基础功能**、**预测部署**、**高级功能**四个部分,四个教程由浅至深地介绍PaddleSeg的设计思路和使用方法。 - -### 快速入门 - -* [PaddleSeg快速入门](./docs/usage.md) - -### 基础功能 - -* [自定义数据的标注与准备](./docs/data_prepare.md) -* [脚本使用和配置说明](./docs/config.md) -* [数据和配置校验](./docs/check.md) -* [分割模型介绍](./docs/models.md) -* [预训练模型下载](./docs/model_zoo.md) -* [DeepLabv3+模型使用教程](./tutorial/finetune_deeplabv3plus.md) -* [U-Net模型使用教程](./tutorial/finetune_unet.md) -* [ICNet模型使用教程](./tutorial/finetune_icnet.md) -* [PSPNet模型使用教程](./tutorial/finetune_pspnet.md) -* [HRNet模型使用教程](./tutorial/finetune_hrnet.md) -* [Fast-SCNN模型使用教程](./tutorial/finetune_fast_scnn.md) -* [OCRNet模型使用教程](./tutorial/finetune_ocrnet.md) - -### 预测部署 - -* [模型导出](./docs/model_export.md) -* [Python预测](./deploy/python/) -* [C++预测](./deploy/cpp/) -* [Paddle-Lite移动端预测部署](./deploy/lite/) -* [PaddleServing预测部署](./deploy/paddle-serving) - - -### 高级功能 - -* [PaddleSeg的数据增强](./docs/data_aug.md) -* [PaddleSeg的loss选择](./docs/loss_select.md) -* [PaddleSeg产业实践](./contrib) -* [多进程训练和混合精度训练](./docs/multiple_gpus_train_and_mixed_precision_train.md) -* 使用PaddleSlim进行分割模型压缩([量化](./slim/quantization/README.md), [蒸馏](./slim/distillation/README.md), [剪枝](./slim/prune/README.md), [搜索](./slim/nas/README.md)) -## 在线体验 - -我们在AI Studio平台上提供了在线体验的教程,欢迎体验: -|在线教程|链接| -|-|-| -|快速开始|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/100798)| -|U-Net图像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectDetail/102889)| -|DeepLabv3+图像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectDetail/226703)| -|工业质检(零件瑕疵检测)|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/184392)| -|人像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/475345)| -|PaddleSeg特色垂类模型|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/226710)| -## FAQ - -#### Q: 安装requirements.txt指定的依赖包时,部分包提示找不到? - -A: 可能是pip源的问题,这种情况下建议切换为官方源,或者通过`pip install -r requirements.txt -i `指定其他源地址。 - -#### Q:图像分割的数据增强如何配置,Unpadding, StepScaling, RangeScaling的原理是什么? - -A: 更详细数据增强文档可以参考[数据增强](./docs/data_aug.md) - -#### Q: 训练时因为某些原因中断了,如何恢复训练? - -A: 启动训练脚本时通过命令行覆盖TRAIN.RESUME_MODEL_DIR配置为模型checkpoint目录即可, 以下代码示例第100轮重新恢复训练: -``` -python pdseg/train.py --cfg xxx.yaml TRAIN.RESUME_MODEL_DIR /PATH/TO/MODEL_CKPT/100 +```shell +cd PaddleSeg/dygraph +export PYTHONPATH=`pwd` +# windows下请执行以下命令 +# set PYTHONPATH=%cd% +pip install -r requirements.txt ``` -#### Q: 预测时图片过大,导致显存不足如何处理? - -A: 降低Batch size,使用Group Norm策略;请注意训练过程中当`DEFAULT_NORM_TYPE`选择`bn`时,为了Batch Norm计算稳定性,batch size需要满足>=2 - - -## 交流与反馈 -* 欢迎您通过[Github Issues](https://github.com/PaddlePaddle/PaddleSeg/issues)来提交问题、报告与建议 -* 微信公众号:飞桨PaddlePaddle -* QQ群: 703252161 - -

     

-

   微信公众号                官方技术交流QQ群

- -## 更新日志 - -* 2020.10.28 - - **`v0.7.0`** - * 全面支持Paddle2.0-rc动态图模式,推出PaddleSeg[动态图体验版](./dygraph/) - * 发布大量动态图模型,支持11个分割模型,4个骨干网络,3个数据集: - * 分割模型:ANN, BiSeNetV2, DANet, DeeplabV3, DeeplabV3+, FCN, FastSCNN, GCNet, OCRNet, PSPNet, UNet - * 骨干网络:ResNet, HRNet, MobileNetV3, Xception - * 数据集:Cityscapes, ADE20K, Pascal VOC - - * 提供高精度骨干网络预训练模型以及基于Cityscapes数据集的语义分割[预训练模型](./dygraph/configs/)。Cityscapes精度超过**82%**。 - - -* 2020.08.31 - - **`v0.6.0`** - * 丰富Deeplabv3p网络结构,新增ResNet-vd、MobileNetv3两种backbone,满足高性能与高精度场景,并提供基于Cityscapes和ImageNet的[预训练模型](./docs/model_zoo.md)4个。 - * 新增高精度分割模型OCRNet,支持以HRNet作为backbone,提供基于Cityscapes的[预训练模型](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/docs/model_zoo.md#cityscapes%E9%A2%84%E8%AE%AD%E7%BB%83%E6%A8%A1%E5%9E%8B),mIoU超过80%。 - * 新增proposal free的实例分割模型[Spatial Embedding](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/contrib/SpatialEmbeddings),性能与精度均超越MaskRCNN。提供了基于kitti的预训练模型。 - -* 2020.05.12 - - **`v0.5.0`** - * 全面升级[HumanSeg人像分割模型](./contrib/HumanSeg),新增超轻量级人像分割模型HumanSeg-lite支持移动端实时人像分割处理,并提供基于光流的视频分割后处理提升分割流畅性。 - * 新增[气象遥感分割方案](./contrib/RemoteSensing),支持积雪识别、云检测等气象遥感场景。 - * 新增[Lovasz Loss](docs/lovasz_loss.md),解决数据类别不均衡问题。 - * 使用VisualDL 2.0作为训练可视化工具 - -* 2020.02.25 - - **`v0.4.0`** - * 新增适用于实时场景且不需要预训练模型的分割网络Fast-SCNN,提供基于Cityscapes的[预训练模型](./docs/model_zoo.md)1个 - * 新增LaneNet车道线检测网络,提供[预训练模型](https://github.com/PaddlePaddle/PaddleSeg/tree/release/v0.4.0/contrib/LaneNet#%E4%B8%83-%E5%8F%AF%E8%A7%86%E5%8C%96)一个 - * 新增基于PaddleSlim的分割库压缩策略([量化](./slim/quantization/README.md), [蒸馏](./slim/distillation/README.md), [剪枝](./slim/prune/README.md), [搜索](./slim/nas/README.md)) - - -* 2019.12.15 - - **`v0.3.0`** - * 新增HRNet分割网络,提供基于cityscapes和ImageNet的[预训练模型](./docs/model_zoo.md)8个 - * 支持使用[伪彩色标签](./docs/data_prepare.md#%E7%81%B0%E5%BA%A6%E6%A0%87%E6%B3%A8vs%E4%BC%AA%E5%BD%A9%E8%89%B2%E6%A0%87%E6%B3%A8)进行训练/评估/预测,提升训练体验,并提供将灰度标注图转为伪彩色标注图的脚本 - * 新增[学习率warmup](./docs/configs/solver_group.md#lr_warmup)功能,支持与不同的学习率Decay策略配合使用 - * 新增图像归一化操作的GPU化实现,进一步提升预测速度。 - * 新增Python部署方案,更低成本完成工业级部署。 - * 新增Paddle-Lite移动端部署方案,支持人像分割模型的移动端部署。 - * 新增不同分割模型的预测[性能数据Benchmark](./deploy/python/docs/PaddleSeg_Infer_Benchmark.md), 便于开发者提供模型选型性能参考。 - - -* 2019.11.04 - - **`v0.2.0`** - * 新增PSPNet分割网络,提供基于COCO和cityscapes数据集的[预训练模型](./docs/model_zoo.md)4个。 - * 新增Dice Loss、BCE Loss以及组合Loss配置,支持样本不均衡场景下的[模型优化](./docs/loss_select.md)。 - * 支持[FP16混合精度训练](./docs/multiple_gpus_train_and_mixed_precision_train.md)以及动态Loss Scaling,在不损耗精度的情况下,训练速度提升30%+。 - * 支持[PaddlePaddle多卡多进程训练](./docs/multiple_gpus_train_and_mixed_precision_train.md),多卡训练时训练速度提升15%+。 - * 发布基于UNet的[工业标记表盘分割模型](./contrib#%E5%B7%A5%E4%B8%9A%E7%94%A8%E8%A1%A8%E5%88%86%E5%89%B2)。 - -* 2019.09.10 - - **`v0.1.0`** - * PaddleSeg分割库初始版本发布,包含DeepLabv3+, U-Net, ICNet三类分割模型, 其中DeepLabv3+支持Xception, MobileNet v2两种可调节的骨干网络。 - * CVPR19 LIP人体部件分割比赛冠军预测模型发布[ACE2P](./contrib/ACE2P)。 - * 预置基于DeepLabv3+网络的[人像分割](./contrib/HumanSeg/)和[车道线分割](./contrib/RoadLine)预测模型发布。 - -
+## 训练 +```shell +python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml +``` -## 贡献代码 +## 使用教程 -我们非常欢迎您为PaddleSeg贡献代码或者提供使用建议。如果您可以修复某个issue或者增加一个新功能,欢迎给我们提交Pull Requests. +* [快速入门](./docs/quick_start.md) +* [数据集准备](./docs/data_prepare.md) +* [配置项](./configs/) +* [Add New Components](./docs/add_new_model.md) diff --git a/dygraph/benchmark/deeplabv3p.yml b/benchmark/deeplabv3p.yml similarity index 100% rename from dygraph/benchmark/deeplabv3p.yml rename to benchmark/deeplabv3p.yml diff --git a/dygraph/benchmark/hrnet.yml b/benchmark/hrnet.yml similarity index 100% rename from dygraph/benchmark/hrnet.yml rename to benchmark/hrnet.yml diff --git a/dygraph/configs/README.md b/configs/README.md similarity index 100% rename from dygraph/configs/README.md rename to configs/README.md diff --git a/dygraph/configs/_base_/ade20k.yml b/configs/_base_/ade20k.yml similarity index 100% rename from dygraph/configs/_base_/ade20k.yml rename to configs/_base_/ade20k.yml diff --git a/dygraph/configs/_base_/cityscapes.yml b/configs/_base_/cityscapes.yml similarity index 100% rename from dygraph/configs/_base_/cityscapes.yml rename to configs/_base_/cityscapes.yml diff --git a/dygraph/configs/_base_/cityscapes_1024x1024.yml b/configs/_base_/cityscapes_1024x1024.yml similarity index 100% rename from dygraph/configs/_base_/cityscapes_1024x1024.yml rename to configs/_base_/cityscapes_1024x1024.yml diff --git a/dygraph/configs/_base_/cityscapes_769x769.yml b/configs/_base_/cityscapes_769x769.yml similarity index 100% rename from dygraph/configs/_base_/cityscapes_769x769.yml rename to configs/_base_/cityscapes_769x769.yml diff --git a/dygraph/configs/_base_/pascal_voc12.yml b/configs/_base_/pascal_voc12.yml similarity index 100% rename from dygraph/configs/_base_/pascal_voc12.yml rename to configs/_base_/pascal_voc12.yml diff --git a/dygraph/configs/_base_/pascal_voc12aug.yml b/configs/_base_/pascal_voc12aug.yml similarity index 100% rename from dygraph/configs/_base_/pascal_voc12aug.yml rename to configs/_base_/pascal_voc12aug.yml diff --git a/dygraph/configs/ann/README.md b/configs/ann/README.md similarity index 100% rename from dygraph/configs/ann/README.md rename to configs/ann/README.md diff --git a/dygraph/configs/ann/ann_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/ann/ann_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/ann/ann_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/ann/ann_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/ann/ann_resnet101_os8_voc12aug_512x512_40k.yml b/configs/ann/ann_resnet101_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/ann/ann_resnet101_os8_voc12aug_512x512_40k.yml rename to configs/ann/ann_resnet101_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/ann/ann_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/ann/ann_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/ann/ann_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/ann/ann_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/ann/ann_resnet50_os8_voc12aug_512x512_40k.yml b/configs/ann/ann_resnet50_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/ann/ann_resnet50_os8_voc12aug_512x512_40k.yml rename to configs/ann/ann_resnet50_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/bisenet/README.md b/configs/bisenet/README.md similarity index 100% rename from dygraph/configs/bisenet/README.md rename to configs/bisenet/README.md diff --git a/dygraph/configs/bisenet/bisenet_cityscapes_1024x1024_160k.yml b/configs/bisenet/bisenet_cityscapes_1024x1024_160k.yml similarity index 100% rename from dygraph/configs/bisenet/bisenet_cityscapes_1024x1024_160k.yml rename to configs/bisenet/bisenet_cityscapes_1024x1024_160k.yml diff --git a/dygraph/configs/danet/README.md b/configs/danet/README.md similarity index 100% rename from dygraph/configs/danet/README.md rename to configs/danet/README.md diff --git a/dygraph/configs/danet/danet_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/danet/danet_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/danet/danet_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/danet/danet_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/danet/danet_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/danet/danet_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/danet/danet_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/danet/danet_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/deeplabv3/README.md b/configs/deeplabv3/README.md similarity index 100% rename from dygraph/configs/deeplabv3/README.md rename to configs/deeplabv3/README.md diff --git a/dygraph/configs/deeplabv3/deeplabv3_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/deeplabv3/deeplabv3_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/deeplabv3/deeplabv3_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/deeplabv3/deeplabv3_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/deeplabv3/deeplabv3_resnet101_os8_voc12aug_512x512_40k.yml b/configs/deeplabv3/deeplabv3_resnet101_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/deeplabv3/deeplabv3_resnet101_os8_voc12aug_512x512_40k.yml rename to configs/deeplabv3/deeplabv3_resnet101_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/deeplabv3/deeplabv3_resnet50_os8_voc12aug_512x512_40k.yml b/configs/deeplabv3/deeplabv3_resnet50_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/deeplabv3/deeplabv3_resnet50_os8_voc12aug_512x512_40k.yml rename to configs/deeplabv3/deeplabv3_resnet50_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/deeplabv3p/README.md b/configs/deeplabv3p/README.md similarity index 100% rename from dygraph/configs/deeplabv3p/README.md rename to configs/deeplabv3p/README.md diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml b/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml similarity index 100% rename from dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml rename to configs/deeplabv3p/deeplabv3p_resnet101_os8_cityscapes_769x769_80k.yml diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_voc12aug_512x512_40k.yml b/configs/deeplabv3p/deeplabv3p_resnet101_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/deeplabv3p/deeplabv3p_resnet101_os8_voc12aug_512x512_40k.yml rename to configs/deeplabv3p/deeplabv3p_resnet101_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/deeplabv3p/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/deeplabv3p/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/deeplabv3p/deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/deeplabv3p/deeplabv3p_resnet50_os8_voc12aug_512x512_40k.yml b/configs/deeplabv3p/deeplabv3p_resnet50_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/deeplabv3p/deeplabv3p_resnet50_os8_voc12aug_512x512_40k.yml rename to configs/deeplabv3p/deeplabv3p_resnet50_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/fastscnn/README.md b/configs/fastscnn/README.md similarity index 100% rename from dygraph/configs/fastscnn/README.md rename to configs/fastscnn/README.md diff --git a/dygraph/configs/fastscnn/fastscnn_cityscapes_1024x1024_160k.yml b/configs/fastscnn/fastscnn_cityscapes_1024x1024_160k.yml similarity index 100% rename from dygraph/configs/fastscnn/fastscnn_cityscapes_1024x1024_160k.yml rename to configs/fastscnn/fastscnn_cityscapes_1024x1024_160k.yml diff --git a/dygraph/configs/fcn/README.md b/configs/fcn/README.md similarity index 100% rename from dygraph/configs/fcn/README.md rename to configs/fcn/README.md diff --git a/dygraph/configs/fcn/fcn_hrnetw18_cityscapes_1024x512_80k.yml b/configs/fcn/fcn_hrnetw18_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/fcn/fcn_hrnetw18_cityscapes_1024x512_80k.yml rename to configs/fcn/fcn_hrnetw18_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml b/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml rename to configs/fcn/fcn_hrnetw18_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/fcn/fcn_hrnetw48_cityscapes_1024x512_80k.yml b/configs/fcn/fcn_hrnetw48_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/fcn/fcn_hrnetw48_cityscapes_1024x512_80k.yml rename to configs/fcn/fcn_hrnetw48_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml b/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml rename to configs/fcn/fcn_hrnetw48_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/gcnet/README.md b/configs/gcnet/README.md similarity index 100% rename from dygraph/configs/gcnet/README.md rename to configs/gcnet/README.md diff --git a/dygraph/configs/gcnet/gcnet_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/gcnet/gcnet_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/gcnet/gcnet_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/gcnet/gcnet_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml b/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml rename to configs/gcnet/gcnet_resnet101_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/gcnet/gcnet_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/gcnet/gcnet_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/gcnet/gcnet_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/gcnet/gcnet_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml b/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml rename to configs/gcnet/gcnet_resnet50_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/ocrnet/README.md b/configs/ocrnet/README.md similarity index 100% rename from dygraph/configs/ocrnet/README.md rename to configs/ocrnet/README.md diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw18_cityscapes_1024x512_160k.yml b/configs/ocrnet/ocrnet_hrnetw18_cityscapes_1024x512_160k.yml similarity index 100% rename from dygraph/configs/ocrnet/ocrnet_hrnetw18_cityscapes_1024x512_160k.yml rename to configs/ocrnet/ocrnet_hrnetw18_cityscapes_1024x512_160k.yml diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml b/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml rename to configs/ocrnet/ocrnet_hrnetw18_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw48_cityscapes_1024x512_160k.yml b/configs/ocrnet/ocrnet_hrnetw48_cityscapes_1024x512_160k.yml similarity index 100% rename from dygraph/configs/ocrnet/ocrnet_hrnetw48_cityscapes_1024x512_160k.yml rename to configs/ocrnet/ocrnet_hrnetw48_cityscapes_1024x512_160k.yml diff --git a/dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml b/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml rename to configs/ocrnet/ocrnet_hrnetw48_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/pspnet/README.md b/configs/pspnet/README.md similarity index 100% rename from dygraph/configs/pspnet/README.md rename to configs/pspnet/README.md diff --git a/dygraph/configs/pspnet/pspnet_resnet101_os8_cityscapes_1024x512_80k.yml b/configs/pspnet/pspnet_resnet101_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/pspnet/pspnet_resnet101_os8_cityscapes_1024x512_80k.yml rename to configs/pspnet/pspnet_resnet101_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/pspnet/pspnet_resnet101_os8_voc12aug_512x512_40k.yml b/configs/pspnet/pspnet_resnet101_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/pspnet/pspnet_resnet101_os8_voc12aug_512x512_40k.yml rename to configs/pspnet/pspnet_resnet101_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/pspnet/pspnet_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/pspnet/pspnet_resnet50_os8_cityscapes_1024x512_80k.yml similarity index 100% rename from dygraph/configs/pspnet/pspnet_resnet50_os8_cityscapes_1024x512_80k.yml rename to configs/pspnet/pspnet_resnet50_os8_cityscapes_1024x512_80k.yml diff --git a/dygraph/configs/pspnet/pspnet_resnet50_os8_voc12aug_512x512_40k.yml b/configs/pspnet/pspnet_resnet50_os8_voc12aug_512x512_40k.yml similarity index 100% rename from dygraph/configs/pspnet/pspnet_resnet50_os8_voc12aug_512x512_40k.yml rename to configs/pspnet/pspnet_resnet50_os8_voc12aug_512x512_40k.yml diff --git a/dygraph/configs/quick_start/bisenet_optic_disc_512x512_1k.yml b/configs/quick_start/bisenet_optic_disc_512x512_1k.yml similarity index 100% rename from dygraph/configs/quick_start/bisenet_optic_disc_512x512_1k.yml rename to configs/quick_start/bisenet_optic_disc_512x512_1k.yml diff --git a/dygraph/configs/unet/README.md b/configs/unet/README.md similarity index 100% rename from dygraph/configs/unet/README.md rename to configs/unet/README.md diff --git a/dygraph/configs/unet/unet_cityscapes_1024x512_160k.yml b/configs/unet/unet_cityscapes_1024x512_160k.yml similarity index 100% rename from dygraph/configs/unet/unet_cityscapes_1024x512_160k.yml rename to configs/unet/unet_cityscapes_1024x512_160k.yml diff --git a/dygraph/contrib/remote_sensing/README.md b/contrib/remote_sensing/README.md similarity index 100% rename from dygraph/contrib/remote_sensing/README.md rename to contrib/remote_sensing/README.md diff --git a/dygraph/contrib/remote_sensing/fcn_hrnetw48_ccf_256x256_160k.yml b/contrib/remote_sensing/fcn_hrnetw48_ccf_256x256_160k.yml similarity index 100% rename from dygraph/contrib/remote_sensing/fcn_hrnetw48_ccf_256x256_160k.yml rename to contrib/remote_sensing/fcn_hrnetw48_ccf_256x256_160k.yml diff --git a/dygraph/contrib/remote_sensing/ocrnet_hrnetw48_ccf_256x256_80k.yml b/contrib/remote_sensing/ocrnet_hrnetw48_ccf_256x256_80k.yml similarity index 100% rename from dygraph/contrib/remote_sensing/ocrnet_hrnetw48_ccf_256x256_80k.yml rename to contrib/remote_sensing/ocrnet_hrnetw48_ccf_256x256_80k.yml diff --git a/dygraph/docs/add_new_model.md b/docs/add_new_model.md similarity index 100% rename from dygraph/docs/add_new_model.md rename to docs/add_new_model.md diff --git a/dygraph/docs/apis/README.md b/docs/apis/README.md similarity index 100% rename from dygraph/docs/apis/README.md rename to docs/apis/README.md diff --git a/dygraph/docs/apis/backbones.md b/docs/apis/backbones.md similarity index 100% rename from dygraph/docs/apis/backbones.md rename to docs/apis/backbones.md diff --git a/dygraph/docs/apis/core.md b/docs/apis/core.md similarity index 100% rename from dygraph/docs/apis/core.md rename to docs/apis/core.md diff --git a/dygraph/docs/apis/cvlibs.md b/docs/apis/cvlibs.md similarity index 100% rename from dygraph/docs/apis/cvlibs.md rename to docs/apis/cvlibs.md diff --git a/dygraph/docs/apis/datasets.md b/docs/apis/datasets.md similarity index 100% rename from dygraph/docs/apis/datasets.md rename to docs/apis/datasets.md diff --git a/dygraph/docs/apis/models.md b/docs/apis/models.md similarity index 100% rename from dygraph/docs/apis/models.md rename to docs/apis/models.md diff --git a/dygraph/docs/apis/transforms.md b/docs/apis/transforms.md similarity index 100% rename from dygraph/docs/apis/transforms.md rename to docs/apis/transforms.md diff --git a/dygraph/docs/apis/utils.md b/docs/apis/utils.md similarity index 100% rename from dygraph/docs/apis/utils.md rename to docs/apis/utils.md diff --git a/docs/data_prepare.md b/docs/data_prepare.md index de1fd7965c..b05665301f 100644 --- a/docs/data_prepare.md +++ b/docs/data_prepare.md @@ -1,175 +1,100 @@ -# PaddleSeg 数据准备 - -## 数据标注 - -### 标注协议 -PaddleSeg采用单通道的标注图片,每一种像素值代表一种类别,像素标注类别需要从0开始递增,例如0,1,2,3表示有4种类别。 - -**NOTE:** 标注图像请使用PNG无损压缩格式的图片。标注类别最多为256类。 - -### 灰度标注vs伪彩色标注 -一般的分割库使用单通道灰度图作为标注图片,往往显示出来是全黑的效果。灰度标注图的弊端: -1. 对图像标注后,无法直接观察标注是否正确。 -2. 模型测试过程无法直接判断分割的实际效果。 - -**PaddleSeg支持伪彩色图作为标注图片,在原来的单通道图片基础上,注入调色板。在基本不增加图片大小的基础上,却可以显示出彩色的效果。** - -同时PaddleSeg也兼容灰度图标注,用户原来的灰度数据集可以不做修改,直接使用。 -![](./imgs/annotation/image-11.png) - -### 灰度标注转换为伪彩色标注 -如果用户需要转换成伪彩色标注图,可使用我们的转换工具。适用于以下两种常见的情况: -1. 如果您希望将指定目录下的所有灰度标注图转换为伪彩色标注图,则执行以下命令,指定灰度标注所在的目录即可。 -```buildoutcfg -python pdseg/tools/gray2pseudo_color.py -``` - -|参数|用途| -|-|-| -|dir_or_file|指定灰度标注所在目录| -|output_dir|彩色标注图片的输出目录| - -2. 如果您仅希望将指定数据集中的部分灰度标注图转换为伪彩色标注图,则执行以下命令,需要已有文件列表,按列表读取指定图片。 -```buildoutcfg -python pdseg/tools/gray2pseudo_color.py --dataset_dir --file_separator -``` -|参数|用途| -|-|-| -|dir_or_file|指定文件列表路径| -|output_dir|彩色标注图片的输出目录| -|--dataset_dir|数据集所在根目录| -|--file_separator|文件列表分隔符| - -### 标注教程 -用户需预先采集好用于训练、评估和测试的图片,然后使用数据标注工具完成数据标注。 - -PddleSeg已支持2种标注工具:LabelMe、精灵数据标注工具。标注教程如下: - -- [LabelMe标注教程](annotation/labelme2seg.md) -- [精灵数据标注工具教程](annotation/jingling2seg.md) - - -## 文件列表 - -### 文件列表规范 - -PaddleSeg采用通用的文件列表方式组织训练集、验证集和测试集。在训练、评估、可视化过程前必须准备好相应的文件列表。 - -文件列表组织形式如下 -``` -原始图片路径 [SEP] 标注图片路径 -``` - -其中`[SEP]`是文件路径分割符,可以在`DATASET.SEPARATOR`配置项中修改, 默认为空格。文件列表的路径以数据集根目录作为相对路径起始点,`DATASET.DATA_DIR`即为数据集根目录。 - -如下图所示,左边为原图的图片路径,右边为图片对应的标注路径。 - -![cityscapes_filelist](./imgs/file_list.png) - -**注意事项** - -* 务必保证分隔符在文件列表中每行只存在一次, 如文件名中存在空格,请使用"|"等文件名不可用字符进行切分 - -* 文件列表请使用**UTF-8**格式保存, PaddleSeg默认使用UTF-8编码读取file_list文件 - -若数据集缺少标注图片,则文件列表不用包含分隔符和标注图片路径,如下图所示。 - -![cityscapes_filelist](./imgs/file_list2.png) - -**注意事项** - -此时的文件列表仅可在调用`pdseg/vis.py`进行可视化展示时使用, -即仅可在`DATASET.TEST_FILE_LIST`和`DATASET.VIS_FILE_LIST`配置项中使用。 -不可在`DATASET.TRAIN_FILE_LIST`和`DATASET.VAL_FILE_LIST`配置项中使用。 - - -**符合规范的文件列表是什么样的呢?** - -请参考目录[`./docs/annotation/cityscapes_demo`](../docs/annotation/cityscapes_demo/)。 - -### 数据集目录结构整理 - -如果用户想要生成数据集的文件列表,需要整理成如下的目录结构(类似于Cityscapes数据集): - -``` -./dataset/ # 数据集根目录 -├── annotations # 标注目录 -│   ├── test -│   │   ├── ... -│   │   └── ... -│   ├── train -│   │   ├── ... -│   │   └── ... -│   └── val -│   ├── ... -│   └── ... -└── images # 原图目录 - ├── test - │   ├── ... - │   └── ... - ├── train - │   ├── ... - │   └── ... - └── val - ├── ... - └── ... -Note:以上目录名可任意 -``` - -### 文件列表生成 -PaddleSeg提供了生成文件列表的使用脚本,可适用于自定义数据集或cityscapes数据集,并支持通过不同的Flags来开启特定功能。 -``` -python pdseg/tools/create_dataset_list.py ${FLAGS} -``` -运行后将在数据集根目录下生成训练/验证/测试集的文件列表(文件主名与`--second_folder`一致,扩展名为`.txt`)。 - -**Note:** 生成文件列表要求:要么原图和标注图片数量一致,要么只有原图,没有标注图片。若数据集缺少标注图片,仍可自动生成不含分隔符和标注图片路径的文件列表。 - -#### 命令行FLAGS列表 - -|FLAG|用途|默认值|参数数目| -|-|-|-|-| -|--type|指定数据集类型,`cityscapes`或`自定义`|`自定义`|1| -|--separator|文件列表分隔符|"|"|1| -|--folder|图片和标签集的文件夹名|"images" "annotations"|2| -|--second_folder|训练/验证/测试集的文件夹名|"train" "val" "test"|若干| -|--format|图片和标签集的数据格式|"jpg" "png"|2| -|--postfix|按文件主名(无扩展名)是否包含指定后缀对图片和标签集进行筛选|"" ""(2个空字符)|2| - -#### 使用示例 -- **对于自定义数据集** - -若您已经按上述说明整理好了数据集目录结构,可以运行下面的命令生成文件列表。 - -``` -# 生成文件列表,其分隔符为空格,图片和标签集的数据格式都为png -python pdseg/tools/create_dataset_list.py --separator " " --format png png -``` -``` -# 生成文件列表,其图片和标签集的文件夹名为img和gt,训练和验证集的文件夹名为training和validation,不生成测试集列表 -python pdseg/tools/create_dataset_list.py \ - --folder img gt --second_folder training validation -``` -**Note:** 必须指定自定义数据集目录,可以按需要设定FLAG。无需指定`--type`。 - -- **对于cityscapes数据集** - -若您使用的是cityscapes数据集,可以运行下面的命令生成文件列表。 - -``` -# 生成cityscapes文件列表,其分隔符为逗号 -python pdseg/tools/create_dataset_list.py --type cityscapes --separator "," -``` -**Note:** - -必须指定cityscapes数据集目录,`--type`必须为`cityscapes`。 - -在cityscapes类型下,部分FLAG将被重新设定,无需手动指定,具体如下: - -|FLAG|固定值| -|-|-| -|--folder|"leftImg8bit" "gtFine"| -|--format|"png" "png"| -|--postfix|"_leftImg8bit" "_gtFine_labelTrainIds"| - -其余FLAG可以按需要设定。 +# 数据集准备 + +PaddleSeg目前支持CityScapes、ADE20K、Pascal VOC等数据集的加载,在加载数据集时,如若本地不存在对应数据,则会自动触发下载(除Cityscapes数据集). + +## 关于CityScapes数据集 +Cityscapes是关于城市街道场景的语义理解图片数据集。它主要包含来自50个不同城市的街道场景, +拥有5000张(2048 x 1024)城市驾驶场景的高质量像素级注释图像,包含19个类别。其中训练集2975张, 验证集500张和测试集1525张。 + +由于协议限制,请自行前往[CityScapes官网](https://www.cityscapes-dataset.com/)下载数据集, +我们建议您将数据集存放于`PaddleSeg/dygraph/data`中,以便与我们配置文件完全兼容。数据集下载后请组织成如下结构: + + cityscapes + | + |--leftImg8bit + | |--train + | |--val + | |--test + | + |--gtFine + | |--train + | |--val + | |--test + +运行下列命令进行标签转换: +```shell +pip install cityscapesscripts +python tools/convert_cityscapes.py --cityscapes_path data/cityscapes --num_workers 8 +``` +其中`cityscapes_path`应根据实际数据集路径进行调整。 `num_workers`决定启动的进程数,可根据实际情况进行调整大小。 + +## 关于Pascal VOC 2012数据集 +[Pascal VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/)数据集以对象分割为主,包含20个类别和背景类,其中训练集1464张,验证集1449张。 +通常情况下会利用[SBD(Semantic Boundaries Dataset)](http://home.bharathh.info/pubs/codes/SBD/download.html)进行扩充,扩充后训练集10582张。 +运行下列命令进行SBD数据集下载并进行扩充: +```shell +python tools/voc_augment.py --voc_path data/VOCdevkit --num_workers 8 +``` +其中`voc_path`应根据实际数据集路径进行调整。 + +**注意** 运行前请确保在dygraph目录下执行过下列命令: +```shell +export PYTHONPATH=`pwd` +# windows下请执行相面的命令 +# set PYTHONPATH=%cd% +``` + +## 关于ADE20K数据集 +[ADE20K](http://sceneparsing.csail.mit.edu/)由MIT发布的可用于场景感知、分割和多物体识别等多种任务的数据集。 +其涵盖了150个语义类别,包括训练集20210张,验证集2000张。 + +## 自定义数据集 + +如果您需要使用自定义数据集进行训练,请按照以下步骤准备数据. + +1.推荐整理成如下结构 + + custom_dataset + | + |--images + | |--image1.jpg + | |--image2.jpg + | |--... + | + |--labels + | |--label1.jpg + | |--label2.png + | |--... + | + |--train.txt + | + |--val.txt + | + |--test.txt + +其中train.txt和val.txt的内容如下所示: + + images/image1.jpg labels/label1.png + images/image2.jpg labels/label2.png + ... + +2.标注图像的标签从0,1依次取值,不可间隔。若有需要忽略的像素,则按255进行标注。 + +可按如下方式对自定义数据集进行配置: +```yaml +train_dataset: + type: Dataset + dataset_root: custom_dataset + train_path: custom_dataset/train.txt + num_classes: 2 + transforms: + - type: ResizeStepScaling + min_scale_factor: 0.5 + max_scale_factor: 2.0 + scale_step_size: 0.25 + - type: RandomPaddingCrop + crop_size: [512, 512] + - type: RandomHorizontalFlip + - type: Normalize + mode: train +``` diff --git a/dygraph/docs/images/quick_start_predict.jpg b/docs/images/quick_start_predict.jpg similarity index 100% rename from dygraph/docs/images/quick_start_predict.jpg rename to docs/images/quick_start_predict.jpg diff --git a/dygraph/docs/images/quick_start_vdl.jpg b/docs/images/quick_start_vdl.jpg similarity index 100% rename from dygraph/docs/images/quick_start_vdl.jpg rename to docs/images/quick_start_vdl.jpg diff --git a/dygraph/docs/quick_start.md b/docs/quick_start.md similarity index 100% rename from dygraph/docs/quick_start.md rename to docs/quick_start.md diff --git a/dygraph/README.md b/dygraph/README.md deleted file mode 100644 index 0d3460bab8..0000000000 --- a/dygraph/README.md +++ /dev/null @@ -1,85 +0,0 @@ -English | [简体中文](README_CN.md) - -# PaddleSeg(Dynamic Graph) - -[![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg) -[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) -[![Version](https://img.shields.io/github/release/PaddlePaddle/PaddleSeg.svg)](https://github.com/PaddlePaddle/PaddleSeg/releases) -![python version](https://img.shields.io/badge/python-3.6+-orange.svg) -![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg) - -Welcome to the dynamic version! PaddleSeg is the first development kit which supports PaddlePaddle 2.0. Currently, we provide an experimental version that allows developers to have full-featured experience on dynamic graph. In the near future, the dynamic version will be set as default, and the static one will be moved to "legacy" directory. - -The full-detailed documents and tutorials are coming soon. So far there are minimum tutorials that help you to enjoy the strengths of dynamic version. - -## Model Zoo - -|Model\Backbone|ResNet50|ResNet101|HRNetw18|HRNetw48| -|-|-|-|-|-| -|[ANN](./configs/ann)|✔|✔||| -|[BiSeNetv2](./configs/bisenet)|-|-|-|-| -|[DANet](./configs/danet)|✔|✔||| -|[Deeplabv3](./configs/deeplabv3)|✔|✔||| -|[Deeplabv3P](./configs/deeplabv3p)|✔|✔||| -|[Fast-SCNN](./configs/fastscnn)|-|-|-|-| -|[FCN](./configs/fcn)|||✔|✔| -|[GCNet](./configs/gcnet)|✔|✔||| -|[OCRNet](./configs/ocrnet/)|||✔|✔| -|[PSPNet](./configs/pspnet)|✔|✔||| -|[UNet](./configs/unet)|-|-|-|-| - -## Dataset - -- [x] Cityscapes -- [x] Pascal VOC -- [x] ADE20K -- [ ] Pascal Context -- [ ] COCO stuff - -## Installation - -1. Install PaddlePaddle - -System Requirements: -* PaddlePaddle >= 2.0.0rc -* Python >= 3.6+ - -> Note: the above requirements are for the **dynamic** graph version. If you intent to use the static one, please refers to [here](../README.md). - -Highly recommend you install the GPU version of PaddlePaddle, due to large overhead of segmentation models, otherwise it could be out of memory while running the models. - -For more detailed installation tutorials, please refer to the official website of [PaddlePaddle](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-beta/install/index_cn.html)。 - - -### Download PaddleSeg - -``` -git clone https://github.com/PaddlePaddle/PaddleSeg -``` - -### Install Dependencies -Install the python dependencies via the following commands,and please make sure execute it at least once in your branch. -```shell -cd PaddleSeg/dygraph -export PYTHONPATH=`pwd` -# Run the following one on Windows -# set PYTHONPATH=%cd% -pip install -r requirements.txt -``` - -## Quick Training -```shell -python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml -``` - -## Tutorials - -* [Get Started](./docs/quick_start.md) -* [Data Preparation](./docs/data_prepare.md) -* [Training Configuration](./configs/) -* [Add New Components](./docs/add_new_model.md) - - -## Feedbacks and Contact -* The dynamic version is still under development, if you find any issue or have an idea on new features, please don't hesitate to contact us via [GitHub Issues](https://github.com/PaddlePaddle/PaddleSeg/issues). -* PaddleSeg User Group (QQ): 850378321 or 793114768 diff --git a/dygraph/README_CN.md b/dygraph/README_CN.md deleted file mode 100644 index 084f5ad903..0000000000 --- a/dygraph/README_CN.md +++ /dev/null @@ -1,74 +0,0 @@ -简体中文 | [English](README.md) - -# PaddleSeg(动态图版本) - -本目录提供了PaddleSeg的动态图版本,目前已经完成了模型训练、评估、数据处理等功能,在未来的版本中,PaddleSeg将会启动默认的动态图模式。目前该目录处于实验阶段,如果您在使用过程中遇到任何问题,请通过issue反馈给我们,我们将会在第一时间跟进处理。 - -## 模型库 - -|模型\骨干网络|ResNet50|ResNet101|HRNetw18|HRNetw48| -|-|-|-|-|-| -|[ANN](./configs/ann)|✔|✔||| -|[BiSeNetv2](./configs/bisenet)|-|-|-|-| -|[DANet](./configs/danet)|✔|✔||| -|[Deeplabv3](./configs/deeplabv3)|✔|✔||| -|[Deeplabv3P](./configs/deeplabv3p)|✔|✔||| -|[Fast-SCNN](./configs/fastscnn)|-|-|-|-| -|[FCN](./configs/fcn)|||✔|✔| -|[GCNet](./configs/gcnet)|✔|✔||| -|[OCRNet](./configs/ocrnet/)|||✔|✔| -|[PSPNet](./configs/pspnet)|✔|✔||| -|[UNet](./configs/unet)|-|-|-|-| - -## 数据集 - -- [x] Cityscapes -- [x] Pascal VOC -- [x] ADE20K -- [ ] Pascal Context -- [ ] COCO stuff - -## 安装 - -1. 安装PaddlePaddle - -版本要求 - -* PaddlePaddle >= 2.0.0rc - -* Python >= 3.6+ - -由于图像分割模型计算开销大,推荐在GPU版本的PaddlePaddle下使用PaddleSeg。推荐安装10.0以上的CUDA环境。 - - -安装教程请见[PaddlePaddle官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-beta/install/index_cn.html)。 - - -2. 下载PaddleSeg代码 -```shell -git clone https://github.com/PaddlePaddle/PaddleSeg -``` - -3. 安装PaddleSeg依赖 -通过以下命令安装python包依赖,请确保在该分支上至少执行过一次以下命令: - - -```shell -cd PaddleSeg/dygraph -export PYTHONPATH=`pwd` -# windows下请执行以下命令 -# set PYTHONPATH=%cd% -pip install -r requirements.txt -``` - -## 训练 -```shell -python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml -``` - -## 使用教程 - -* [快速入门](./docs/quick_start.md) -* [数据集准备](./docs/data_prepare.md) -* [配置项](./configs/) -* [Add New Components](./docs/add_new_model.md) diff --git a/dygraph/docs/data_prepare.md b/dygraph/docs/data_prepare.md deleted file mode 100644 index b05665301f..0000000000 --- a/dygraph/docs/data_prepare.md +++ /dev/null @@ -1,100 +0,0 @@ -# 数据集准备 - -PaddleSeg目前支持CityScapes、ADE20K、Pascal VOC等数据集的加载,在加载数据集时,如若本地不存在对应数据,则会自动触发下载(除Cityscapes数据集). - -## 关于CityScapes数据集 -Cityscapes是关于城市街道场景的语义理解图片数据集。它主要包含来自50个不同城市的街道场景, -拥有5000张(2048 x 1024)城市驾驶场景的高质量像素级注释图像,包含19个类别。其中训练集2975张, 验证集500张和测试集1525张。 - -由于协议限制,请自行前往[CityScapes官网](https://www.cityscapes-dataset.com/)下载数据集, -我们建议您将数据集存放于`PaddleSeg/dygraph/data`中,以便与我们配置文件完全兼容。数据集下载后请组织成如下结构: - - cityscapes - | - |--leftImg8bit - | |--train - | |--val - | |--test - | - |--gtFine - | |--train - | |--val - | |--test - -运行下列命令进行标签转换: -```shell -pip install cityscapesscripts -python tools/convert_cityscapes.py --cityscapes_path data/cityscapes --num_workers 8 -``` -其中`cityscapes_path`应根据实际数据集路径进行调整。 `num_workers`决定启动的进程数,可根据实际情况进行调整大小。 - -## 关于Pascal VOC 2012数据集 -[Pascal VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/)数据集以对象分割为主,包含20个类别和背景类,其中训练集1464张,验证集1449张。 -通常情况下会利用[SBD(Semantic Boundaries Dataset)](http://home.bharathh.info/pubs/codes/SBD/download.html)进行扩充,扩充后训练集10582张。 -运行下列命令进行SBD数据集下载并进行扩充: -```shell -python tools/voc_augment.py --voc_path data/VOCdevkit --num_workers 8 -``` -其中`voc_path`应根据实际数据集路径进行调整。 - -**注意** 运行前请确保在dygraph目录下执行过下列命令: -```shell -export PYTHONPATH=`pwd` -# windows下请执行相面的命令 -# set PYTHONPATH=%cd% -``` - -## 关于ADE20K数据集 -[ADE20K](http://sceneparsing.csail.mit.edu/)由MIT发布的可用于场景感知、分割和多物体识别等多种任务的数据集。 -其涵盖了150个语义类别,包括训练集20210张,验证集2000张。 - -## 自定义数据集 - -如果您需要使用自定义数据集进行训练,请按照以下步骤准备数据. - -1.推荐整理成如下结构 - - custom_dataset - | - |--images - | |--image1.jpg - | |--image2.jpg - | |--... - | - |--labels - | |--label1.jpg - | |--label2.png - | |--... - | - |--train.txt - | - |--val.txt - | - |--test.txt - -其中train.txt和val.txt的内容如下所示: - - images/image1.jpg labels/label1.png - images/image2.jpg labels/label2.png - ... - -2.标注图像的标签从0,1依次取值,不可间隔。若有需要忽略的像素,则按255进行标注。 - -可按如下方式对自定义数据集进行配置: -```yaml -train_dataset: - type: Dataset - dataset_root: custom_dataset - train_path: custom_dataset/train.txt - num_classes: 2 - transforms: - - type: ResizeStepScaling - min_scale_factor: 0.5 - max_scale_factor: 2.0 - scale_step_size: 0.25 - - type: RandomPaddingCrop - crop_size: [512, 512] - - type: RandomHorizontalFlip - - type: Normalize - mode: train -``` diff --git a/legacy/README.md b/legacy/README.md new file mode 100644 index 0000000000..963c23fc3a --- /dev/null +++ b/legacy/README.md @@ -0,0 +1,115 @@ +English | [简体中文](README_CN.md) + +# PaddleSeg + +[![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg) +[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) +[![Version](https://img.shields.io/github/release/PaddlePaddle/PaddleSeg.svg)](https://github.com/PaddlePaddle/PaddleSeg/releases) +![python version](https://img.shields.io/badge/python-3.6+-orange.svg) +![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg) + + *[2020-12-02] PaddleSeg has released the [dynamic graph](./dygraph) version, which supports PaddlePaddle 2.0rc. For the static graph, we only fix bugs without adding new features. See detailed [release notes](./docs/release_notes.md).* + +## Introduction + +PaddleSeg is an end-to-end image segmentation development kit based on PaddlePaddle, which aims to help developers in the whole process of training models, optimizing performance and inference speed, and deploying models. Currently PaddleSeg supports seven efficient segmentation models, including DeepLabv3+, U-Net, ICNet, PSPNet, HRNet, Fast-SCNN, and OCRNet, which are extensively used in both academia and industry. Enjoy your Seg journey! + +![demo](./docs/imgs/cityscapes.png) + +## Main Features + +- **Practical Data Augmentation Techniques** + +PaddleSeg provides 10+ data augmentation techniques, which are developed from the product-level applications in Baidu. The techniques are able to help developers improve the generalization and robustness ability of their customized models. + +- **Modular Design** + +PaddleSeg supports seven popular segmentation models, including U-Net, DeepLabv3+, ICNet, PSPNet, HRNet, Fast-SCNN, and OCRNet. Combing with different components, such as pre-trained models, adjustable backbone architectures and loss functions, developer can easily build an efficient segmentation model according to their practical performance requirements. + +- **High Performance** + +PaddleSeg supports the efficient acceleration strategies, such as multi-processing I/O operations, and multi-GPUs parallel training. Moreover, integrating GPU memory optimization techniques in the PaddlePaddle framework, PaddleSeg significantly reduces training overhead of the segmentation models, which helps developers complete the segmentation tasks in a high-efficient way. + +- **Industry-Level Deployment** + +PaddleSeg supports the industry-level deployment in both **server** and **mobile devices** with the high-performance inference engine and image processing ability, which helps developers achieve the high-performance deployment and integration of segmentation model efficiently. Particularly, using another paddle tool [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite), the segmentation models trained in PaddleSeg are able to be deployed on mobile/embedded devices quickly and easily. + +- **Rich Practical Cases** + +PaddleSeg provides rich practical cases in industry, such as human segmentation, mechanical meter segmentation, lane segmentation, remote sensing image segmentation, human parsing, and industry inspection, etc. The practical cases allow developers to get a closer look at the image segmentation area, and get more hand-on experiences on the real practice. + +## Installation + +### 1. Install PaddlePaddle + +System Requirements: +* PaddlePaddle >= 1.7.0 and < 2.0 +* Python >= 3.5+ + +> Note: the above requirements are for the **static** graph version. If you intent to use the dynamic one, please refers to [here](./dygraph). + +Highly recommend you install the GPU version of PaddlePaddle, due to large overhead of segmentation models, otherwise it could be out of memory while running the models. + +For more detailed installation tutorials, please refer to the official website of [PaddlePaddle](https://www.paddlepaddle.org.cn/install/quick)。 + +### 2. Download PaddleSeg + +``` +git clone https://github.com/PaddlePaddle/PaddleSeg +``` + +### 3. Install Dependencies +Install the python dependencies via the following commands,and please make sure execute it at least once in your branch. +``` +cd PaddleSeg +pip install -r requirements.txt +``` + +## Tutorials + +For a better understanding of PaddleSeg, we provide comprehensive tutorials to show the whole process of using PaddleSeg on model training, evaluation and deployment. Besides the basic usages of PaddleSeg, the design insights will be also mentioned in the tutorials. + +### Quick Start + +* [PaddleSeg Start](./docs/usage.md) + +### Basic Usages + +* [Customized Data Preparation](./docs/data_prepare.md) +* [Scripts and Config Guide](./docs/config.md) +* [Data and Config Verification](./docs/check.md) +* [Segmentation Models](./docs/models.md) +* [Pretrained Models](./docs/model_zoo.md) +* [DeepLabv3+ Tutorial](./tutorial/finetune_deeplabv3plus.md) + +### Inference and Deployment + +* [Model Export](./docs/model_export.md) +* [Python Inference](./deploy/python/) +* [C++ Inference](./deploy/cpp/) +* [Paddle-Lite Mobile Inference & Deployment](./deploy/lite/) +* [PaddleServing Inference & Deployment](./deploy/paddle-serving) + + +### Advanced features + +* [Data Augmentation](./docs/data_aug.md) +* [Loss Functions](./docs/loss_select.md) +* [Practical Cases](./contrib) +* [Multiprocessing and Mixed-Precision Training](./docs/multiple_gpus_train_and_mixed_precision_train.md) +* Model Compression ([Quantization](./slim/quantization/README.md), [Distillation](./slim/distillation/README.md), [Pruning](./slim/prune/README.md), [NAS](./slim/nas/README.md)) + + +### Online Tutorials + +We further provide a few online tutorials in Baidu AI Studio:[Get Started](https://aistudio.baidu.com/aistudio/projectdetail/100798), [U-Net](https://aistudio.baidu.com/aistudio/projectDetail/102889), [DeepLabv3+](https://aistudio.baidu.com/aistudio/projectDetail/226703), [Industry Inspection](https://aistudio.baidu.com/aistudio/projectdetail/184392), [HumanSeg](https://aistudio.baidu.com/aistudio/projectdetail/475345), [More](https://aistudio.baidu.com/aistudio/projectdetail/226710). + + +## Feedbacks and Contact +* If your question is not answered properly in [FAQ](./docs/faq.md) or you have an idea on PaddleSeg, please report an issue via [Github Issues](https://github.com/PaddlePaddle/PaddleSeg/issues). +* PaddleSeg User Group (QQ): 850378321 or 793114768 + + +## Contributing + +All contributions and suggestions are welcomed. If you want to contribute to PaddleSeg,please summit an issue or create a pull request directly. diff --git a/legacy/README_CN.md b/legacy/README_CN.md new file mode 100644 index 0000000000..c953b3cca0 --- /dev/null +++ b/legacy/README_CN.md @@ -0,0 +1,230 @@ +简体中文 | [English](README.md) + +# PaddleSeg + +[![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg) +[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) +[![Version](https://img.shields.io/github/release/PaddlePaddle/PaddleSeg.svg)](https://github.com/PaddlePaddle/PaddleSeg/releases) +![python version](https://img.shields.io/badge/python-3.6+-orange.svg) +![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg) + + *[2020-12-02] PaddleSeg已经发布了全新的[动态图版本](./dygraph),全面适配 PaddlePaddle 2.0rc, 静态图版本只作维护不再添加新功能,更多信息请查看详细[更新日志](./docs/release_notes.md).* + +## 简介 + +PaddleSeg是基于[PaddlePaddle](https://www.paddlepaddle.org.cn)开发的端到端图像分割开发套件,覆盖了DeepLabv3+, U-Net, ICNet, PSPNet, HRNet, Fast-SCNN等主流分割网络。通过模块化的设计,以配置化方式驱动模型组合,帮助开发者更便捷地完成从训练到部署的全流程图像分割应用。 + +- [特点](#特点) +- [安装](#安装) +- [使用教程](#使用教程) + - [快速入门](#快速入门) + - [基础功能](#基础功能) + - [预测部署](#预测部署) + - [高级功能](#高级功能) +- [在线体验](#在线体验) +- [FAQ](#FAQ) +- [交流与反馈](#交流与反馈) +- [更新日志](#更新日志) +- [贡献代码](#贡献代码) + +## 特点 + +- **丰富的数据增强** + +基于百度视觉技术部的实际业务经验,内置10+种数据增强策略,可结合实际业务场景进行定制组合,提升模型泛化能力和鲁棒性。 + +- **模块化设计** + +支持U-Net, DeepLabv3+, ICNet, PSPNet, HRNet, Fast-SCNN六种主流分割网络,结合预训练模型和可调节的骨干网络,满足不同性能和精度的要求;选择不同的损失函数如Dice Loss, Lovasz Loss等方式可以强化小目标和不均衡样本场景下的分割精度。 + +- **高性能** + +PaddleSeg支持多进程I/O、多卡并行等训练加速策略,结合飞桨核心框架的显存优化功能,可大幅度减少分割模型的显存开销,让开发者更低成本、更高效地完成图像分割训练。 + +- **工业级部署** + +全面提供**服务端**和**移动端**的工业级部署能力,依托飞桨高性能推理引擎和高性能图像处理实现,开发者可以轻松完成高性能的分割模型部署和集成。通过[Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite),可以在移动设备或者嵌入式设备上完成轻量级、高性能的人像分割模型部署。 + +- **产业实践案例** + +PaddleSeg提供丰富地产业实践案例,如[人像分割](./contrib/HumanSeg)、[工业表计检测](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/contrib#%E5%B7%A5%E4%B8%9A%E8%A1%A8%E7%9B%98%E5%88%86%E5%89%B2)、[遥感分割](./contrib/RemoteSensing)、[人体解析](contrib/ACE2P),[工业质检](https://aistudio.baidu.com/aistudio/projectdetail/184392)等产业实践案例,助力开发者更便捷地落地图像分割技术。 + +## 安装 + +### 1. 安装PaddlePaddle + +版本要求 +* PaddlePaddle >= 1.7.0 and < 2.0 +* Python >= 3.5+ + +由于图像分割模型计算开销大,推荐在GPU版本的PaddlePaddle下使用PaddleSeg. + +安装教程请见[PaddlePaddle官网](https://www.paddlepaddle.org.cn/install/quick)。 + +### 2. 下载PaddleSeg代码 + +``` +git clone https://github.com/PaddlePaddle/PaddleSeg +``` + +### 3. 安装PaddleSeg依赖 +通过以下命令安装python包依赖,请确保在该分支上至少执行过一次以下命令: +``` +cd PaddleSeg +pip install -r requirements.txt +``` + +## 使用教程 + +我们提供了一系列的使用教程,来说明如何使用PaddleSeg完成语义分割模型的训练、评估、部署。 + +这一系列的文档被分为**快速入门**、**基础功能**、**预测部署**、**高级功能**四个部分,四个教程由浅至深地介绍PaddleSeg的设计思路和使用方法。 + +### 快速入门 + +* [PaddleSeg快速入门](./docs/usage.md) + +### 基础功能 + +* [自定义数据的标注与准备](./docs/data_prepare.md) +* [脚本使用和配置说明](./docs/config.md) +* [数据和配置校验](./docs/check.md) +* [分割模型介绍](./docs/models.md) +* [预训练模型下载](./docs/model_zoo.md) +* [DeepLabv3+模型使用教程](./tutorial/finetune_deeplabv3plus.md) +* [U-Net模型使用教程](./tutorial/finetune_unet.md) +* [ICNet模型使用教程](./tutorial/finetune_icnet.md) +* [PSPNet模型使用教程](./tutorial/finetune_pspnet.md) +* [HRNet模型使用教程](./tutorial/finetune_hrnet.md) +* [Fast-SCNN模型使用教程](./tutorial/finetune_fast_scnn.md) +* [OCRNet模型使用教程](./tutorial/finetune_ocrnet.md) + +### 预测部署 + +* [模型导出](./docs/model_export.md) +* [Python预测](./deploy/python/) +* [C++预测](./deploy/cpp/) +* [Paddle-Lite移动端预测部署](./deploy/lite/) +* [PaddleServing预测部署](./deploy/paddle-serving) + + +### 高级功能 + +* [PaddleSeg的数据增强](./docs/data_aug.md) +* [PaddleSeg的loss选择](./docs/loss_select.md) +* [PaddleSeg产业实践](./contrib) +* [多进程训练和混合精度训练](./docs/multiple_gpus_train_and_mixed_precision_train.md) +* 使用PaddleSlim进行分割模型压缩([量化](./slim/quantization/README.md), [蒸馏](./slim/distillation/README.md), [剪枝](./slim/prune/README.md), [搜索](./slim/nas/README.md)) +## 在线体验 + +我们在AI Studio平台上提供了在线体验的教程,欢迎体验: + +|在线教程|链接| +|-|-| +|快速开始|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/100798)| +|U-Net图像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectDetail/102889)| +|DeepLabv3+图像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectDetail/226703)| +|工业质检(零件瑕疵检测)|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/184392)| +|人像分割|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/475345)| +|PaddleSeg特色垂类模型|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/226710)| + +## FAQ + +#### Q: 安装requirements.txt指定的依赖包时,部分包提示找不到? + +A: 可能是pip源的问题,这种情况下建议切换为官方源,或者通过`pip install -r requirements.txt -i `指定其他源地址。 + +#### Q:图像分割的数据增强如何配置,Unpadding, StepScaling, RangeScaling的原理是什么? + +A: 更详细数据增强文档可以参考[数据增强](./docs/data_aug.md) + +#### Q: 训练时因为某些原因中断了,如何恢复训练? + +A: 启动训练脚本时通过命令行覆盖TRAIN.RESUME_MODEL_DIR配置为模型checkpoint目录即可, 以下代码示例第100轮重新恢复训练: +``` +python pdseg/train.py --cfg xxx.yaml TRAIN.RESUME_MODEL_DIR /PATH/TO/MODEL_CKPT/100 +``` + +#### Q: 预测时图片过大,导致显存不足如何处理? + +A: 降低Batch size,使用Group Norm策略;请注意训练过程中当`DEFAULT_NORM_TYPE`选择`bn`时,为了Batch Norm计算稳定性,batch size需要满足>=2 + + +## 交流与反馈 +* 欢迎您通过[Github Issues](https://github.com/PaddlePaddle/PaddleSeg/issues)来提交问题、报告与建议 +* 微信公众号:飞桨PaddlePaddle +* QQ群: 703252161 + +

     

+

   微信公众号                官方技术交流QQ群

+ +## 更新日志 + +* 2020.10.28 + + **`v0.7.0`** + * 全面支持Paddle2.0-rc动态图模式,推出PaddleSeg[动态图体验版](./dygraph/) + * 发布大量动态图模型,支持11个分割模型,4个骨干网络,3个数据集: + * 分割模型:ANN, BiSeNetV2, DANet, DeeplabV3, DeeplabV3+, FCN, FastSCNN, GCNet, OCRNet, PSPNet, UNet + * 骨干网络:ResNet, HRNet, MobileNetV3, Xception + * 数据集:Cityscapes, ADE20K, Pascal VOC + + * 提供高精度骨干网络预训练模型以及基于Cityscapes数据集的语义分割[预训练模型](./dygraph/configs/)。Cityscapes精度超过**82%**。 + + +* 2020.08.31 + + **`v0.6.0`** + * 丰富Deeplabv3p网络结构,新增ResNet-vd、MobileNetv3两种backbone,满足高性能与高精度场景,并提供基于Cityscapes和ImageNet的[预训练模型](./docs/model_zoo.md)4个。 + * 新增高精度分割模型OCRNet,支持以HRNet作为backbone,提供基于Cityscapes的[预训练模型](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/docs/model_zoo.md#cityscapes%E9%A2%84%E8%AE%AD%E7%BB%83%E6%A8%A1%E5%9E%8B),mIoU超过80%。 + * 新增proposal free的实例分割模型[Spatial Embedding](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/contrib/SpatialEmbeddings),性能与精度均超越MaskRCNN。提供了基于kitti的预训练模型。 + +* 2020.05.12 + + **`v0.5.0`** + * 全面升级[HumanSeg人像分割模型](./contrib/HumanSeg),新增超轻量级人像分割模型HumanSeg-lite支持移动端实时人像分割处理,并提供基于光流的视频分割后处理提升分割流畅性。 + * 新增[气象遥感分割方案](./contrib/RemoteSensing),支持积雪识别、云检测等气象遥感场景。 + * 新增[Lovasz Loss](docs/lovasz_loss.md),解决数据类别不均衡问题。 + * 使用VisualDL 2.0作为训练可视化工具 + +* 2020.02.25 + + **`v0.4.0`** + * 新增适用于实时场景且不需要预训练模型的分割网络Fast-SCNN,提供基于Cityscapes的[预训练模型](./docs/model_zoo.md)1个 + * 新增LaneNet车道线检测网络,提供[预训练模型](https://github.com/PaddlePaddle/PaddleSeg/tree/release/v0.4.0/contrib/LaneNet#%E4%B8%83-%E5%8F%AF%E8%A7%86%E5%8C%96)一个 + * 新增基于PaddleSlim的分割库压缩策略([量化](./slim/quantization/README.md), [蒸馏](./slim/distillation/README.md), [剪枝](./slim/prune/README.md), [搜索](./slim/nas/README.md)) + + +* 2019.12.15 + + **`v0.3.0`** + * 新增HRNet分割网络,提供基于cityscapes和ImageNet的[预训练模型](./docs/model_zoo.md)8个 + * 支持使用[伪彩色标签](./docs/data_prepare.md#%E7%81%B0%E5%BA%A6%E6%A0%87%E6%B3%A8vs%E4%BC%AA%E5%BD%A9%E8%89%B2%E6%A0%87%E6%B3%A8)进行训练/评估/预测,提升训练体验,并提供将灰度标注图转为伪彩色标注图的脚本 + * 新增[学习率warmup](./docs/configs/solver_group.md#lr_warmup)功能,支持与不同的学习率Decay策略配合使用 + * 新增图像归一化操作的GPU化实现,进一步提升预测速度。 + * 新增Python部署方案,更低成本完成工业级部署。 + * 新增Paddle-Lite移动端部署方案,支持人像分割模型的移动端部署。 + * 新增不同分割模型的预测[性能数据Benchmark](./deploy/python/docs/PaddleSeg_Infer_Benchmark.md), 便于开发者提供模型选型性能参考。 + + +* 2019.11.04 + + **`v0.2.0`** + * 新增PSPNet分割网络,提供基于COCO和cityscapes数据集的[预训练模型](./docs/model_zoo.md)4个。 + * 新增Dice Loss、BCE Loss以及组合Loss配置,支持样本不均衡场景下的[模型优化](./docs/loss_select.md)。 + * 支持[FP16混合精度训练](./docs/multiple_gpus_train_and_mixed_precision_train.md)以及动态Loss Scaling,在不损耗精度的情况下,训练速度提升30%+。 + * 支持[PaddlePaddle多卡多进程训练](./docs/multiple_gpus_train_and_mixed_precision_train.md),多卡训练时训练速度提升15%+。 + * 发布基于UNet的[工业标记表盘分割模型](./contrib#%E5%B7%A5%E4%B8%9A%E7%94%A8%E8%A1%A8%E5%88%86%E5%89%B2)。 + +* 2019.09.10 + + **`v0.1.0`** + * PaddleSeg分割库初始版本发布,包含DeepLabv3+, U-Net, ICNet三类分割模型, 其中DeepLabv3+支持Xception, MobileNet v2两种可调节的骨干网络。 + * CVPR19 LIP人体部件分割比赛冠军预测模型发布[ACE2P](./contrib/ACE2P)。 + * 预置基于DeepLabv3+网络的[人像分割](./contrib/HumanSeg/)和[车道线分割](./contrib/RoadLine)预测模型发布。 + +
+ +## 贡献代码 + +我们非常欢迎您为PaddleSeg贡献代码或者提供使用建议。如果您可以修复某个issue或者增加一个新功能,欢迎给我们提交Pull Requests. diff --git a/configs/cityscape_fast_scnn.yaml b/legacy/configs/cityscape_fast_scnn.yaml similarity index 100% rename from configs/cityscape_fast_scnn.yaml rename to legacy/configs/cityscape_fast_scnn.yaml diff --git a/configs/deepglobe_road_extraction.yaml b/legacy/configs/deepglobe_road_extraction.yaml similarity index 100% rename from configs/deepglobe_road_extraction.yaml rename to legacy/configs/deepglobe_road_extraction.yaml diff --git a/configs/deeplabv3p_mobilenet-1-0_pet.yaml b/legacy/configs/deeplabv3p_mobilenet-1-0_pet.yaml similarity index 100% rename from configs/deeplabv3p_mobilenet-1-0_pet.yaml rename to legacy/configs/deeplabv3p_mobilenet-1-0_pet.yaml diff --git a/configs/deeplabv3p_mobilenetv2_cityscapes.yaml b/legacy/configs/deeplabv3p_mobilenetv2_cityscapes.yaml similarity index 100% rename from configs/deeplabv3p_mobilenetv2_cityscapes.yaml rename to legacy/configs/deeplabv3p_mobilenetv2_cityscapes.yaml diff --git a/configs/deeplabv3p_mobilenetv3_large_cityscapes.yaml b/legacy/configs/deeplabv3p_mobilenetv3_large_cityscapes.yaml similarity index 100% rename from configs/deeplabv3p_mobilenetv3_large_cityscapes.yaml rename to legacy/configs/deeplabv3p_mobilenetv3_large_cityscapes.yaml diff --git a/configs/deeplabv3p_resnet50_vd_cityscapes.yaml b/legacy/configs/deeplabv3p_resnet50_vd_cityscapes.yaml similarity index 100% rename from configs/deeplabv3p_resnet50_vd_cityscapes.yaml rename to legacy/configs/deeplabv3p_resnet50_vd_cityscapes.yaml diff --git a/configs/deeplabv3p_xception65_cityscapes.yaml b/legacy/configs/deeplabv3p_xception65_cityscapes.yaml similarity index 100% rename from configs/deeplabv3p_xception65_cityscapes.yaml rename to legacy/configs/deeplabv3p_xception65_cityscapes.yaml diff --git a/configs/deeplabv3p_xception65_optic.yaml b/legacy/configs/deeplabv3p_xception65_optic.yaml similarity index 100% rename from configs/deeplabv3p_xception65_optic.yaml rename to legacy/configs/deeplabv3p_xception65_optic.yaml diff --git a/configs/fast_scnn_pet.yaml b/legacy/configs/fast_scnn_pet.yaml similarity index 100% rename from configs/fast_scnn_pet.yaml rename to legacy/configs/fast_scnn_pet.yaml diff --git a/configs/hrnet_optic.yaml b/legacy/configs/hrnet_optic.yaml similarity index 100% rename from configs/hrnet_optic.yaml rename to legacy/configs/hrnet_optic.yaml diff --git a/configs/icnet_optic.yaml b/legacy/configs/icnet_optic.yaml similarity index 100% rename from configs/icnet_optic.yaml rename to legacy/configs/icnet_optic.yaml diff --git a/configs/lovasz_hinge_deeplabv3p_mobilenet_road.yaml b/legacy/configs/lovasz_hinge_deeplabv3p_mobilenet_road.yaml similarity index 100% rename from configs/lovasz_hinge_deeplabv3p_mobilenet_road.yaml rename to legacy/configs/lovasz_hinge_deeplabv3p_mobilenet_road.yaml diff --git a/configs/lovasz_softmax_deeplabv3p_mobilenet_pascal.yaml b/legacy/configs/lovasz_softmax_deeplabv3p_mobilenet_pascal.yaml similarity index 100% rename from configs/lovasz_softmax_deeplabv3p_mobilenet_pascal.yaml rename to legacy/configs/lovasz_softmax_deeplabv3p_mobilenet_pascal.yaml diff --git a/configs/ocrnet_w18_bn_cityscapes.yaml b/legacy/configs/ocrnet_w18_bn_cityscapes.yaml similarity index 100% rename from configs/ocrnet_w18_bn_cityscapes.yaml rename to legacy/configs/ocrnet_w18_bn_cityscapes.yaml diff --git a/configs/pspnet_optic.yaml b/legacy/configs/pspnet_optic.yaml similarity index 100% rename from configs/pspnet_optic.yaml rename to legacy/configs/pspnet_optic.yaml diff --git a/configs/unet_optic.yaml b/legacy/configs/unet_optic.yaml similarity index 100% rename from configs/unet_optic.yaml rename to legacy/configs/unet_optic.yaml diff --git a/contrib/ACE2P/README.md b/legacy/contrib/ACE2P/README.md similarity index 100% rename from contrib/ACE2P/README.md rename to legacy/contrib/ACE2P/README.md diff --git a/contrib/ACE2P/__init__.py b/legacy/contrib/ACE2P/__init__.py similarity index 100% rename from contrib/ACE2P/__init__.py rename to legacy/contrib/ACE2P/__init__.py diff --git a/contrib/ACE2P/config.py b/legacy/contrib/ACE2P/config.py similarity index 100% rename from contrib/ACE2P/config.py rename to legacy/contrib/ACE2P/config.py diff --git a/contrib/ACE2P/download_ACE2P.py b/legacy/contrib/ACE2P/download_ACE2P.py similarity index 100% rename from contrib/ACE2P/download_ACE2P.py rename to legacy/contrib/ACE2P/download_ACE2P.py diff --git a/contrib/ACE2P/imgs/117676_2149260.jpg b/legacy/contrib/ACE2P/imgs/117676_2149260.jpg similarity index 100% rename from contrib/ACE2P/imgs/117676_2149260.jpg rename to legacy/contrib/ACE2P/imgs/117676_2149260.jpg diff --git a/contrib/ACE2P/imgs/117676_2149260.png b/legacy/contrib/ACE2P/imgs/117676_2149260.png similarity index 100% rename from contrib/ACE2P/imgs/117676_2149260.png rename to legacy/contrib/ACE2P/imgs/117676_2149260.png diff --git a/contrib/ACE2P/imgs/net.jpg b/legacy/contrib/ACE2P/imgs/net.jpg similarity index 100% rename from contrib/ACE2P/imgs/net.jpg rename to legacy/contrib/ACE2P/imgs/net.jpg diff --git a/contrib/ACE2P/imgs/result.jpg b/legacy/contrib/ACE2P/imgs/result.jpg similarity index 100% rename from contrib/ACE2P/imgs/result.jpg rename to legacy/contrib/ACE2P/imgs/result.jpg diff --git a/contrib/ACE2P/infer.py b/legacy/contrib/ACE2P/infer.py similarity index 100% rename from contrib/ACE2P/infer.py rename to legacy/contrib/ACE2P/infer.py diff --git a/contrib/ACE2P/reader.py b/legacy/contrib/ACE2P/reader.py similarity index 100% rename from contrib/ACE2P/reader.py rename to legacy/contrib/ACE2P/reader.py diff --git a/contrib/ACE2P/utils/__init__.py b/legacy/contrib/ACE2P/utils/__init__.py similarity index 100% rename from contrib/ACE2P/utils/__init__.py rename to legacy/contrib/ACE2P/utils/__init__.py diff --git a/contrib/ACE2P/utils/palette.py b/legacy/contrib/ACE2P/utils/palette.py similarity index 100% rename from contrib/ACE2P/utils/palette.py rename to legacy/contrib/ACE2P/utils/palette.py diff --git a/contrib/ACE2P/utils/util.py b/legacy/contrib/ACE2P/utils/util.py similarity index 100% rename from contrib/ACE2P/utils/util.py rename to legacy/contrib/ACE2P/utils/util.py diff --git a/contrib/HumanSeg/README.md b/legacy/contrib/HumanSeg/README.md similarity index 100% rename from contrib/HumanSeg/README.md rename to legacy/contrib/HumanSeg/README.md diff --git a/contrib/HumanSeg/bg_replace.py b/legacy/contrib/HumanSeg/bg_replace.py similarity index 100% rename from contrib/HumanSeg/bg_replace.py rename to legacy/contrib/HumanSeg/bg_replace.py diff --git a/contrib/HumanSeg/data/background.jpg b/legacy/contrib/HumanSeg/data/background.jpg similarity index 100% rename from contrib/HumanSeg/data/background.jpg rename to legacy/contrib/HumanSeg/data/background.jpg diff --git a/contrib/HumanSeg/data/download_data.py b/legacy/contrib/HumanSeg/data/download_data.py similarity index 100% rename from contrib/HumanSeg/data/download_data.py rename to legacy/contrib/HumanSeg/data/download_data.py diff --git a/contrib/HumanSeg/data/human_image.jpg b/legacy/contrib/HumanSeg/data/human_image.jpg similarity index 100% rename from contrib/HumanSeg/data/human_image.jpg rename to legacy/contrib/HumanSeg/data/human_image.jpg diff --git a/contrib/HumanSeg/datasets/__init__.py b/legacy/contrib/HumanSeg/datasets/__init__.py similarity index 100% rename from contrib/HumanSeg/datasets/__init__.py rename to legacy/contrib/HumanSeg/datasets/__init__.py diff --git a/contrib/HumanSeg/datasets/dataset.py b/legacy/contrib/HumanSeg/datasets/dataset.py similarity index 100% rename from contrib/HumanSeg/datasets/dataset.py rename to legacy/contrib/HumanSeg/datasets/dataset.py diff --git a/contrib/HumanSeg/datasets/shared_queue/__init__.py b/legacy/contrib/HumanSeg/datasets/shared_queue/__init__.py similarity index 100% rename from contrib/HumanSeg/datasets/shared_queue/__init__.py rename to legacy/contrib/HumanSeg/datasets/shared_queue/__init__.py diff --git a/contrib/HumanSeg/datasets/shared_queue/queue.py b/legacy/contrib/HumanSeg/datasets/shared_queue/queue.py similarity index 100% rename from contrib/HumanSeg/datasets/shared_queue/queue.py rename to legacy/contrib/HumanSeg/datasets/shared_queue/queue.py diff --git a/contrib/HumanSeg/datasets/shared_queue/sharedmemory.py b/legacy/contrib/HumanSeg/datasets/shared_queue/sharedmemory.py similarity index 100% rename from contrib/HumanSeg/datasets/shared_queue/sharedmemory.py rename to legacy/contrib/HumanSeg/datasets/shared_queue/sharedmemory.py diff --git a/contrib/HumanSeg/export.py b/legacy/contrib/HumanSeg/export.py similarity index 100% rename from contrib/HumanSeg/export.py rename to legacy/contrib/HumanSeg/export.py diff --git a/contrib/HumanSeg/infer.py b/legacy/contrib/HumanSeg/infer.py similarity index 100% rename from contrib/HumanSeg/infer.py rename to legacy/contrib/HumanSeg/infer.py diff --git a/contrib/HumanSeg/models/__init__.py b/legacy/contrib/HumanSeg/models/__init__.py similarity index 100% rename from contrib/HumanSeg/models/__init__.py rename to legacy/contrib/HumanSeg/models/__init__.py diff --git a/contrib/HumanSeg/models/humanseg.py b/legacy/contrib/HumanSeg/models/humanseg.py similarity index 100% rename from contrib/HumanSeg/models/humanseg.py rename to legacy/contrib/HumanSeg/models/humanseg.py diff --git a/contrib/HumanSeg/models/load_model.py b/legacy/contrib/HumanSeg/models/load_model.py similarity index 100% rename from contrib/HumanSeg/models/load_model.py rename to legacy/contrib/HumanSeg/models/load_model.py diff --git a/contrib/HumanSeg/nets/__init__.py b/legacy/contrib/HumanSeg/nets/__init__.py similarity index 100% rename from contrib/HumanSeg/nets/__init__.py rename to legacy/contrib/HumanSeg/nets/__init__.py diff --git a/contrib/HumanSeg/nets/backbone/__init__.py b/legacy/contrib/HumanSeg/nets/backbone/__init__.py similarity index 100% rename from contrib/HumanSeg/nets/backbone/__init__.py rename to legacy/contrib/HumanSeg/nets/backbone/__init__.py diff --git a/contrib/HumanSeg/nets/backbone/mobilenet_v2.py b/legacy/contrib/HumanSeg/nets/backbone/mobilenet_v2.py similarity index 100% rename from contrib/HumanSeg/nets/backbone/mobilenet_v2.py rename to legacy/contrib/HumanSeg/nets/backbone/mobilenet_v2.py diff --git a/contrib/HumanSeg/nets/backbone/xception.py b/legacy/contrib/HumanSeg/nets/backbone/xception.py similarity index 100% rename from contrib/HumanSeg/nets/backbone/xception.py rename to legacy/contrib/HumanSeg/nets/backbone/xception.py diff --git a/contrib/HumanSeg/nets/deeplabv3p.py b/legacy/contrib/HumanSeg/nets/deeplabv3p.py similarity index 100% rename from contrib/HumanSeg/nets/deeplabv3p.py rename to legacy/contrib/HumanSeg/nets/deeplabv3p.py diff --git a/contrib/HumanSeg/nets/hrnet.py b/legacy/contrib/HumanSeg/nets/hrnet.py similarity index 100% rename from contrib/HumanSeg/nets/hrnet.py rename to legacy/contrib/HumanSeg/nets/hrnet.py diff --git a/contrib/HumanSeg/nets/libs.py b/legacy/contrib/HumanSeg/nets/libs.py similarity index 100% rename from contrib/HumanSeg/nets/libs.py rename to legacy/contrib/HumanSeg/nets/libs.py diff --git a/contrib/HumanSeg/nets/seg_modules.py b/legacy/contrib/HumanSeg/nets/seg_modules.py similarity index 100% rename from contrib/HumanSeg/nets/seg_modules.py rename to legacy/contrib/HumanSeg/nets/seg_modules.py diff --git a/contrib/HumanSeg/nets/shufflenet_slim.py b/legacy/contrib/HumanSeg/nets/shufflenet_slim.py similarity index 100% rename from contrib/HumanSeg/nets/shufflenet_slim.py rename to legacy/contrib/HumanSeg/nets/shufflenet_slim.py diff --git a/contrib/HumanSeg/pretrained_weights/download_pretrained_weights.py b/legacy/contrib/HumanSeg/pretrained_weights/download_pretrained_weights.py similarity index 100% rename from contrib/HumanSeg/pretrained_weights/download_pretrained_weights.py rename to legacy/contrib/HumanSeg/pretrained_weights/download_pretrained_weights.py diff --git a/contrib/HumanSeg/quant_offline.py b/legacy/contrib/HumanSeg/quant_offline.py similarity index 100% rename from contrib/HumanSeg/quant_offline.py rename to legacy/contrib/HumanSeg/quant_offline.py diff --git a/contrib/HumanSeg/quant_online.py b/legacy/contrib/HumanSeg/quant_online.py similarity index 100% rename from contrib/HumanSeg/quant_online.py rename to legacy/contrib/HumanSeg/quant_online.py diff --git a/contrib/HumanSeg/requirements.txt b/legacy/contrib/HumanSeg/requirements.txt similarity index 100% rename from contrib/HumanSeg/requirements.txt rename to legacy/contrib/HumanSeg/requirements.txt diff --git a/contrib/HumanSeg/train.py b/legacy/contrib/HumanSeg/train.py similarity index 100% rename from contrib/HumanSeg/train.py rename to legacy/contrib/HumanSeg/train.py diff --git a/contrib/HumanSeg/transforms/__init__.py b/legacy/contrib/HumanSeg/transforms/__init__.py similarity index 100% rename from contrib/HumanSeg/transforms/__init__.py rename to legacy/contrib/HumanSeg/transforms/__init__.py diff --git a/contrib/HumanSeg/transforms/functional.py b/legacy/contrib/HumanSeg/transforms/functional.py similarity index 100% rename from contrib/HumanSeg/transforms/functional.py rename to legacy/contrib/HumanSeg/transforms/functional.py diff --git a/contrib/HumanSeg/transforms/transforms.py b/legacy/contrib/HumanSeg/transforms/transforms.py similarity index 100% rename from contrib/HumanSeg/transforms/transforms.py rename to legacy/contrib/HumanSeg/transforms/transforms.py diff --git a/contrib/HumanSeg/utils/__init__.py b/legacy/contrib/HumanSeg/utils/__init__.py similarity index 100% rename from contrib/HumanSeg/utils/__init__.py rename to legacy/contrib/HumanSeg/utils/__init__.py diff --git a/contrib/HumanSeg/utils/humanseg_postprocess.py b/legacy/contrib/HumanSeg/utils/humanseg_postprocess.py similarity index 100% rename from contrib/HumanSeg/utils/humanseg_postprocess.py rename to legacy/contrib/HumanSeg/utils/humanseg_postprocess.py diff --git a/contrib/HumanSeg/utils/logging.py b/legacy/contrib/HumanSeg/utils/logging.py similarity index 100% rename from contrib/HumanSeg/utils/logging.py rename to legacy/contrib/HumanSeg/utils/logging.py diff --git a/contrib/HumanSeg/utils/metrics.py b/legacy/contrib/HumanSeg/utils/metrics.py similarity index 100% rename from contrib/HumanSeg/utils/metrics.py rename to legacy/contrib/HumanSeg/utils/metrics.py diff --git a/contrib/HumanSeg/utils/post_quantization.py b/legacy/contrib/HumanSeg/utils/post_quantization.py similarity index 100% rename from contrib/HumanSeg/utils/post_quantization.py rename to legacy/contrib/HumanSeg/utils/post_quantization.py diff --git a/contrib/HumanSeg/utils/utils.py b/legacy/contrib/HumanSeg/utils/utils.py similarity index 100% rename from contrib/HumanSeg/utils/utils.py rename to legacy/contrib/HumanSeg/utils/utils.py diff --git a/contrib/HumanSeg/val.py b/legacy/contrib/HumanSeg/val.py similarity index 100% rename from contrib/HumanSeg/val.py rename to legacy/contrib/HumanSeg/val.py diff --git a/contrib/HumanSeg/video_infer.py b/legacy/contrib/HumanSeg/video_infer.py similarity index 100% rename from contrib/HumanSeg/video_infer.py rename to legacy/contrib/HumanSeg/video_infer.py diff --git a/contrib/LaneNet/README.md b/legacy/contrib/LaneNet/README.md similarity index 100% rename from contrib/LaneNet/README.md rename to legacy/contrib/LaneNet/README.md diff --git a/contrib/LaneNet/configs/lanenet.yaml b/legacy/contrib/LaneNet/configs/lanenet.yaml similarity index 100% rename from contrib/LaneNet/configs/lanenet.yaml rename to legacy/contrib/LaneNet/configs/lanenet.yaml diff --git a/contrib/LaneNet/data_aug.py b/legacy/contrib/LaneNet/data_aug.py similarity index 100% rename from contrib/LaneNet/data_aug.py rename to legacy/contrib/LaneNet/data_aug.py diff --git a/contrib/LaneNet/dataset/download_tusimple.py b/legacy/contrib/LaneNet/dataset/download_tusimple.py similarity index 100% rename from contrib/LaneNet/dataset/download_tusimple.py rename to legacy/contrib/LaneNet/dataset/download_tusimple.py diff --git a/contrib/LaneNet/eval.py b/legacy/contrib/LaneNet/eval.py similarity index 100% rename from contrib/LaneNet/eval.py rename to legacy/contrib/LaneNet/eval.py diff --git a/contrib/LaneNet/imgs/0005_pred_binary.png b/legacy/contrib/LaneNet/imgs/0005_pred_binary.png similarity index 100% rename from contrib/LaneNet/imgs/0005_pred_binary.png rename to legacy/contrib/LaneNet/imgs/0005_pred_binary.png diff --git a/contrib/LaneNet/imgs/0005_pred_instance.png b/legacy/contrib/LaneNet/imgs/0005_pred_instance.png similarity index 100% rename from contrib/LaneNet/imgs/0005_pred_instance.png rename to legacy/contrib/LaneNet/imgs/0005_pred_instance.png diff --git a/contrib/LaneNet/imgs/0005_pred_lane.png b/legacy/contrib/LaneNet/imgs/0005_pred_lane.png similarity index 100% rename from contrib/LaneNet/imgs/0005_pred_lane.png rename to legacy/contrib/LaneNet/imgs/0005_pred_lane.png diff --git a/contrib/LaneNet/loss.py b/legacy/contrib/LaneNet/loss.py similarity index 100% rename from contrib/LaneNet/loss.py rename to legacy/contrib/LaneNet/loss.py diff --git a/contrib/LaneNet/models/__init__.py b/legacy/contrib/LaneNet/models/__init__.py similarity index 100% rename from contrib/LaneNet/models/__init__.py rename to legacy/contrib/LaneNet/models/__init__.py diff --git a/contrib/LaneNet/models/model_builder.py b/legacy/contrib/LaneNet/models/model_builder.py similarity index 100% rename from contrib/LaneNet/models/model_builder.py rename to legacy/contrib/LaneNet/models/model_builder.py diff --git a/contrib/LaneNet/models/modeling/__init__.py b/legacy/contrib/LaneNet/models/modeling/__init__.py similarity index 100% rename from contrib/LaneNet/models/modeling/__init__.py rename to legacy/contrib/LaneNet/models/modeling/__init__.py diff --git a/contrib/LaneNet/models/modeling/lanenet.py b/legacy/contrib/LaneNet/models/modeling/lanenet.py similarity index 100% rename from contrib/LaneNet/models/modeling/lanenet.py rename to legacy/contrib/LaneNet/models/modeling/lanenet.py diff --git a/contrib/LaneNet/reader.py b/legacy/contrib/LaneNet/reader.py similarity index 100% rename from contrib/LaneNet/reader.py rename to legacy/contrib/LaneNet/reader.py diff --git a/contrib/LaneNet/requirements.txt b/legacy/contrib/LaneNet/requirements.txt similarity index 100% rename from contrib/LaneNet/requirements.txt rename to legacy/contrib/LaneNet/requirements.txt diff --git a/contrib/LaneNet/train.py b/legacy/contrib/LaneNet/train.py similarity index 100% rename from contrib/LaneNet/train.py rename to legacy/contrib/LaneNet/train.py diff --git a/contrib/LaneNet/utils/__init__.py b/legacy/contrib/LaneNet/utils/__init__.py similarity index 100% rename from contrib/LaneNet/utils/__init__.py rename to legacy/contrib/LaneNet/utils/__init__.py diff --git a/contrib/LaneNet/utils/config.py b/legacy/contrib/LaneNet/utils/config.py similarity index 100% rename from contrib/LaneNet/utils/config.py rename to legacy/contrib/LaneNet/utils/config.py diff --git a/contrib/LaneNet/utils/dist_utils.py b/legacy/contrib/LaneNet/utils/dist_utils.py similarity index 100% rename from contrib/LaneNet/utils/dist_utils.py rename to legacy/contrib/LaneNet/utils/dist_utils.py diff --git a/contrib/LaneNet/utils/generate_tusimple_dataset.py b/legacy/contrib/LaneNet/utils/generate_tusimple_dataset.py similarity index 100% rename from contrib/LaneNet/utils/generate_tusimple_dataset.py rename to legacy/contrib/LaneNet/utils/generate_tusimple_dataset.py diff --git a/contrib/LaneNet/utils/lanenet_postprocess.py b/legacy/contrib/LaneNet/utils/lanenet_postprocess.py similarity index 100% rename from contrib/LaneNet/utils/lanenet_postprocess.py rename to legacy/contrib/LaneNet/utils/lanenet_postprocess.py diff --git a/contrib/LaneNet/utils/load_model_utils.py b/legacy/contrib/LaneNet/utils/load_model_utils.py similarity index 100% rename from contrib/LaneNet/utils/load_model_utils.py rename to legacy/contrib/LaneNet/utils/load_model_utils.py diff --git a/contrib/LaneNet/vis.py b/legacy/contrib/LaneNet/vis.py similarity index 100% rename from contrib/LaneNet/vis.py rename to legacy/contrib/LaneNet/vis.py diff --git a/contrib/MechanicalIndustryMeter/download_mini_mechanical_industry_meter.py b/legacy/contrib/MechanicalIndustryMeter/download_mini_mechanical_industry_meter.py similarity index 100% rename from contrib/MechanicalIndustryMeter/download_mini_mechanical_industry_meter.py rename to legacy/contrib/MechanicalIndustryMeter/download_mini_mechanical_industry_meter.py diff --git a/contrib/MechanicalIndustryMeter/download_unet_mechanical_industry_meter.py b/legacy/contrib/MechanicalIndustryMeter/download_unet_mechanical_industry_meter.py similarity index 100% rename from contrib/MechanicalIndustryMeter/download_unet_mechanical_industry_meter.py rename to legacy/contrib/MechanicalIndustryMeter/download_unet_mechanical_industry_meter.py diff --git a/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.JPG b/legacy/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.JPG similarity index 100% rename from contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.JPG rename to legacy/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.JPG diff --git a/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.png b/legacy/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.png similarity index 100% rename from contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.png rename to legacy/contrib/MechanicalIndustryMeter/imgs/1560143028.5_IMG_3091.png diff --git a/contrib/MechanicalIndustryMeter/unet_mechanical_meter.yaml b/legacy/contrib/MechanicalIndustryMeter/unet_mechanical_meter.yaml similarity index 100% rename from contrib/MechanicalIndustryMeter/unet_mechanical_meter.yaml rename to legacy/contrib/MechanicalIndustryMeter/unet_mechanical_meter.yaml diff --git a/contrib/README.md b/legacy/contrib/README.md similarity index 100% rename from contrib/README.md rename to legacy/contrib/README.md diff --git a/contrib/RemoteSensing/README.md b/legacy/contrib/RemoteSensing/README.md similarity index 100% rename from contrib/RemoteSensing/README.md rename to legacy/contrib/RemoteSensing/README.md diff --git a/contrib/RemoteSensing/__init__.py b/legacy/contrib/RemoteSensing/__init__.py similarity index 100% rename from contrib/RemoteSensing/__init__.py rename to legacy/contrib/RemoteSensing/__init__.py diff --git a/contrib/RemoteSensing/docs/data_analyse_and_check.md b/legacy/contrib/RemoteSensing/docs/data_analyse_and_check.md similarity index 100% rename from contrib/RemoteSensing/docs/data_analyse_and_check.md rename to legacy/contrib/RemoteSensing/docs/data_analyse_and_check.md diff --git a/contrib/RemoteSensing/docs/data_prepare.md b/legacy/contrib/RemoteSensing/docs/data_prepare.md similarity index 100% rename from contrib/RemoteSensing/docs/data_prepare.md rename to legacy/contrib/RemoteSensing/docs/data_prepare.md diff --git a/contrib/RemoteSensing/docs/imgs/data_distribution.png b/legacy/contrib/RemoteSensing/docs/imgs/data_distribution.png similarity index 100% rename from contrib/RemoteSensing/docs/imgs/data_distribution.png rename to legacy/contrib/RemoteSensing/docs/imgs/data_distribution.png diff --git a/contrib/RemoteSensing/docs/imgs/dataset.png b/legacy/contrib/RemoteSensing/docs/imgs/dataset.png similarity index 100% rename from contrib/RemoteSensing/docs/imgs/dataset.png rename to legacy/contrib/RemoteSensing/docs/imgs/dataset.png diff --git a/contrib/RemoteSensing/docs/imgs/vis.png b/legacy/contrib/RemoteSensing/docs/imgs/vis.png similarity index 100% rename from contrib/RemoteSensing/docs/imgs/vis.png rename to legacy/contrib/RemoteSensing/docs/imgs/vis.png diff --git a/contrib/RemoteSensing/docs/imgs/visualdl.png b/legacy/contrib/RemoteSensing/docs/imgs/visualdl.png similarity index 100% rename from contrib/RemoteSensing/docs/imgs/visualdl.png rename to legacy/contrib/RemoteSensing/docs/imgs/visualdl.png diff --git a/contrib/RemoteSensing/docs/transforms.md b/legacy/contrib/RemoteSensing/docs/transforms.md similarity index 100% rename from contrib/RemoteSensing/docs/transforms.md rename to legacy/contrib/RemoteSensing/docs/transforms.md diff --git a/contrib/RemoteSensing/models/__init__.py b/legacy/contrib/RemoteSensing/models/__init__.py similarity index 100% rename from contrib/RemoteSensing/models/__init__.py rename to legacy/contrib/RemoteSensing/models/__init__.py diff --git a/contrib/RemoteSensing/models/base.py b/legacy/contrib/RemoteSensing/models/base.py similarity index 100% rename from contrib/RemoteSensing/models/base.py rename to legacy/contrib/RemoteSensing/models/base.py diff --git a/contrib/RemoteSensing/models/hrnet.py b/legacy/contrib/RemoteSensing/models/hrnet.py similarity index 100% rename from contrib/RemoteSensing/models/hrnet.py rename to legacy/contrib/RemoteSensing/models/hrnet.py diff --git a/contrib/RemoteSensing/models/load_model.py b/legacy/contrib/RemoteSensing/models/load_model.py similarity index 100% rename from contrib/RemoteSensing/models/load_model.py rename to legacy/contrib/RemoteSensing/models/load_model.py diff --git a/contrib/RemoteSensing/models/unet.py b/legacy/contrib/RemoteSensing/models/unet.py similarity index 100% rename from contrib/RemoteSensing/models/unet.py rename to legacy/contrib/RemoteSensing/models/unet.py diff --git a/contrib/RemoteSensing/models/utils/visualize.py b/legacy/contrib/RemoteSensing/models/utils/visualize.py similarity index 100% rename from contrib/RemoteSensing/models/utils/visualize.py rename to legacy/contrib/RemoteSensing/models/utils/visualize.py diff --git a/contrib/RemoteSensing/nets/__init__.py b/legacy/contrib/RemoteSensing/nets/__init__.py similarity index 100% rename from contrib/RemoteSensing/nets/__init__.py rename to legacy/contrib/RemoteSensing/nets/__init__.py diff --git a/contrib/RemoteSensing/nets/hrnet.py b/legacy/contrib/RemoteSensing/nets/hrnet.py similarity index 100% rename from contrib/RemoteSensing/nets/hrnet.py rename to legacy/contrib/RemoteSensing/nets/hrnet.py diff --git a/contrib/RemoteSensing/nets/libs.py b/legacy/contrib/RemoteSensing/nets/libs.py similarity index 100% rename from contrib/RemoteSensing/nets/libs.py rename to legacy/contrib/RemoteSensing/nets/libs.py diff --git a/contrib/RemoteSensing/nets/loss.py b/legacy/contrib/RemoteSensing/nets/loss.py similarity index 100% rename from contrib/RemoteSensing/nets/loss.py rename to legacy/contrib/RemoteSensing/nets/loss.py diff --git a/contrib/RemoteSensing/nets/unet.py b/legacy/contrib/RemoteSensing/nets/unet.py similarity index 100% rename from contrib/RemoteSensing/nets/unet.py rename to legacy/contrib/RemoteSensing/nets/unet.py diff --git a/contrib/RemoteSensing/predict_demo.py b/legacy/contrib/RemoteSensing/predict_demo.py similarity index 100% rename from contrib/RemoteSensing/predict_demo.py rename to legacy/contrib/RemoteSensing/predict_demo.py diff --git a/contrib/RemoteSensing/readers/__init__.py b/legacy/contrib/RemoteSensing/readers/__init__.py similarity index 100% rename from contrib/RemoteSensing/readers/__init__.py rename to legacy/contrib/RemoteSensing/readers/__init__.py diff --git a/contrib/RemoteSensing/readers/base.py b/legacy/contrib/RemoteSensing/readers/base.py similarity index 100% rename from contrib/RemoteSensing/readers/base.py rename to legacy/contrib/RemoteSensing/readers/base.py diff --git a/contrib/RemoteSensing/readers/reader.py b/legacy/contrib/RemoteSensing/readers/reader.py similarity index 100% rename from contrib/RemoteSensing/readers/reader.py rename to legacy/contrib/RemoteSensing/readers/reader.py diff --git a/contrib/RemoteSensing/requirements.txt b/legacy/contrib/RemoteSensing/requirements.txt similarity index 100% rename from contrib/RemoteSensing/requirements.txt rename to legacy/contrib/RemoteSensing/requirements.txt diff --git a/contrib/RemoteSensing/tools/cal_norm_coef.py b/legacy/contrib/RemoteSensing/tools/cal_norm_coef.py similarity index 100% rename from contrib/RemoteSensing/tools/cal_norm_coef.py rename to legacy/contrib/RemoteSensing/tools/cal_norm_coef.py diff --git a/contrib/RemoteSensing/tools/create_dataset_list.py b/legacy/contrib/RemoteSensing/tools/create_dataset_list.py similarity index 100% rename from contrib/RemoteSensing/tools/create_dataset_list.py rename to legacy/contrib/RemoteSensing/tools/create_dataset_list.py diff --git a/contrib/RemoteSensing/tools/data_analyse_and_check.py b/legacy/contrib/RemoteSensing/tools/data_analyse_and_check.py similarity index 100% rename from contrib/RemoteSensing/tools/data_analyse_and_check.py rename to legacy/contrib/RemoteSensing/tools/data_analyse_and_check.py diff --git a/contrib/RemoteSensing/tools/data_distribution_vis.py b/legacy/contrib/RemoteSensing/tools/data_distribution_vis.py similarity index 100% rename from contrib/RemoteSensing/tools/data_distribution_vis.py rename to legacy/contrib/RemoteSensing/tools/data_distribution_vis.py diff --git a/contrib/RemoteSensing/tools/split_dataset_list.py b/legacy/contrib/RemoteSensing/tools/split_dataset_list.py similarity index 100% rename from contrib/RemoteSensing/tools/split_dataset_list.py rename to legacy/contrib/RemoteSensing/tools/split_dataset_list.py diff --git a/contrib/RemoteSensing/train_demo.py b/legacy/contrib/RemoteSensing/train_demo.py similarity index 100% rename from contrib/RemoteSensing/train_demo.py rename to legacy/contrib/RemoteSensing/train_demo.py diff --git a/contrib/RemoteSensing/transforms/__init__.py b/legacy/contrib/RemoteSensing/transforms/__init__.py similarity index 100% rename from contrib/RemoteSensing/transforms/__init__.py rename to legacy/contrib/RemoteSensing/transforms/__init__.py diff --git a/contrib/RemoteSensing/transforms/ops.py b/legacy/contrib/RemoteSensing/transforms/ops.py similarity index 100% rename from contrib/RemoteSensing/transforms/ops.py rename to legacy/contrib/RemoteSensing/transforms/ops.py diff --git a/contrib/RemoteSensing/transforms/transforms.py b/legacy/contrib/RemoteSensing/transforms/transforms.py similarity index 100% rename from contrib/RemoteSensing/transforms/transforms.py rename to legacy/contrib/RemoteSensing/transforms/transforms.py diff --git a/contrib/RemoteSensing/utils/__init__.py b/legacy/contrib/RemoteSensing/utils/__init__.py similarity index 100% rename from contrib/RemoteSensing/utils/__init__.py rename to legacy/contrib/RemoteSensing/utils/__init__.py diff --git a/contrib/RemoteSensing/utils/logging.py b/legacy/contrib/RemoteSensing/utils/logging.py similarity index 100% rename from contrib/RemoteSensing/utils/logging.py rename to legacy/contrib/RemoteSensing/utils/logging.py diff --git a/contrib/RemoteSensing/utils/metrics.py b/legacy/contrib/RemoteSensing/utils/metrics.py similarity index 100% rename from contrib/RemoteSensing/utils/metrics.py rename to legacy/contrib/RemoteSensing/utils/metrics.py diff --git a/contrib/RemoteSensing/utils/pretrain_weights.py b/legacy/contrib/RemoteSensing/utils/pretrain_weights.py similarity index 100% rename from contrib/RemoteSensing/utils/pretrain_weights.py rename to legacy/contrib/RemoteSensing/utils/pretrain_weights.py diff --git a/contrib/RemoteSensing/utils/utils.py b/legacy/contrib/RemoteSensing/utils/utils.py similarity index 100% rename from contrib/RemoteSensing/utils/utils.py rename to legacy/contrib/RemoteSensing/utils/utils.py diff --git a/contrib/RemoteSensing/visualize_demo.py b/legacy/contrib/RemoteSensing/visualize_demo.py similarity index 100% rename from contrib/RemoteSensing/visualize_demo.py rename to legacy/contrib/RemoteSensing/visualize_demo.py diff --git a/contrib/SpatialEmbeddings/README.md b/legacy/contrib/SpatialEmbeddings/README.md similarity index 100% rename from contrib/SpatialEmbeddings/README.md rename to legacy/contrib/SpatialEmbeddings/README.md diff --git a/contrib/SpatialEmbeddings/config.py b/legacy/contrib/SpatialEmbeddings/config.py similarity index 100% rename from contrib/SpatialEmbeddings/config.py rename to legacy/contrib/SpatialEmbeddings/config.py diff --git a/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000512.png b/legacy/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000512.png similarity index 100% rename from contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000512.png rename to legacy/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000512.png diff --git a/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000518.png b/legacy/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000518.png similarity index 100% rename from contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000518.png rename to legacy/contrib/SpatialEmbeddings/data/kitti/0007/kitti_0007_000518.png diff --git a/contrib/SpatialEmbeddings/data/test.txt b/legacy/contrib/SpatialEmbeddings/data/test.txt similarity index 100% rename from contrib/SpatialEmbeddings/data/test.txt rename to legacy/contrib/SpatialEmbeddings/data/test.txt diff --git a/contrib/SpatialEmbeddings/download_SpatialEmbeddings_kitti.py b/legacy/contrib/SpatialEmbeddings/download_SpatialEmbeddings_kitti.py similarity index 100% rename from contrib/SpatialEmbeddings/download_SpatialEmbeddings_kitti.py rename to legacy/contrib/SpatialEmbeddings/download_SpatialEmbeddings_kitti.py diff --git a/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_ori.png b/legacy/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_ori.png similarity index 100% rename from contrib/SpatialEmbeddings/imgs/kitti_0007_000518_ori.png rename to legacy/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_ori.png diff --git a/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_pred.png b/legacy/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_pred.png similarity index 100% rename from contrib/SpatialEmbeddings/imgs/kitti_0007_000518_pred.png rename to legacy/contrib/SpatialEmbeddings/imgs/kitti_0007_000518_pred.png diff --git a/contrib/SpatialEmbeddings/infer.py b/legacy/contrib/SpatialEmbeddings/infer.py similarity index 100% rename from contrib/SpatialEmbeddings/infer.py rename to legacy/contrib/SpatialEmbeddings/infer.py diff --git a/contrib/SpatialEmbeddings/models.py b/legacy/contrib/SpatialEmbeddings/models.py similarity index 100% rename from contrib/SpatialEmbeddings/models.py rename to legacy/contrib/SpatialEmbeddings/models.py diff --git a/contrib/SpatialEmbeddings/utils/__init__.py b/legacy/contrib/SpatialEmbeddings/utils/__init__.py similarity index 100% rename from contrib/SpatialEmbeddings/utils/__init__.py rename to legacy/contrib/SpatialEmbeddings/utils/__init__.py diff --git a/contrib/SpatialEmbeddings/utils/data_util.py b/legacy/contrib/SpatialEmbeddings/utils/data_util.py similarity index 100% rename from contrib/SpatialEmbeddings/utils/data_util.py rename to legacy/contrib/SpatialEmbeddings/utils/data_util.py diff --git a/contrib/SpatialEmbeddings/utils/palette.py b/legacy/contrib/SpatialEmbeddings/utils/palette.py similarity index 100% rename from contrib/SpatialEmbeddings/utils/palette.py rename to legacy/contrib/SpatialEmbeddings/utils/palette.py diff --git a/contrib/SpatialEmbeddings/utils/util.py b/legacy/contrib/SpatialEmbeddings/utils/util.py similarity index 100% rename from contrib/SpatialEmbeddings/utils/util.py rename to legacy/contrib/SpatialEmbeddings/utils/util.py diff --git a/dataset/README.md b/legacy/dataset/README.md similarity index 100% rename from dataset/README.md rename to legacy/dataset/README.md diff --git a/dataset/convert_voc2012.py b/legacy/dataset/convert_voc2012.py similarity index 100% rename from dataset/convert_voc2012.py rename to legacy/dataset/convert_voc2012.py diff --git a/dataset/download_and_convert_voc2012.py b/legacy/dataset/download_and_convert_voc2012.py similarity index 100% rename from dataset/download_and_convert_voc2012.py rename to legacy/dataset/download_and_convert_voc2012.py diff --git a/dataset/download_cityscapes.py b/legacy/dataset/download_cityscapes.py similarity index 100% rename from dataset/download_cityscapes.py rename to legacy/dataset/download_cityscapes.py diff --git a/dataset/download_mini_deepglobe_road_extraction.py b/legacy/dataset/download_mini_deepglobe_road_extraction.py similarity index 100% rename from dataset/download_mini_deepglobe_road_extraction.py rename to legacy/dataset/download_mini_deepglobe_road_extraction.py diff --git a/dataset/download_optic.py b/legacy/dataset/download_optic.py similarity index 100% rename from dataset/download_optic.py rename to legacy/dataset/download_optic.py diff --git a/dataset/download_pet.py b/legacy/dataset/download_pet.py similarity index 100% rename from dataset/download_pet.py rename to legacy/dataset/download_pet.py diff --git a/deploy/README.md b/legacy/deploy/README.md similarity index 100% rename from deploy/README.md rename to legacy/deploy/README.md diff --git a/deploy/cpp/CMakeLists.txt b/legacy/deploy/cpp/CMakeLists.txt similarity index 100% rename from deploy/cpp/CMakeLists.txt rename to legacy/deploy/cpp/CMakeLists.txt diff --git a/deploy/cpp/CMakeSettings.json b/legacy/deploy/cpp/CMakeSettings.json similarity index 100% rename from deploy/cpp/CMakeSettings.json rename to legacy/deploy/cpp/CMakeSettings.json diff --git a/deploy/cpp/INSTALL.md b/legacy/deploy/cpp/INSTALL.md similarity index 100% rename from deploy/cpp/INSTALL.md rename to legacy/deploy/cpp/INSTALL.md diff --git a/deploy/cpp/LICENSE b/legacy/deploy/cpp/LICENSE similarity index 100% rename from deploy/cpp/LICENSE rename to legacy/deploy/cpp/LICENSE diff --git a/deploy/cpp/README.md b/legacy/deploy/cpp/README.md similarity index 100% rename from deploy/cpp/README.md rename to legacy/deploy/cpp/README.md diff --git a/deploy/cpp/conf/humanseg.yaml b/legacy/deploy/cpp/conf/humanseg.yaml similarity index 100% rename from deploy/cpp/conf/humanseg.yaml rename to legacy/deploy/cpp/conf/humanseg.yaml diff --git a/deploy/cpp/demo.cpp b/legacy/deploy/cpp/demo.cpp similarity index 100% rename from deploy/cpp/demo.cpp rename to legacy/deploy/cpp/demo.cpp diff --git a/deploy/cpp/docs/demo.jpg b/legacy/deploy/cpp/docs/demo.jpg similarity index 100% rename from deploy/cpp/docs/demo.jpg rename to legacy/deploy/cpp/docs/demo.jpg diff --git a/deploy/cpp/docs/demo_jpg.png b/legacy/deploy/cpp/docs/demo_jpg.png similarity index 100% rename from deploy/cpp/docs/demo_jpg.png rename to legacy/deploy/cpp/docs/demo_jpg.png diff --git a/deploy/cpp/docs/linux_build.md b/legacy/deploy/cpp/docs/linux_build.md similarity index 100% rename from deploy/cpp/docs/linux_build.md rename to legacy/deploy/cpp/docs/linux_build.md diff --git a/deploy/cpp/docs/vis.md b/legacy/deploy/cpp/docs/vis.md similarity index 100% rename from deploy/cpp/docs/vis.md rename to legacy/deploy/cpp/docs/vis.md diff --git a/deploy/cpp/docs/vis_result.png b/legacy/deploy/cpp/docs/vis_result.png similarity index 100% rename from deploy/cpp/docs/vis_result.png rename to legacy/deploy/cpp/docs/vis_result.png diff --git a/deploy/cpp/docs/windows_vs2015_build.md b/legacy/deploy/cpp/docs/windows_vs2015_build.md similarity index 100% rename from deploy/cpp/docs/windows_vs2015_build.md rename to legacy/deploy/cpp/docs/windows_vs2015_build.md diff --git a/deploy/cpp/docs/windows_vs2019_build.md b/legacy/deploy/cpp/docs/windows_vs2019_build.md similarity index 100% rename from deploy/cpp/docs/windows_vs2019_build.md rename to legacy/deploy/cpp/docs/windows_vs2019_build.md diff --git a/deploy/cpp/external-cmake/yaml-cpp.cmake b/legacy/deploy/cpp/external-cmake/yaml-cpp.cmake similarity index 100% rename from deploy/cpp/external-cmake/yaml-cpp.cmake rename to legacy/deploy/cpp/external-cmake/yaml-cpp.cmake diff --git a/deploy/cpp/images/humanseg/demo1.jpeg b/legacy/deploy/cpp/images/humanseg/demo1.jpeg similarity index 100% rename from deploy/cpp/images/humanseg/demo1.jpeg rename to legacy/deploy/cpp/images/humanseg/demo1.jpeg diff --git a/deploy/cpp/images/humanseg/demo2.jpeg b/legacy/deploy/cpp/images/humanseg/demo2.jpeg similarity index 100% rename from deploy/cpp/images/humanseg/demo2.jpeg rename to legacy/deploy/cpp/images/humanseg/demo2.jpeg diff --git a/deploy/cpp/images/humanseg/demo2.jpeg_result.png b/legacy/deploy/cpp/images/humanseg/demo2.jpeg_result.png similarity index 100% rename from deploy/cpp/images/humanseg/demo2.jpeg_result.png rename to legacy/deploy/cpp/images/humanseg/demo2.jpeg_result.png diff --git a/deploy/cpp/images/humanseg/demo2_jpeg_recover.png b/legacy/deploy/cpp/images/humanseg/demo2_jpeg_recover.png similarity index 100% rename from deploy/cpp/images/humanseg/demo2_jpeg_recover.png rename to legacy/deploy/cpp/images/humanseg/demo2_jpeg_recover.png diff --git a/deploy/cpp/images/humanseg/demo3.jpeg b/legacy/deploy/cpp/images/humanseg/demo3.jpeg similarity index 100% rename from deploy/cpp/images/humanseg/demo3.jpeg rename to legacy/deploy/cpp/images/humanseg/demo3.jpeg diff --git a/deploy/cpp/predictor/seg_predictor.cpp b/legacy/deploy/cpp/predictor/seg_predictor.cpp similarity index 100% rename from deploy/cpp/predictor/seg_predictor.cpp rename to legacy/deploy/cpp/predictor/seg_predictor.cpp diff --git a/deploy/cpp/predictor/seg_predictor.h b/legacy/deploy/cpp/predictor/seg_predictor.h similarity index 100% rename from deploy/cpp/predictor/seg_predictor.h rename to legacy/deploy/cpp/predictor/seg_predictor.h diff --git a/deploy/cpp/preprocessor/preprocessor.cpp b/legacy/deploy/cpp/preprocessor/preprocessor.cpp similarity index 100% rename from deploy/cpp/preprocessor/preprocessor.cpp rename to legacy/deploy/cpp/preprocessor/preprocessor.cpp diff --git a/deploy/cpp/preprocessor/preprocessor.h b/legacy/deploy/cpp/preprocessor/preprocessor.h similarity index 100% rename from deploy/cpp/preprocessor/preprocessor.h rename to legacy/deploy/cpp/preprocessor/preprocessor.h diff --git a/deploy/cpp/preprocessor/preprocessor_seg.cpp b/legacy/deploy/cpp/preprocessor/preprocessor_seg.cpp similarity index 100% rename from deploy/cpp/preprocessor/preprocessor_seg.cpp rename to legacy/deploy/cpp/preprocessor/preprocessor_seg.cpp diff --git a/deploy/cpp/preprocessor/preprocessor_seg.h b/legacy/deploy/cpp/preprocessor/preprocessor_seg.h similarity index 100% rename from deploy/cpp/preprocessor/preprocessor_seg.h rename to legacy/deploy/cpp/preprocessor/preprocessor_seg.h diff --git a/deploy/cpp/tools/visualize.py b/legacy/deploy/cpp/tools/visualize.py similarity index 100% rename from deploy/cpp/tools/visualize.py rename to legacy/deploy/cpp/tools/visualize.py diff --git a/deploy/cpp/utils/seg_conf_parser.h b/legacy/deploy/cpp/utils/seg_conf_parser.h similarity index 100% rename from deploy/cpp/utils/seg_conf_parser.h rename to legacy/deploy/cpp/utils/seg_conf_parser.h diff --git a/deploy/cpp/utils/utils.h b/legacy/deploy/cpp/utils/utils.h similarity index 100% rename from deploy/cpp/utils/utils.h rename to legacy/deploy/cpp/utils/utils.h diff --git a/deploy/lite/README.md b/legacy/deploy/lite/README.md similarity index 100% rename from deploy/lite/README.md rename to legacy/deploy/lite/README.md diff --git a/deploy/lite/example/human_1.png b/legacy/deploy/lite/example/human_1.png similarity index 100% rename from deploy/lite/example/human_1.png rename to legacy/deploy/lite/example/human_1.png diff --git a/deploy/lite/example/human_2.png b/legacy/deploy/lite/example/human_2.png similarity index 100% rename from deploy/lite/example/human_2.png rename to legacy/deploy/lite/example/human_2.png diff --git a/deploy/lite/example/human_3.png b/legacy/deploy/lite/example/human_3.png similarity index 100% rename from deploy/lite/example/human_3.png rename to legacy/deploy/lite/example/human_3.png diff --git a/deploy/lite/human_segmentation_demo/.gitignore b/legacy/deploy/lite/human_segmentation_demo/.gitignore similarity index 100% rename from deploy/lite/human_segmentation_demo/.gitignore rename to legacy/deploy/lite/human_segmentation_demo/.gitignore diff --git a/deploy/lite/human_segmentation_demo/app/.gitignore b/legacy/deploy/lite/human_segmentation_demo/app/.gitignore similarity index 100% rename from deploy/lite/human_segmentation_demo/app/.gitignore rename to legacy/deploy/lite/human_segmentation_demo/app/.gitignore diff --git a/deploy/lite/human_segmentation_demo/app/build.gradle b/legacy/deploy/lite/human_segmentation_demo/app/build.gradle similarity index 100% rename from deploy/lite/human_segmentation_demo/app/build.gradle rename to legacy/deploy/lite/human_segmentation_demo/app/build.gradle diff --git a/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.jar b/legacy/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.jar rename to legacy/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.jar diff --git a/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.properties b/legacy/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.properties rename to legacy/deploy/lite/human_segmentation_demo/app/gradle/wrapper/gradle-wrapper.properties diff --git a/deploy/lite/human_segmentation_demo/app/gradlew b/legacy/deploy/lite/human_segmentation_demo/app/gradlew similarity index 100% rename from deploy/lite/human_segmentation_demo/app/gradlew rename to legacy/deploy/lite/human_segmentation_demo/app/gradlew diff --git a/deploy/lite/human_segmentation_demo/app/gradlew.bat b/legacy/deploy/lite/human_segmentation_demo/app/gradlew.bat similarity index 100% rename from deploy/lite/human_segmentation_demo/app/gradlew.bat rename to legacy/deploy/lite/human_segmentation_demo/app/gradlew.bat diff --git a/deploy/lite/human_segmentation_demo/app/local.properties b/legacy/deploy/lite/human_segmentation_demo/app/local.properties similarity index 100% rename from deploy/lite/human_segmentation_demo/app/local.properties rename to legacy/deploy/lite/human_segmentation_demo/app/local.properties diff --git a/deploy/lite/human_segmentation_demo/app/proguard-rules.pro b/legacy/deploy/lite/human_segmentation_demo/app/proguard-rules.pro similarity index 100% rename from deploy/lite/human_segmentation_demo/app/proguard-rules.pro rename to legacy/deploy/lite/human_segmentation_demo/app/proguard-rules.pro diff --git a/deploy/lite/human_segmentation_demo/app/src/androidTest/java/com/baidu/paddle/lite/demo/ExampleInstrumentedTest.java b/legacy/deploy/lite/human_segmentation_demo/app/src/androidTest/java/com/baidu/paddle/lite/demo/ExampleInstrumentedTest.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/androidTest/java/com/baidu/paddle/lite/demo/ExampleInstrumentedTest.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/androidTest/java/com/baidu/paddle/lite/demo/ExampleInstrumentedTest.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/AndroidManifest.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/AndroidManifest.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/AndroidManifest.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/AndroidManifest.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/images/human.jpg b/legacy/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/images/human.jpg similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/images/human.jpg rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/images/human.jpg diff --git a/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/labels/label_list b/legacy/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/labels/label_list similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/labels/label_list rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/assets/image_segmentation/labels/label_list diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/AppCompatPreferenceActivity.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/AppCompatPreferenceActivity.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/AppCompatPreferenceActivity.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/AppCompatPreferenceActivity.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/MainActivity.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/MainActivity.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/MainActivity.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/MainActivity.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Predictor.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Predictor.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Predictor.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Predictor.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/SettingsActivity.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/SettingsActivity.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/SettingsActivity.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/SettingsActivity.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Utils.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Utils.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Utils.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/Utils.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/config/Config.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/config/Config.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/config/Config.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/config/Config.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/preprocess/Preprocess.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/preprocess/Preprocess.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/preprocess/Preprocess.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/preprocess/Preprocess.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/visual/Visualize.java b/legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/visual/Visualize.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/visual/Visualize.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/java/com/baidu/paddle/lite/demo/segmentation/visual/Visualize.java diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/drawable/ic_launcher_background.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/drawable/ic_launcher_background.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/layout/activity_main.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/layout/activity_main.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/layout/activity_main.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/layout/activity_main.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/menu/menu_action_options.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/menu/menu_action_options.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/menu/menu_action_options.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/menu/menu_action_options.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/values/arrays.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/arrays.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/values/arrays.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/arrays.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/values/colors.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/colors.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/values/colors.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/colors.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/values/strings.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/strings.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/values/strings.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/strings.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/values/styles.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/styles.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/values/styles.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/values/styles.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/main/res/xml/settings.xml b/legacy/deploy/lite/human_segmentation_demo/app/src/main/res/xml/settings.xml similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/main/res/xml/settings.xml rename to legacy/deploy/lite/human_segmentation_demo/app/src/main/res/xml/settings.xml diff --git a/deploy/lite/human_segmentation_demo/app/src/test/java/com/baidu/paddle/lite/demo/ExampleUnitTest.java b/legacy/deploy/lite/human_segmentation_demo/app/src/test/java/com/baidu/paddle/lite/demo/ExampleUnitTest.java similarity index 100% rename from deploy/lite/human_segmentation_demo/app/src/test/java/com/baidu/paddle/lite/demo/ExampleUnitTest.java rename to legacy/deploy/lite/human_segmentation_demo/app/src/test/java/com/baidu/paddle/lite/demo/ExampleUnitTest.java diff --git a/deploy/lite/human_segmentation_demo/build.gradle b/legacy/deploy/lite/human_segmentation_demo/build.gradle similarity index 100% rename from deploy/lite/human_segmentation_demo/build.gradle rename to legacy/deploy/lite/human_segmentation_demo/build.gradle diff --git a/deploy/lite/human_segmentation_demo/gradle.properties b/legacy/deploy/lite/human_segmentation_demo/gradle.properties similarity index 100% rename from deploy/lite/human_segmentation_demo/gradle.properties rename to legacy/deploy/lite/human_segmentation_demo/gradle.properties diff --git a/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.jar b/legacy/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.jar rename to legacy/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.jar diff --git a/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.properties b/legacy/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.properties rename to legacy/deploy/lite/human_segmentation_demo/gradle/wrapper/gradle-wrapper.properties diff --git a/deploy/lite/human_segmentation_demo/gradlew b/legacy/deploy/lite/human_segmentation_demo/gradlew similarity index 100% rename from deploy/lite/human_segmentation_demo/gradlew rename to legacy/deploy/lite/human_segmentation_demo/gradlew diff --git a/deploy/lite/human_segmentation_demo/gradlew.bat b/legacy/deploy/lite/human_segmentation_demo/gradlew.bat similarity index 100% rename from deploy/lite/human_segmentation_demo/gradlew.bat rename to legacy/deploy/lite/human_segmentation_demo/gradlew.bat diff --git a/deploy/lite/human_segmentation_demo/settings.gradle b/legacy/deploy/lite/human_segmentation_demo/settings.gradle similarity index 100% rename from deploy/lite/human_segmentation_demo/settings.gradle rename to legacy/deploy/lite/human_segmentation_demo/settings.gradle diff --git a/deploy/paddle-serving/README.md b/legacy/deploy/paddle-serving/README.md similarity index 100% rename from deploy/paddle-serving/README.md rename to legacy/deploy/paddle-serving/README.md diff --git a/deploy/paddle-serving/postprocess.py b/legacy/deploy/paddle-serving/postprocess.py similarity index 100% rename from deploy/paddle-serving/postprocess.py rename to legacy/deploy/paddle-serving/postprocess.py diff --git a/deploy/paddle-serving/seg_client.py b/legacy/deploy/paddle-serving/seg_client.py similarity index 100% rename from deploy/paddle-serving/seg_client.py rename to legacy/deploy/paddle-serving/seg_client.py diff --git a/deploy/python/README.md b/legacy/deploy/python/README.md similarity index 100% rename from deploy/python/README.md rename to legacy/deploy/python/README.md diff --git a/deploy/python/docs/PaddleSeg_Infer_Benchmark.md b/legacy/deploy/python/docs/PaddleSeg_Infer_Benchmark.md similarity index 100% rename from deploy/python/docs/PaddleSeg_Infer_Benchmark.md rename to legacy/deploy/python/docs/PaddleSeg_Infer_Benchmark.md diff --git a/deploy/python/docs/compile_paddle_with_tensorrt.md b/legacy/deploy/python/docs/compile_paddle_with_tensorrt.md similarity index 100% rename from deploy/python/docs/compile_paddle_with_tensorrt.md rename to legacy/deploy/python/docs/compile_paddle_with_tensorrt.md diff --git a/deploy/python/infer.py b/legacy/deploy/python/infer.py similarity index 100% rename from deploy/python/infer.py rename to legacy/deploy/python/infer.py diff --git a/deploy/python/requirements.txt b/legacy/deploy/python/requirements.txt similarity index 100% rename from deploy/python/requirements.txt rename to legacy/deploy/python/requirements.txt diff --git a/deploy/serving/COMPILE_GUIDE.md b/legacy/deploy/serving/COMPILE_GUIDE.md similarity index 100% rename from deploy/serving/COMPILE_GUIDE.md rename to legacy/deploy/serving/COMPILE_GUIDE.md diff --git a/deploy/serving/README.md b/legacy/deploy/serving/README.md similarity index 100% rename from deploy/serving/README.md rename to legacy/deploy/serving/README.md diff --git a/deploy/serving/UBUNTU.md b/legacy/deploy/serving/UBUNTU.md similarity index 100% rename from deploy/serving/UBUNTU.md rename to legacy/deploy/serving/UBUNTU.md diff --git a/deploy/serving/requirements.txt b/legacy/deploy/serving/requirements.txt similarity index 100% rename from deploy/serving/requirements.txt rename to legacy/deploy/serving/requirements.txt diff --git a/deploy/serving/seg-serving/CMakeLists.txt b/legacy/deploy/serving/seg-serving/CMakeLists.txt similarity index 100% rename from deploy/serving/seg-serving/CMakeLists.txt rename to legacy/deploy/serving/seg-serving/CMakeLists.txt diff --git a/deploy/serving/seg-serving/conf/gflags.conf b/legacy/deploy/serving/seg-serving/conf/gflags.conf similarity index 100% rename from deploy/serving/seg-serving/conf/gflags.conf rename to legacy/deploy/serving/seg-serving/conf/gflags.conf diff --git a/deploy/serving/seg-serving/conf/model_toolkit.prototxt b/legacy/deploy/serving/seg-serving/conf/model_toolkit.prototxt similarity index 100% rename from deploy/serving/seg-serving/conf/model_toolkit.prototxt rename to legacy/deploy/serving/seg-serving/conf/model_toolkit.prototxt diff --git a/deploy/serving/seg-serving/conf/resource.prototxt b/legacy/deploy/serving/seg-serving/conf/resource.prototxt similarity index 100% rename from deploy/serving/seg-serving/conf/resource.prototxt rename to legacy/deploy/serving/seg-serving/conf/resource.prototxt diff --git a/deploy/serving/seg-serving/conf/seg_conf.yaml b/legacy/deploy/serving/seg-serving/conf/seg_conf.yaml similarity index 100% rename from deploy/serving/seg-serving/conf/seg_conf.yaml rename to legacy/deploy/serving/seg-serving/conf/seg_conf.yaml diff --git a/deploy/serving/seg-serving/conf/seg_conf2.yaml b/legacy/deploy/serving/seg-serving/conf/seg_conf2.yaml similarity index 100% rename from deploy/serving/seg-serving/conf/seg_conf2.yaml rename to legacy/deploy/serving/seg-serving/conf/seg_conf2.yaml diff --git a/deploy/serving/seg-serving/conf/service.prototxt b/legacy/deploy/serving/seg-serving/conf/service.prototxt similarity index 100% rename from deploy/serving/seg-serving/conf/service.prototxt rename to legacy/deploy/serving/seg-serving/conf/service.prototxt diff --git a/deploy/serving/seg-serving/conf/workflow.prototxt b/legacy/deploy/serving/seg-serving/conf/workflow.prototxt similarity index 100% rename from deploy/serving/seg-serving/conf/workflow.prototxt rename to legacy/deploy/serving/seg-serving/conf/workflow.prototxt diff --git a/deploy/serving/seg-serving/data/model/paddle/fluid_reload_flag b/legacy/deploy/serving/seg-serving/data/model/paddle/fluid_reload_flag similarity index 100% rename from deploy/serving/seg-serving/data/model/paddle/fluid_reload_flag rename to legacy/deploy/serving/seg-serving/data/model/paddle/fluid_reload_flag diff --git a/deploy/serving/seg-serving/data/model/paddle/fluid_time_file b/legacy/deploy/serving/seg-serving/data/model/paddle/fluid_time_file similarity index 100% rename from deploy/serving/seg-serving/data/model/paddle/fluid_time_file rename to legacy/deploy/serving/seg-serving/data/model/paddle/fluid_time_file diff --git a/deploy/serving/seg-serving/op/CMakeLists.txt b/legacy/deploy/serving/seg-serving/op/CMakeLists.txt similarity index 100% rename from deploy/serving/seg-serving/op/CMakeLists.txt rename to legacy/deploy/serving/seg-serving/op/CMakeLists.txt diff --git a/deploy/serving/seg-serving/op/image_seg_op.cpp b/legacy/deploy/serving/seg-serving/op/image_seg_op.cpp similarity index 100% rename from deploy/serving/seg-serving/op/image_seg_op.cpp rename to legacy/deploy/serving/seg-serving/op/image_seg_op.cpp diff --git a/deploy/serving/seg-serving/op/image_seg_op.h b/legacy/deploy/serving/seg-serving/op/image_seg_op.h similarity index 100% rename from deploy/serving/seg-serving/op/image_seg_op.h rename to legacy/deploy/serving/seg-serving/op/image_seg_op.h diff --git a/deploy/serving/seg-serving/op/reader_op.cpp b/legacy/deploy/serving/seg-serving/op/reader_op.cpp similarity index 100% rename from deploy/serving/seg-serving/op/reader_op.cpp rename to legacy/deploy/serving/seg-serving/op/reader_op.cpp diff --git a/deploy/serving/seg-serving/op/reader_op.h b/legacy/deploy/serving/seg-serving/op/reader_op.h similarity index 100% rename from deploy/serving/seg-serving/op/reader_op.h rename to legacy/deploy/serving/seg-serving/op/reader_op.h diff --git a/deploy/serving/seg-serving/op/seg_conf.cpp b/legacy/deploy/serving/seg-serving/op/seg_conf.cpp similarity index 100% rename from deploy/serving/seg-serving/op/seg_conf.cpp rename to legacy/deploy/serving/seg-serving/op/seg_conf.cpp diff --git a/deploy/serving/seg-serving/op/seg_conf.h b/legacy/deploy/serving/seg-serving/op/seg_conf.h similarity index 100% rename from deploy/serving/seg-serving/op/seg_conf.h rename to legacy/deploy/serving/seg-serving/op/seg_conf.h diff --git a/deploy/serving/seg-serving/op/write_json_op.cpp b/legacy/deploy/serving/seg-serving/op/write_json_op.cpp similarity index 100% rename from deploy/serving/seg-serving/op/write_json_op.cpp rename to legacy/deploy/serving/seg-serving/op/write_json_op.cpp diff --git a/deploy/serving/seg-serving/op/write_json_op.h b/legacy/deploy/serving/seg-serving/op/write_json_op.h similarity index 100% rename from deploy/serving/seg-serving/op/write_json_op.h rename to legacy/deploy/serving/seg-serving/op/write_json_op.h diff --git a/deploy/serving/seg-serving/proto/CMakeLists.txt b/legacy/deploy/serving/seg-serving/proto/CMakeLists.txt similarity index 100% rename from deploy/serving/seg-serving/proto/CMakeLists.txt rename to legacy/deploy/serving/seg-serving/proto/CMakeLists.txt diff --git a/deploy/serving/seg-serving/proto/image_seg.proto b/legacy/deploy/serving/seg-serving/proto/image_seg.proto similarity index 100% rename from deploy/serving/seg-serving/proto/image_seg.proto rename to legacy/deploy/serving/seg-serving/proto/image_seg.proto diff --git a/deploy/serving/seg-serving/scripts/start.sh b/legacy/deploy/serving/seg-serving/scripts/start.sh similarity index 100% rename from deploy/serving/seg-serving/scripts/start.sh rename to legacy/deploy/serving/seg-serving/scripts/start.sh diff --git a/deploy/serving/tools/image_seg_client.py b/legacy/deploy/serving/tools/image_seg_client.py similarity index 100% rename from deploy/serving/tools/image_seg_client.py rename to legacy/deploy/serving/tools/image_seg_client.py diff --git a/deploy/serving/tools/images/1.jpg b/legacy/deploy/serving/tools/images/1.jpg similarity index 100% rename from deploy/serving/tools/images/1.jpg rename to legacy/deploy/serving/tools/images/1.jpg diff --git a/deploy/serving/tools/images/2.jpg b/legacy/deploy/serving/tools/images/2.jpg similarity index 100% rename from deploy/serving/tools/images/2.jpg rename to legacy/deploy/serving/tools/images/2.jpg diff --git a/deploy/serving/tools/images/3.jpg b/legacy/deploy/serving/tools/images/3.jpg similarity index 100% rename from deploy/serving/tools/images/3.jpg rename to legacy/deploy/serving/tools/images/3.jpg diff --git a/docs/annotation/cityscapes_demo/cityscapes_demo_dataset.yaml b/legacy/docs/annotation/cityscapes_demo/cityscapes_demo_dataset.yaml similarity index 100% rename from docs/annotation/cityscapes_demo/cityscapes_demo_dataset.yaml rename to legacy/docs/annotation/cityscapes_demo/cityscapes_demo_dataset.yaml diff --git a/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png b/legacy/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png similarity index 100% rename from docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png rename to legacy/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png diff --git a/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png b/legacy/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png similarity index 100% rename from docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png rename to legacy/docs/annotation/cityscapes_demo/gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png diff --git a/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png b/legacy/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png similarity index 100% rename from docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png rename to legacy/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png diff --git a/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png b/legacy/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png similarity index 100% rename from docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png rename to legacy/docs/annotation/cityscapes_demo/gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png diff --git a/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png b/legacy/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png similarity index 100% rename from docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png rename to legacy/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png diff --git a/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png b/legacy/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png similarity index 100% rename from docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png rename to legacy/docs/annotation/cityscapes_demo/leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png diff --git a/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png b/legacy/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png similarity index 100% rename from docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png rename to legacy/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png diff --git a/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png b/legacy/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png similarity index 100% rename from docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png rename to legacy/docs/annotation/cityscapes_demo/leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png diff --git a/docs/annotation/cityscapes_demo/train_list.txt b/legacy/docs/annotation/cityscapes_demo/train_list.txt similarity index 100% rename from docs/annotation/cityscapes_demo/train_list.txt rename to legacy/docs/annotation/cityscapes_demo/train_list.txt diff --git a/docs/annotation/cityscapes_demo/val_list.txt b/legacy/docs/annotation/cityscapes_demo/val_list.txt similarity index 100% rename from docs/annotation/cityscapes_demo/val_list.txt rename to legacy/docs/annotation/cityscapes_demo/val_list.txt diff --git a/docs/annotation/jingling2seg.md b/legacy/docs/annotation/jingling2seg.md similarity index 100% rename from docs/annotation/jingling2seg.md rename to legacy/docs/annotation/jingling2seg.md diff --git a/docs/annotation/jingling_demo/jingling.jpg b/legacy/docs/annotation/jingling_demo/jingling.jpg similarity index 100% rename from docs/annotation/jingling_demo/jingling.jpg rename to legacy/docs/annotation/jingling_demo/jingling.jpg diff --git a/docs/annotation/jingling_demo/outputs/annotations/jingling.png b/legacy/docs/annotation/jingling_demo/outputs/annotations/jingling.png similarity index 100% rename from docs/annotation/jingling_demo/outputs/annotations/jingling.png rename to legacy/docs/annotation/jingling_demo/outputs/annotations/jingling.png diff --git a/docs/annotation/jingling_demo/outputs/class_names.txt b/legacy/docs/annotation/jingling_demo/outputs/class_names.txt similarity index 100% rename from docs/annotation/jingling_demo/outputs/class_names.txt rename to legacy/docs/annotation/jingling_demo/outputs/class_names.txt diff --git a/docs/annotation/jingling_demo/outputs/jingling.json b/legacy/docs/annotation/jingling_demo/outputs/jingling.json similarity index 100% rename from docs/annotation/jingling_demo/outputs/jingling.json rename to legacy/docs/annotation/jingling_demo/outputs/jingling.json diff --git a/docs/annotation/labelme2seg.md b/legacy/docs/annotation/labelme2seg.md similarity index 100% rename from docs/annotation/labelme2seg.md rename to legacy/docs/annotation/labelme2seg.md diff --git a/docs/annotation/labelme_demo/2011_000025.jpg b/legacy/docs/annotation/labelme_demo/2011_000025.jpg similarity index 100% rename from docs/annotation/labelme_demo/2011_000025.jpg rename to legacy/docs/annotation/labelme_demo/2011_000025.jpg diff --git a/docs/annotation/labelme_demo/2011_000025.json b/legacy/docs/annotation/labelme_demo/2011_000025.json similarity index 100% rename from docs/annotation/labelme_demo/2011_000025.json rename to legacy/docs/annotation/labelme_demo/2011_000025.json diff --git a/docs/annotation/labelme_demo/class_names.txt b/legacy/docs/annotation/labelme_demo/class_names.txt similarity index 100% rename from docs/annotation/labelme_demo/class_names.txt rename to legacy/docs/annotation/labelme_demo/class_names.txt diff --git a/docs/check.md b/legacy/docs/check.md similarity index 100% rename from docs/check.md rename to legacy/docs/check.md diff --git a/docs/config.md b/legacy/docs/config.md similarity index 100% rename from docs/config.md rename to legacy/docs/config.md diff --git a/docs/configs/.gitkeep b/legacy/docs/configs/.gitkeep similarity index 100% rename from docs/configs/.gitkeep rename to legacy/docs/configs/.gitkeep diff --git a/docs/configs/basic_group.md b/legacy/docs/configs/basic_group.md similarity index 100% rename from docs/configs/basic_group.md rename to legacy/docs/configs/basic_group.md diff --git a/docs/configs/dataloader_group.md b/legacy/docs/configs/dataloader_group.md similarity index 100% rename from docs/configs/dataloader_group.md rename to legacy/docs/configs/dataloader_group.md diff --git a/docs/configs/dataset_group.md b/legacy/docs/configs/dataset_group.md similarity index 100% rename from docs/configs/dataset_group.md rename to legacy/docs/configs/dataset_group.md diff --git a/docs/configs/freeze_group.md b/legacy/docs/configs/freeze_group.md similarity index 100% rename from docs/configs/freeze_group.md rename to legacy/docs/configs/freeze_group.md diff --git a/docs/configs/model_deeplabv3p_group.md b/legacy/docs/configs/model_deeplabv3p_group.md similarity index 100% rename from docs/configs/model_deeplabv3p_group.md rename to legacy/docs/configs/model_deeplabv3p_group.md diff --git a/docs/configs/model_group.md b/legacy/docs/configs/model_group.md similarity index 100% rename from docs/configs/model_group.md rename to legacy/docs/configs/model_group.md diff --git a/docs/configs/model_hrnet_group.md b/legacy/docs/configs/model_hrnet_group.md similarity index 100% rename from docs/configs/model_hrnet_group.md rename to legacy/docs/configs/model_hrnet_group.md diff --git a/docs/configs/model_icnet_group.md b/legacy/docs/configs/model_icnet_group.md similarity index 100% rename from docs/configs/model_icnet_group.md rename to legacy/docs/configs/model_icnet_group.md diff --git a/docs/configs/model_pspnet_group.md b/legacy/docs/configs/model_pspnet_group.md similarity index 100% rename from docs/configs/model_pspnet_group.md rename to legacy/docs/configs/model_pspnet_group.md diff --git a/docs/configs/model_unet_group.md b/legacy/docs/configs/model_unet_group.md similarity index 100% rename from docs/configs/model_unet_group.md rename to legacy/docs/configs/model_unet_group.md diff --git a/docs/configs/solver_group.md b/legacy/docs/configs/solver_group.md similarity index 100% rename from docs/configs/solver_group.md rename to legacy/docs/configs/solver_group.md diff --git a/docs/configs/test_group.md b/legacy/docs/configs/test_group.md similarity index 100% rename from docs/configs/test_group.md rename to legacy/docs/configs/test_group.md diff --git a/docs/configs/train_group.md b/legacy/docs/configs/train_group.md similarity index 100% rename from docs/configs/train_group.md rename to legacy/docs/configs/train_group.md diff --git a/docs/data_aug.md b/legacy/docs/data_aug.md similarity index 100% rename from docs/data_aug.md rename to legacy/docs/data_aug.md diff --git a/legacy/docs/data_prepare.md b/legacy/docs/data_prepare.md new file mode 100644 index 0000000000..de1fd7965c --- /dev/null +++ b/legacy/docs/data_prepare.md @@ -0,0 +1,175 @@ +# PaddleSeg 数据准备 + +## 数据标注 + +### 标注协议 +PaddleSeg采用单通道的标注图片,每一种像素值代表一种类别,像素标注类别需要从0开始递增,例如0,1,2,3表示有4种类别。 + +**NOTE:** 标注图像请使用PNG无损压缩格式的图片。标注类别最多为256类。 + +### 灰度标注vs伪彩色标注 +一般的分割库使用单通道灰度图作为标注图片,往往显示出来是全黑的效果。灰度标注图的弊端: +1. 对图像标注后,无法直接观察标注是否正确。 +2. 模型测试过程无法直接判断分割的实际效果。 + +**PaddleSeg支持伪彩色图作为标注图片,在原来的单通道图片基础上,注入调色板。在基本不增加图片大小的基础上,却可以显示出彩色的效果。** + +同时PaddleSeg也兼容灰度图标注,用户原来的灰度数据集可以不做修改,直接使用。 +![](./imgs/annotation/image-11.png) + +### 灰度标注转换为伪彩色标注 +如果用户需要转换成伪彩色标注图,可使用我们的转换工具。适用于以下两种常见的情况: +1. 如果您希望将指定目录下的所有灰度标注图转换为伪彩色标注图,则执行以下命令,指定灰度标注所在的目录即可。 +```buildoutcfg +python pdseg/tools/gray2pseudo_color.py +``` + +|参数|用途| +|-|-| +|dir_or_file|指定灰度标注所在目录| +|output_dir|彩色标注图片的输出目录| + +2. 如果您仅希望将指定数据集中的部分灰度标注图转换为伪彩色标注图,则执行以下命令,需要已有文件列表,按列表读取指定图片。 +```buildoutcfg +python pdseg/tools/gray2pseudo_color.py --dataset_dir --file_separator +``` +|参数|用途| +|-|-| +|dir_or_file|指定文件列表路径| +|output_dir|彩色标注图片的输出目录| +|--dataset_dir|数据集所在根目录| +|--file_separator|文件列表分隔符| + +### 标注教程 +用户需预先采集好用于训练、评估和测试的图片,然后使用数据标注工具完成数据标注。 + +PddleSeg已支持2种标注工具:LabelMe、精灵数据标注工具。标注教程如下: + +- [LabelMe标注教程](annotation/labelme2seg.md) +- [精灵数据标注工具教程](annotation/jingling2seg.md) + + +## 文件列表 + +### 文件列表规范 + +PaddleSeg采用通用的文件列表方式组织训练集、验证集和测试集。在训练、评估、可视化过程前必须准备好相应的文件列表。 + +文件列表组织形式如下 +``` +原始图片路径 [SEP] 标注图片路径 +``` + +其中`[SEP]`是文件路径分割符,可以在`DATASET.SEPARATOR`配置项中修改, 默认为空格。文件列表的路径以数据集根目录作为相对路径起始点,`DATASET.DATA_DIR`即为数据集根目录。 + +如下图所示,左边为原图的图片路径,右边为图片对应的标注路径。 + +![cityscapes_filelist](./imgs/file_list.png) + +**注意事项** + +* 务必保证分隔符在文件列表中每行只存在一次, 如文件名中存在空格,请使用"|"等文件名不可用字符进行切分 + +* 文件列表请使用**UTF-8**格式保存, PaddleSeg默认使用UTF-8编码读取file_list文件 + +若数据集缺少标注图片,则文件列表不用包含分隔符和标注图片路径,如下图所示。 + +![cityscapes_filelist](./imgs/file_list2.png) + +**注意事项** + +此时的文件列表仅可在调用`pdseg/vis.py`进行可视化展示时使用, +即仅可在`DATASET.TEST_FILE_LIST`和`DATASET.VIS_FILE_LIST`配置项中使用。 +不可在`DATASET.TRAIN_FILE_LIST`和`DATASET.VAL_FILE_LIST`配置项中使用。 + + +**符合规范的文件列表是什么样的呢?** + +请参考目录[`./docs/annotation/cityscapes_demo`](../docs/annotation/cityscapes_demo/)。 + +### 数据集目录结构整理 + +如果用户想要生成数据集的文件列表,需要整理成如下的目录结构(类似于Cityscapes数据集): + +``` +./dataset/ # 数据集根目录 +├── annotations # 标注目录 +│   ├── test +│   │   ├── ... +│   │   └── ... +│   ├── train +│   │   ├── ... +│   │   └── ... +│   └── val +│   ├── ... +│   └── ... +└── images # 原图目录 + ├── test + │   ├── ... + │   └── ... + ├── train + │   ├── ... + │   └── ... + └── val + ├── ... + └── ... +Note:以上目录名可任意 +``` + +### 文件列表生成 +PaddleSeg提供了生成文件列表的使用脚本,可适用于自定义数据集或cityscapes数据集,并支持通过不同的Flags来开启特定功能。 +``` +python pdseg/tools/create_dataset_list.py ${FLAGS} +``` +运行后将在数据集根目录下生成训练/验证/测试集的文件列表(文件主名与`--second_folder`一致,扩展名为`.txt`)。 + +**Note:** 生成文件列表要求:要么原图和标注图片数量一致,要么只有原图,没有标注图片。若数据集缺少标注图片,仍可自动生成不含分隔符和标注图片路径的文件列表。 + +#### 命令行FLAGS列表 + +|FLAG|用途|默认值|参数数目| +|-|-|-|-| +|--type|指定数据集类型,`cityscapes`或`自定义`|`自定义`|1| +|--separator|文件列表分隔符|"|"|1| +|--folder|图片和标签集的文件夹名|"images" "annotations"|2| +|--second_folder|训练/验证/测试集的文件夹名|"train" "val" "test"|若干| +|--format|图片和标签集的数据格式|"jpg" "png"|2| +|--postfix|按文件主名(无扩展名)是否包含指定后缀对图片和标签集进行筛选|"" ""(2个空字符)|2| + +#### 使用示例 +- **对于自定义数据集** + +若您已经按上述说明整理好了数据集目录结构,可以运行下面的命令生成文件列表。 + +``` +# 生成文件列表,其分隔符为空格,图片和标签集的数据格式都为png +python pdseg/tools/create_dataset_list.py --separator " " --format png png +``` +``` +# 生成文件列表,其图片和标签集的文件夹名为img和gt,训练和验证集的文件夹名为training和validation,不生成测试集列表 +python pdseg/tools/create_dataset_list.py \ + --folder img gt --second_folder training validation +``` +**Note:** 必须指定自定义数据集目录,可以按需要设定FLAG。无需指定`--type`。 + +- **对于cityscapes数据集** + +若您使用的是cityscapes数据集,可以运行下面的命令生成文件列表。 + +``` +# 生成cityscapes文件列表,其分隔符为逗号 +python pdseg/tools/create_dataset_list.py --type cityscapes --separator "," +``` +**Note:** + +必须指定cityscapes数据集目录,`--type`必须为`cityscapes`。 + +在cityscapes类型下,部分FLAG将被重新设定,无需手动指定,具体如下: + +|FLAG|固定值| +|-|-| +|--folder|"leftImg8bit" "gtFine"| +|--format|"png" "png"| +|--postfix|"_leftImg8bit" "_gtFine_labelTrainIds"| + +其余FLAG可以按需要设定。 diff --git a/docs/deploy.md b/legacy/docs/deploy.md similarity index 100% rename from docs/deploy.md rename to legacy/docs/deploy.md diff --git a/docs/dice_loss.md b/legacy/docs/dice_loss.md similarity index 100% rename from docs/dice_loss.md rename to legacy/docs/dice_loss.md diff --git a/docs/faq.md b/legacy/docs/faq.md similarity index 100% rename from docs/faq.md rename to legacy/docs/faq.md diff --git a/docs/imgs/VOC2012.png b/legacy/docs/imgs/VOC2012.png similarity index 100% rename from docs/imgs/VOC2012.png rename to legacy/docs/imgs/VOC2012.png diff --git a/docs/imgs/annotation/image-1.png b/legacy/docs/imgs/annotation/image-1.png similarity index 100% rename from docs/imgs/annotation/image-1.png rename to legacy/docs/imgs/annotation/image-1.png diff --git a/docs/imgs/annotation/image-10.jpg b/legacy/docs/imgs/annotation/image-10.jpg similarity index 100% rename from docs/imgs/annotation/image-10.jpg rename to legacy/docs/imgs/annotation/image-10.jpg diff --git a/docs/imgs/annotation/image-11.png b/legacy/docs/imgs/annotation/image-11.png similarity index 100% rename from docs/imgs/annotation/image-11.png rename to legacy/docs/imgs/annotation/image-11.png diff --git a/docs/imgs/annotation/image-2.png b/legacy/docs/imgs/annotation/image-2.png similarity index 100% rename from docs/imgs/annotation/image-2.png rename to legacy/docs/imgs/annotation/image-2.png diff --git a/docs/imgs/annotation/image-3.png b/legacy/docs/imgs/annotation/image-3.png similarity index 100% rename from docs/imgs/annotation/image-3.png rename to legacy/docs/imgs/annotation/image-3.png diff --git a/docs/imgs/annotation/image-4-1.png b/legacy/docs/imgs/annotation/image-4-1.png similarity index 100% rename from docs/imgs/annotation/image-4-1.png rename to legacy/docs/imgs/annotation/image-4-1.png diff --git a/docs/imgs/annotation/image-4-2.png b/legacy/docs/imgs/annotation/image-4-2.png similarity index 100% rename from docs/imgs/annotation/image-4-2.png rename to legacy/docs/imgs/annotation/image-4-2.png diff --git a/docs/imgs/annotation/image-5.png b/legacy/docs/imgs/annotation/image-5.png similarity index 100% rename from docs/imgs/annotation/image-5.png rename to legacy/docs/imgs/annotation/image-5.png diff --git a/docs/imgs/annotation/image-6-2.png b/legacy/docs/imgs/annotation/image-6-2.png similarity index 100% rename from docs/imgs/annotation/image-6-2.png rename to legacy/docs/imgs/annotation/image-6-2.png diff --git a/docs/imgs/annotation/image-6.png b/legacy/docs/imgs/annotation/image-6.png similarity index 100% rename from docs/imgs/annotation/image-6.png rename to legacy/docs/imgs/annotation/image-6.png diff --git a/docs/imgs/annotation/image-7.png b/legacy/docs/imgs/annotation/image-7.png similarity index 100% rename from docs/imgs/annotation/image-7.png rename to legacy/docs/imgs/annotation/image-7.png diff --git a/docs/imgs/annotation/jingling-1.png b/legacy/docs/imgs/annotation/jingling-1.png similarity index 100% rename from docs/imgs/annotation/jingling-1.png rename to legacy/docs/imgs/annotation/jingling-1.png diff --git a/docs/imgs/annotation/jingling-2.png b/legacy/docs/imgs/annotation/jingling-2.png similarity index 100% rename from docs/imgs/annotation/jingling-2.png rename to legacy/docs/imgs/annotation/jingling-2.png diff --git a/docs/imgs/annotation/jingling-3.png b/legacy/docs/imgs/annotation/jingling-3.png similarity index 100% rename from docs/imgs/annotation/jingling-3.png rename to legacy/docs/imgs/annotation/jingling-3.png diff --git a/docs/imgs/annotation/jingling-4.png b/legacy/docs/imgs/annotation/jingling-4.png similarity index 100% rename from docs/imgs/annotation/jingling-4.png rename to legacy/docs/imgs/annotation/jingling-4.png diff --git a/docs/imgs/annotation/jingling-5.png b/legacy/docs/imgs/annotation/jingling-5.png similarity index 100% rename from docs/imgs/annotation/jingling-5.png rename to legacy/docs/imgs/annotation/jingling-5.png diff --git a/docs/imgs/aug_method.png b/legacy/docs/imgs/aug_method.png similarity index 100% rename from docs/imgs/aug_method.png rename to legacy/docs/imgs/aug_method.png diff --git a/docs/imgs/cityscapes.png b/legacy/docs/imgs/cityscapes.png similarity index 100% rename from docs/imgs/cityscapes.png rename to legacy/docs/imgs/cityscapes.png diff --git a/docs/imgs/cosine_decay_example.png b/legacy/docs/imgs/cosine_decay_example.png similarity index 100% rename from docs/imgs/cosine_decay_example.png rename to legacy/docs/imgs/cosine_decay_example.png diff --git a/docs/imgs/data_aug_example.png b/legacy/docs/imgs/data_aug_example.png similarity index 100% rename from docs/imgs/data_aug_example.png rename to legacy/docs/imgs/data_aug_example.png diff --git a/docs/imgs/data_aug_flip_mirror.png b/legacy/docs/imgs/data_aug_flip_mirror.png similarity index 100% rename from docs/imgs/data_aug_flip_mirror.png rename to legacy/docs/imgs/data_aug_flip_mirror.png diff --git a/docs/imgs/data_aug_flow.png b/legacy/docs/imgs/data_aug_flow.png similarity index 100% rename from docs/imgs/data_aug_flow.png rename to legacy/docs/imgs/data_aug_flow.png diff --git a/docs/imgs/deepglobe.png b/legacy/docs/imgs/deepglobe.png similarity index 100% rename from docs/imgs/deepglobe.png rename to legacy/docs/imgs/deepglobe.png diff --git a/docs/imgs/deeplabv3p.png b/legacy/docs/imgs/deeplabv3p.png similarity index 100% rename from docs/imgs/deeplabv3p.png rename to legacy/docs/imgs/deeplabv3p.png diff --git a/docs/imgs/dice.png b/legacy/docs/imgs/dice.png similarity index 100% rename from docs/imgs/dice.png rename to legacy/docs/imgs/dice.png diff --git a/docs/imgs/dice2.png b/legacy/docs/imgs/dice2.png similarity index 100% rename from docs/imgs/dice2.png rename to legacy/docs/imgs/dice2.png diff --git a/docs/imgs/dice3.png b/legacy/docs/imgs/dice3.png similarity index 100% rename from docs/imgs/dice3.png rename to legacy/docs/imgs/dice3.png diff --git a/docs/imgs/fast-scnn.png b/legacy/docs/imgs/fast-scnn.png similarity index 100% rename from docs/imgs/fast-scnn.png rename to legacy/docs/imgs/fast-scnn.png diff --git a/docs/imgs/file_list.png b/legacy/docs/imgs/file_list.png similarity index 100% rename from docs/imgs/file_list.png rename to legacy/docs/imgs/file_list.png diff --git a/docs/imgs/file_list2.png b/legacy/docs/imgs/file_list2.png similarity index 100% rename from docs/imgs/file_list2.png rename to legacy/docs/imgs/file_list2.png diff --git a/docs/imgs/gn.png b/legacy/docs/imgs/gn.png similarity index 100% rename from docs/imgs/gn.png rename to legacy/docs/imgs/gn.png diff --git a/docs/imgs/hrnet.png b/legacy/docs/imgs/hrnet.png similarity index 100% rename from docs/imgs/hrnet.png rename to legacy/docs/imgs/hrnet.png diff --git a/docs/imgs/icnet.png b/legacy/docs/imgs/icnet.png similarity index 100% rename from docs/imgs/icnet.png rename to legacy/docs/imgs/icnet.png diff --git a/docs/imgs/loss_comparison.png b/legacy/docs/imgs/loss_comparison.png similarity index 100% rename from docs/imgs/loss_comparison.png rename to legacy/docs/imgs/loss_comparison.png diff --git a/docs/imgs/lovasz-hinge-vis.png b/legacy/docs/imgs/lovasz-hinge-vis.png similarity index 100% rename from docs/imgs/lovasz-hinge-vis.png rename to legacy/docs/imgs/lovasz-hinge-vis.png diff --git a/docs/imgs/lovasz-hinge.png b/legacy/docs/imgs/lovasz-hinge.png similarity index 100% rename from docs/imgs/lovasz-hinge.png rename to legacy/docs/imgs/lovasz-hinge.png diff --git a/docs/imgs/lovasz-softmax.png b/legacy/docs/imgs/lovasz-softmax.png similarity index 100% rename from docs/imgs/lovasz-softmax.png rename to legacy/docs/imgs/lovasz-softmax.png diff --git a/docs/imgs/piecewise_decay_example.png b/legacy/docs/imgs/piecewise_decay_example.png similarity index 100% rename from docs/imgs/piecewise_decay_example.png rename to legacy/docs/imgs/piecewise_decay_example.png diff --git a/docs/imgs/poly_decay_example.png b/legacy/docs/imgs/poly_decay_example.png similarity index 100% rename from docs/imgs/poly_decay_example.png rename to legacy/docs/imgs/poly_decay_example.png diff --git a/docs/imgs/pspnet.png b/legacy/docs/imgs/pspnet.png similarity index 100% rename from docs/imgs/pspnet.png rename to legacy/docs/imgs/pspnet.png diff --git a/docs/imgs/pspnet2.png b/legacy/docs/imgs/pspnet2.png similarity index 100% rename from docs/imgs/pspnet2.png rename to legacy/docs/imgs/pspnet2.png diff --git a/docs/imgs/qq_group2.png b/legacy/docs/imgs/qq_group2.png similarity index 100% rename from docs/imgs/qq_group2.png rename to legacy/docs/imgs/qq_group2.png diff --git a/docs/imgs/rangescale.png b/legacy/docs/imgs/rangescale.png similarity index 100% rename from docs/imgs/rangescale.png rename to legacy/docs/imgs/rangescale.png diff --git a/docs/imgs/seg_news_icon.png b/legacy/docs/imgs/seg_news_icon.png similarity index 100% rename from docs/imgs/seg_news_icon.png rename to legacy/docs/imgs/seg_news_icon.png diff --git a/docs/imgs/softmax_loss.png b/legacy/docs/imgs/softmax_loss.png similarity index 100% rename from docs/imgs/softmax_loss.png rename to legacy/docs/imgs/softmax_loss.png diff --git a/docs/imgs/unet.png b/legacy/docs/imgs/unet.png similarity index 100% rename from docs/imgs/unet.png rename to legacy/docs/imgs/unet.png diff --git a/docs/imgs/usage_vis_demo.jpg b/legacy/docs/imgs/usage_vis_demo.jpg similarity index 100% rename from docs/imgs/usage_vis_demo.jpg rename to legacy/docs/imgs/usage_vis_demo.jpg diff --git a/docs/imgs/visualdl_image.png b/legacy/docs/imgs/visualdl_image.png similarity index 100% rename from docs/imgs/visualdl_image.png rename to legacy/docs/imgs/visualdl_image.png diff --git a/docs/imgs/visualdl_scalar.png b/legacy/docs/imgs/visualdl_scalar.png similarity index 100% rename from docs/imgs/visualdl_scalar.png rename to legacy/docs/imgs/visualdl_scalar.png diff --git a/docs/imgs/warmup_with_poly_decay_example.png b/legacy/docs/imgs/warmup_with_poly_decay_example.png similarity index 100% rename from docs/imgs/warmup_with_poly_decay_example.png rename to legacy/docs/imgs/warmup_with_poly_decay_example.png diff --git a/docs/loss_select.md b/legacy/docs/loss_select.md similarity index 100% rename from docs/loss_select.md rename to legacy/docs/loss_select.md diff --git a/docs/lovasz_loss.md b/legacy/docs/lovasz_loss.md similarity index 100% rename from docs/lovasz_loss.md rename to legacy/docs/lovasz_loss.md diff --git a/docs/model_export.md b/legacy/docs/model_export.md similarity index 100% rename from docs/model_export.md rename to legacy/docs/model_export.md diff --git a/docs/model_zoo.md b/legacy/docs/model_zoo.md similarity index 100% rename from docs/model_zoo.md rename to legacy/docs/model_zoo.md diff --git a/docs/models.md b/legacy/docs/models.md similarity index 100% rename from docs/models.md rename to legacy/docs/models.md diff --git a/docs/multiple_gpus_train_and_mixed_precision_train.md b/legacy/docs/multiple_gpus_train_and_mixed_precision_train.md similarity index 100% rename from docs/multiple_gpus_train_and_mixed_precision_train.md rename to legacy/docs/multiple_gpus_train_and_mixed_precision_train.md diff --git a/docs/release_notes.md b/legacy/docs/release_notes.md similarity index 100% rename from docs/release_notes.md rename to legacy/docs/release_notes.md diff --git a/docs/usage.md b/legacy/docs/usage.md similarity index 100% rename from docs/usage.md rename to legacy/docs/usage.md diff --git a/pdseg/__init__.py b/legacy/pdseg/__init__.py similarity index 100% rename from pdseg/__init__.py rename to legacy/pdseg/__init__.py diff --git a/pdseg/check.py b/legacy/pdseg/check.py similarity index 100% rename from pdseg/check.py rename to legacy/pdseg/check.py diff --git a/pdseg/data_aug.py b/legacy/pdseg/data_aug.py similarity index 100% rename from pdseg/data_aug.py rename to legacy/pdseg/data_aug.py diff --git a/pdseg/data_utils.py b/legacy/pdseg/data_utils.py similarity index 100% rename from pdseg/data_utils.py rename to legacy/pdseg/data_utils.py diff --git a/pdseg/eval.py b/legacy/pdseg/eval.py similarity index 100% rename from pdseg/eval.py rename to legacy/pdseg/eval.py diff --git a/pdseg/export_model.py b/legacy/pdseg/export_model.py similarity index 100% rename from pdseg/export_model.py rename to legacy/pdseg/export_model.py diff --git a/pdseg/export_serving_model.py b/legacy/pdseg/export_serving_model.py similarity index 100% rename from pdseg/export_serving_model.py rename to legacy/pdseg/export_serving_model.py diff --git a/pdseg/loss.py b/legacy/pdseg/loss.py similarity index 100% rename from pdseg/loss.py rename to legacy/pdseg/loss.py diff --git a/pdseg/lovasz_losses.py b/legacy/pdseg/lovasz_losses.py similarity index 100% rename from pdseg/lovasz_losses.py rename to legacy/pdseg/lovasz_losses.py diff --git a/pdseg/metrics.py b/legacy/pdseg/metrics.py similarity index 100% rename from pdseg/metrics.py rename to legacy/pdseg/metrics.py diff --git a/pdseg/models/__init__.py b/legacy/pdseg/models/__init__.py similarity index 100% rename from pdseg/models/__init__.py rename to legacy/pdseg/models/__init__.py diff --git a/pdseg/models/backbone/__init__.py b/legacy/pdseg/models/backbone/__init__.py similarity index 100% rename from pdseg/models/backbone/__init__.py rename to legacy/pdseg/models/backbone/__init__.py diff --git a/pdseg/models/backbone/mobilenet_v2.py b/legacy/pdseg/models/backbone/mobilenet_v2.py similarity index 100% rename from pdseg/models/backbone/mobilenet_v2.py rename to legacy/pdseg/models/backbone/mobilenet_v2.py diff --git a/pdseg/models/backbone/mobilenet_v3.py b/legacy/pdseg/models/backbone/mobilenet_v3.py similarity index 100% rename from pdseg/models/backbone/mobilenet_v3.py rename to legacy/pdseg/models/backbone/mobilenet_v3.py diff --git a/pdseg/models/backbone/resnet.py b/legacy/pdseg/models/backbone/resnet.py similarity index 100% rename from pdseg/models/backbone/resnet.py rename to legacy/pdseg/models/backbone/resnet.py diff --git a/pdseg/models/backbone/resnet_vd.py b/legacy/pdseg/models/backbone/resnet_vd.py similarity index 100% rename from pdseg/models/backbone/resnet_vd.py rename to legacy/pdseg/models/backbone/resnet_vd.py diff --git a/pdseg/models/backbone/vgg.py b/legacy/pdseg/models/backbone/vgg.py similarity index 100% rename from pdseg/models/backbone/vgg.py rename to legacy/pdseg/models/backbone/vgg.py diff --git a/pdseg/models/backbone/xception.py b/legacy/pdseg/models/backbone/xception.py similarity index 100% rename from pdseg/models/backbone/xception.py rename to legacy/pdseg/models/backbone/xception.py diff --git a/pdseg/models/libs/__init__.py b/legacy/pdseg/models/libs/__init__.py similarity index 100% rename from pdseg/models/libs/__init__.py rename to legacy/pdseg/models/libs/__init__.py diff --git a/pdseg/models/libs/model_libs.py b/legacy/pdseg/models/libs/model_libs.py similarity index 100% rename from pdseg/models/libs/model_libs.py rename to legacy/pdseg/models/libs/model_libs.py diff --git a/pdseg/models/model_builder.py b/legacy/pdseg/models/model_builder.py similarity index 100% rename from pdseg/models/model_builder.py rename to legacy/pdseg/models/model_builder.py diff --git a/pdseg/models/modeling/__init__.py b/legacy/pdseg/models/modeling/__init__.py similarity index 100% rename from pdseg/models/modeling/__init__.py rename to legacy/pdseg/models/modeling/__init__.py diff --git a/pdseg/models/modeling/deeplab.py b/legacy/pdseg/models/modeling/deeplab.py similarity index 100% rename from pdseg/models/modeling/deeplab.py rename to legacy/pdseg/models/modeling/deeplab.py diff --git a/pdseg/models/modeling/fast_scnn.py b/legacy/pdseg/models/modeling/fast_scnn.py similarity index 100% rename from pdseg/models/modeling/fast_scnn.py rename to legacy/pdseg/models/modeling/fast_scnn.py diff --git a/pdseg/models/modeling/hrnet.py b/legacy/pdseg/models/modeling/hrnet.py similarity index 100% rename from pdseg/models/modeling/hrnet.py rename to legacy/pdseg/models/modeling/hrnet.py diff --git a/pdseg/models/modeling/icnet.py b/legacy/pdseg/models/modeling/icnet.py similarity index 100% rename from pdseg/models/modeling/icnet.py rename to legacy/pdseg/models/modeling/icnet.py diff --git a/pdseg/models/modeling/ocrnet.py b/legacy/pdseg/models/modeling/ocrnet.py similarity index 100% rename from pdseg/models/modeling/ocrnet.py rename to legacy/pdseg/models/modeling/ocrnet.py diff --git a/pdseg/models/modeling/pspnet.py b/legacy/pdseg/models/modeling/pspnet.py similarity index 100% rename from pdseg/models/modeling/pspnet.py rename to legacy/pdseg/models/modeling/pspnet.py diff --git a/pdseg/models/modeling/unet.py b/legacy/pdseg/models/modeling/unet.py similarity index 100% rename from pdseg/models/modeling/unet.py rename to legacy/pdseg/models/modeling/unet.py diff --git a/pdseg/reader.py b/legacy/pdseg/reader.py similarity index 100% rename from pdseg/reader.py rename to legacy/pdseg/reader.py diff --git a/pdseg/solver.py b/legacy/pdseg/solver.py similarity index 100% rename from pdseg/solver.py rename to legacy/pdseg/solver.py diff --git a/pdseg/tools/__init__.py b/legacy/pdseg/tools/__init__.py similarity index 100% rename from pdseg/tools/__init__.py rename to legacy/pdseg/tools/__init__.py diff --git a/pdseg/tools/create_dataset_list.py b/legacy/pdseg/tools/create_dataset_list.py similarity index 100% rename from pdseg/tools/create_dataset_list.py rename to legacy/pdseg/tools/create_dataset_list.py diff --git a/pdseg/tools/gray2pseudo_color.py b/legacy/pdseg/tools/gray2pseudo_color.py similarity index 100% rename from pdseg/tools/gray2pseudo_color.py rename to legacy/pdseg/tools/gray2pseudo_color.py diff --git a/pdseg/tools/jingling2seg.py b/legacy/pdseg/tools/jingling2seg.py similarity index 100% rename from pdseg/tools/jingling2seg.py rename to legacy/pdseg/tools/jingling2seg.py diff --git a/pdseg/tools/labelme2seg.py b/legacy/pdseg/tools/labelme2seg.py similarity index 100% rename from pdseg/tools/labelme2seg.py rename to legacy/pdseg/tools/labelme2seg.py diff --git a/pdseg/train.py b/legacy/pdseg/train.py similarity index 100% rename from pdseg/train.py rename to legacy/pdseg/train.py diff --git a/pdseg/utils/__init__.py b/legacy/pdseg/utils/__init__.py similarity index 100% rename from pdseg/utils/__init__.py rename to legacy/pdseg/utils/__init__.py diff --git a/pdseg/utils/collect.py b/legacy/pdseg/utils/collect.py similarity index 100% rename from pdseg/utils/collect.py rename to legacy/pdseg/utils/collect.py diff --git a/pdseg/utils/config.py b/legacy/pdseg/utils/config.py similarity index 100% rename from pdseg/utils/config.py rename to legacy/pdseg/utils/config.py diff --git a/pdseg/utils/dist_utils.py b/legacy/pdseg/utils/dist_utils.py similarity index 100% rename from pdseg/utils/dist_utils.py rename to legacy/pdseg/utils/dist_utils.py diff --git a/pdseg/utils/fp16_utils.py b/legacy/pdseg/utils/fp16_utils.py similarity index 100% rename from pdseg/utils/fp16_utils.py rename to legacy/pdseg/utils/fp16_utils.py diff --git a/pdseg/utils/load_model_utils.py b/legacy/pdseg/utils/load_model_utils.py similarity index 100% rename from pdseg/utils/load_model_utils.py rename to legacy/pdseg/utils/load_model_utils.py diff --git a/pdseg/utils/paddle_utils.py b/legacy/pdseg/utils/paddle_utils.py similarity index 100% rename from pdseg/utils/paddle_utils.py rename to legacy/pdseg/utils/paddle_utils.py diff --git a/pdseg/utils/timer.py b/legacy/pdseg/utils/timer.py similarity index 100% rename from pdseg/utils/timer.py rename to legacy/pdseg/utils/timer.py diff --git a/pdseg/vis.py b/legacy/pdseg/vis.py similarity index 100% rename from pdseg/vis.py rename to legacy/pdseg/vis.py diff --git a/pretrained_model/download_model.py b/legacy/pretrained_model/download_model.py similarity index 100% rename from pretrained_model/download_model.py rename to legacy/pretrained_model/download_model.py diff --git a/dygraph/requirements.txt b/legacy/requirements.txt similarity index 69% rename from dygraph/requirements.txt rename to legacy/requirements.txt index 237cf295bd..6200a94b71 100644 --- a/dygraph/requirements.txt +++ b/legacy/requirements.txt @@ -3,6 +3,3 @@ yapf == 0.26.0 flake8 pyyaml >= 5.1 visualdl >= 2.0.0 -opencv-python -tqdm -filelock diff --git a/slim/distillation/README.md b/legacy/slim/distillation/README.md similarity index 100% rename from slim/distillation/README.md rename to legacy/slim/distillation/README.md diff --git a/slim/distillation/cityscape.yaml b/legacy/slim/distillation/cityscape.yaml similarity index 100% rename from slim/distillation/cityscape.yaml rename to legacy/slim/distillation/cityscape.yaml diff --git a/slim/distillation/cityscape_teacher.yaml b/legacy/slim/distillation/cityscape_teacher.yaml similarity index 100% rename from slim/distillation/cityscape_teacher.yaml rename to legacy/slim/distillation/cityscape_teacher.yaml diff --git a/slim/distillation/model_builder.py b/legacy/slim/distillation/model_builder.py similarity index 100% rename from slim/distillation/model_builder.py rename to legacy/slim/distillation/model_builder.py diff --git a/slim/distillation/train_distill.py b/legacy/slim/distillation/train_distill.py similarity index 100% rename from slim/distillation/train_distill.py rename to legacy/slim/distillation/train_distill.py diff --git a/slim/nas/README.md b/legacy/slim/nas/README.md similarity index 100% rename from slim/nas/README.md rename to legacy/slim/nas/README.md diff --git a/slim/nas/deeplab.py b/legacy/slim/nas/deeplab.py similarity index 100% rename from slim/nas/deeplab.py rename to legacy/slim/nas/deeplab.py diff --git a/slim/nas/eval_nas.py b/legacy/slim/nas/eval_nas.py similarity index 100% rename from slim/nas/eval_nas.py rename to legacy/slim/nas/eval_nas.py diff --git a/slim/nas/mobilenetv2_search_space.py b/legacy/slim/nas/mobilenetv2_search_space.py similarity index 100% rename from slim/nas/mobilenetv2_search_space.py rename to legacy/slim/nas/mobilenetv2_search_space.py diff --git a/slim/nas/model_builder.py b/legacy/slim/nas/model_builder.py similarity index 100% rename from slim/nas/model_builder.py rename to legacy/slim/nas/model_builder.py diff --git a/slim/nas/train_nas.py b/legacy/slim/nas/train_nas.py similarity index 100% rename from slim/nas/train_nas.py rename to legacy/slim/nas/train_nas.py diff --git a/slim/prune/README.md b/legacy/slim/prune/README.md similarity index 100% rename from slim/prune/README.md rename to legacy/slim/prune/README.md diff --git a/slim/prune/eval_prune.py b/legacy/slim/prune/eval_prune.py similarity index 100% rename from slim/prune/eval_prune.py rename to legacy/slim/prune/eval_prune.py diff --git a/slim/prune/train_prune.py b/legacy/slim/prune/train_prune.py similarity index 100% rename from slim/prune/train_prune.py rename to legacy/slim/prune/train_prune.py diff --git a/slim/quantization/README.md b/legacy/slim/quantization/README.md similarity index 100% rename from slim/quantization/README.md rename to legacy/slim/quantization/README.md diff --git a/slim/quantization/deploy/README.md b/legacy/slim/quantization/deploy/README.md similarity index 100% rename from slim/quantization/deploy/README.md rename to legacy/slim/quantization/deploy/README.md diff --git a/slim/quantization/deploy/infer.py b/legacy/slim/quantization/deploy/infer.py similarity index 100% rename from slim/quantization/deploy/infer.py rename to legacy/slim/quantization/deploy/infer.py diff --git a/slim/quantization/eval_quant.py b/legacy/slim/quantization/eval_quant.py similarity index 100% rename from slim/quantization/eval_quant.py rename to legacy/slim/quantization/eval_quant.py diff --git a/slim/quantization/export_model.py b/legacy/slim/quantization/export_model.py similarity index 100% rename from slim/quantization/export_model.py rename to legacy/slim/quantization/export_model.py diff --git a/slim/quantization/images/ConvertToInt8Pass.png b/legacy/slim/quantization/images/ConvertToInt8Pass.png similarity index 100% rename from slim/quantization/images/ConvertToInt8Pass.png rename to legacy/slim/quantization/images/ConvertToInt8Pass.png diff --git a/slim/quantization/images/FreezePass.png b/legacy/slim/quantization/images/FreezePass.png similarity index 100% rename from slim/quantization/images/FreezePass.png rename to legacy/slim/quantization/images/FreezePass.png diff --git a/slim/quantization/images/TransformForMobilePass.png b/legacy/slim/quantization/images/TransformForMobilePass.png similarity index 100% rename from slim/quantization/images/TransformForMobilePass.png rename to legacy/slim/quantization/images/TransformForMobilePass.png diff --git a/slim/quantization/images/TransformPass.png b/legacy/slim/quantization/images/TransformPass.png similarity index 100% rename from slim/quantization/images/TransformPass.png rename to legacy/slim/quantization/images/TransformPass.png diff --git a/slim/quantization/train_quant.py b/legacy/slim/quantization/train_quant.py similarity index 100% rename from slim/quantization/train_quant.py rename to legacy/slim/quantization/train_quant.py diff --git a/test/ci/check_code_style.sh b/legacy/test/ci/check_code_style.sh similarity index 100% rename from test/ci/check_code_style.sh rename to legacy/test/ci/check_code_style.sh diff --git a/test/ci/test_download_dataset.sh b/legacy/test/ci/test_download_dataset.sh similarity index 100% rename from test/ci/test_download_dataset.sh rename to legacy/test/ci/test_download_dataset.sh diff --git a/test/configs/deeplabv3p_xception65_cityscapes.yaml b/legacy/test/configs/deeplabv3p_xception65_cityscapes.yaml similarity index 100% rename from test/configs/deeplabv3p_xception65_cityscapes.yaml rename to legacy/test/configs/deeplabv3p_xception65_cityscapes.yaml diff --git a/test/configs/unet_pet.yaml b/legacy/test/configs/unet_pet.yaml similarity index 100% rename from test/configs/unet_pet.yaml rename to legacy/test/configs/unet_pet.yaml diff --git a/test/local_test_cityscapes.py b/legacy/test/local_test_cityscapes.py similarity index 100% rename from test/local_test_cityscapes.py rename to legacy/test/local_test_cityscapes.py diff --git a/test/local_test_pet.py b/legacy/test/local_test_pet.py similarity index 100% rename from test/local_test_pet.py rename to legacy/test/local_test_pet.py diff --git a/test/test_utils.py b/legacy/test/test_utils.py similarity index 100% rename from test/test_utils.py rename to legacy/test/test_utils.py diff --git a/tutorial/finetune_deeplabv3plus.md b/legacy/tutorial/finetune_deeplabv3plus.md similarity index 100% rename from tutorial/finetune_deeplabv3plus.md rename to legacy/tutorial/finetune_deeplabv3plus.md diff --git a/tutorial/finetune_fast_scnn.md b/legacy/tutorial/finetune_fast_scnn.md similarity index 100% rename from tutorial/finetune_fast_scnn.md rename to legacy/tutorial/finetune_fast_scnn.md diff --git a/tutorial/finetune_hrnet.md b/legacy/tutorial/finetune_hrnet.md similarity index 100% rename from tutorial/finetune_hrnet.md rename to legacy/tutorial/finetune_hrnet.md diff --git a/tutorial/finetune_icnet.md b/legacy/tutorial/finetune_icnet.md similarity index 100% rename from tutorial/finetune_icnet.md rename to legacy/tutorial/finetune_icnet.md diff --git a/tutorial/finetune_ocrnet.md b/legacy/tutorial/finetune_ocrnet.md similarity index 100% rename from tutorial/finetune_ocrnet.md rename to legacy/tutorial/finetune_ocrnet.md diff --git a/tutorial/finetune_pspnet.md b/legacy/tutorial/finetune_pspnet.md similarity index 100% rename from tutorial/finetune_pspnet.md rename to legacy/tutorial/finetune_pspnet.md diff --git a/tutorial/finetune_unet.md b/legacy/tutorial/finetune_unet.md similarity index 100% rename from tutorial/finetune_unet.md rename to legacy/tutorial/finetune_unet.md diff --git a/tutorial/imgs/optic.png b/legacy/tutorial/imgs/optic.png similarity index 100% rename from tutorial/imgs/optic.png rename to legacy/tutorial/imgs/optic.png diff --git a/tutorial/imgs/optic_deeplab.png b/legacy/tutorial/imgs/optic_deeplab.png similarity index 100% rename from tutorial/imgs/optic_deeplab.png rename to legacy/tutorial/imgs/optic_deeplab.png diff --git a/tutorial/imgs/optic_hrnet.png b/legacy/tutorial/imgs/optic_hrnet.png similarity index 100% rename from tutorial/imgs/optic_hrnet.png rename to legacy/tutorial/imgs/optic_hrnet.png diff --git a/tutorial/imgs/optic_icnet.png b/legacy/tutorial/imgs/optic_icnet.png similarity index 100% rename from tutorial/imgs/optic_icnet.png rename to legacy/tutorial/imgs/optic_icnet.png diff --git a/tutorial/imgs/optic_pspnet.png b/legacy/tutorial/imgs/optic_pspnet.png similarity index 100% rename from tutorial/imgs/optic_pspnet.png rename to legacy/tutorial/imgs/optic_pspnet.png diff --git a/tutorial/imgs/optic_unet.png b/legacy/tutorial/imgs/optic_unet.png similarity index 100% rename from tutorial/imgs/optic_unet.png rename to legacy/tutorial/imgs/optic_unet.png diff --git a/dygraph/paddleseg/__init__.py b/paddleseg/__init__.py similarity index 100% rename from dygraph/paddleseg/__init__.py rename to paddleseg/__init__.py diff --git a/dygraph/paddleseg/core/__init__.py b/paddleseg/core/__init__.py similarity index 100% rename from dygraph/paddleseg/core/__init__.py rename to paddleseg/core/__init__.py diff --git a/dygraph/paddleseg/core/infer.py b/paddleseg/core/infer.py similarity index 100% rename from dygraph/paddleseg/core/infer.py rename to paddleseg/core/infer.py diff --git a/dygraph/paddleseg/core/predict.py b/paddleseg/core/predict.py similarity index 100% rename from dygraph/paddleseg/core/predict.py rename to paddleseg/core/predict.py diff --git a/dygraph/paddleseg/core/train.py b/paddleseg/core/train.py similarity index 100% rename from dygraph/paddleseg/core/train.py rename to paddleseg/core/train.py diff --git a/dygraph/paddleseg/core/val.py b/paddleseg/core/val.py similarity index 100% rename from dygraph/paddleseg/core/val.py rename to paddleseg/core/val.py diff --git a/dygraph/paddleseg/cvlibs/__init__.py b/paddleseg/cvlibs/__init__.py similarity index 100% rename from dygraph/paddleseg/cvlibs/__init__.py rename to paddleseg/cvlibs/__init__.py diff --git a/dygraph/paddleseg/cvlibs/callbacks.py b/paddleseg/cvlibs/callbacks.py similarity index 100% rename from dygraph/paddleseg/cvlibs/callbacks.py rename to paddleseg/cvlibs/callbacks.py diff --git a/dygraph/paddleseg/cvlibs/config.py b/paddleseg/cvlibs/config.py similarity index 100% rename from dygraph/paddleseg/cvlibs/config.py rename to paddleseg/cvlibs/config.py diff --git a/dygraph/paddleseg/cvlibs/manager.py b/paddleseg/cvlibs/manager.py similarity index 100% rename from dygraph/paddleseg/cvlibs/manager.py rename to paddleseg/cvlibs/manager.py diff --git a/dygraph/paddleseg/cvlibs/param_init.py b/paddleseg/cvlibs/param_init.py similarity index 100% rename from dygraph/paddleseg/cvlibs/param_init.py rename to paddleseg/cvlibs/param_init.py diff --git a/dygraph/paddleseg/datasets/__init__.py b/paddleseg/datasets/__init__.py similarity index 100% rename from dygraph/paddleseg/datasets/__init__.py rename to paddleseg/datasets/__init__.py diff --git a/dygraph/paddleseg/datasets/ade.py b/paddleseg/datasets/ade.py similarity index 100% rename from dygraph/paddleseg/datasets/ade.py rename to paddleseg/datasets/ade.py diff --git a/dygraph/paddleseg/datasets/cityscapes.py b/paddleseg/datasets/cityscapes.py similarity index 100% rename from dygraph/paddleseg/datasets/cityscapes.py rename to paddleseg/datasets/cityscapes.py diff --git a/dygraph/paddleseg/datasets/dataset.py b/paddleseg/datasets/dataset.py similarity index 100% rename from dygraph/paddleseg/datasets/dataset.py rename to paddleseg/datasets/dataset.py diff --git a/dygraph/paddleseg/datasets/optic_disc_seg.py b/paddleseg/datasets/optic_disc_seg.py similarity index 100% rename from dygraph/paddleseg/datasets/optic_disc_seg.py rename to paddleseg/datasets/optic_disc_seg.py diff --git a/dygraph/paddleseg/datasets/voc.py b/paddleseg/datasets/voc.py similarity index 100% rename from dygraph/paddleseg/datasets/voc.py rename to paddleseg/datasets/voc.py diff --git a/dygraph/paddleseg/models/__init__.py b/paddleseg/models/__init__.py similarity index 100% rename from dygraph/paddleseg/models/__init__.py rename to paddleseg/models/__init__.py diff --git a/dygraph/paddleseg/models/ann.py b/paddleseg/models/ann.py similarity index 100% rename from dygraph/paddleseg/models/ann.py rename to paddleseg/models/ann.py diff --git a/dygraph/paddleseg/models/backbones/__init__.py b/paddleseg/models/backbones/__init__.py similarity index 100% rename from dygraph/paddleseg/models/backbones/__init__.py rename to paddleseg/models/backbones/__init__.py diff --git a/dygraph/paddleseg/models/backbones/hrnet.py b/paddleseg/models/backbones/hrnet.py similarity index 100% rename from dygraph/paddleseg/models/backbones/hrnet.py rename to paddleseg/models/backbones/hrnet.py diff --git a/dygraph/paddleseg/models/backbones/mobilenetv3.py b/paddleseg/models/backbones/mobilenetv3.py similarity index 100% rename from dygraph/paddleseg/models/backbones/mobilenetv3.py rename to paddleseg/models/backbones/mobilenetv3.py diff --git a/dygraph/paddleseg/models/backbones/resnet_vd.py b/paddleseg/models/backbones/resnet_vd.py similarity index 100% rename from dygraph/paddleseg/models/backbones/resnet_vd.py rename to paddleseg/models/backbones/resnet_vd.py diff --git a/dygraph/paddleseg/models/backbones/xception_deeplab.py b/paddleseg/models/backbones/xception_deeplab.py similarity index 100% rename from dygraph/paddleseg/models/backbones/xception_deeplab.py rename to paddleseg/models/backbones/xception_deeplab.py diff --git a/dygraph/paddleseg/models/bisenet.py b/paddleseg/models/bisenet.py similarity index 100% rename from dygraph/paddleseg/models/bisenet.py rename to paddleseg/models/bisenet.py diff --git a/dygraph/paddleseg/models/danet.py b/paddleseg/models/danet.py similarity index 100% rename from dygraph/paddleseg/models/danet.py rename to paddleseg/models/danet.py diff --git a/dygraph/paddleseg/models/deeplab.py b/paddleseg/models/deeplab.py similarity index 100% rename from dygraph/paddleseg/models/deeplab.py rename to paddleseg/models/deeplab.py diff --git a/dygraph/paddleseg/models/fast_scnn.py b/paddleseg/models/fast_scnn.py similarity index 100% rename from dygraph/paddleseg/models/fast_scnn.py rename to paddleseg/models/fast_scnn.py diff --git a/dygraph/paddleseg/models/fcn.py b/paddleseg/models/fcn.py similarity index 100% rename from dygraph/paddleseg/models/fcn.py rename to paddleseg/models/fcn.py diff --git a/dygraph/paddleseg/models/gcnet.py b/paddleseg/models/gcnet.py similarity index 100% rename from dygraph/paddleseg/models/gcnet.py rename to paddleseg/models/gcnet.py diff --git a/dygraph/paddleseg/models/layers/__init__.py b/paddleseg/models/layers/__init__.py similarity index 100% rename from dygraph/paddleseg/models/layers/__init__.py rename to paddleseg/models/layers/__init__.py diff --git a/dygraph/paddleseg/models/layers/activation.py b/paddleseg/models/layers/activation.py similarity index 100% rename from dygraph/paddleseg/models/layers/activation.py rename to paddleseg/models/layers/activation.py diff --git a/dygraph/paddleseg/models/layers/layer_libs.py b/paddleseg/models/layers/layer_libs.py similarity index 100% rename from dygraph/paddleseg/models/layers/layer_libs.py rename to paddleseg/models/layers/layer_libs.py diff --git a/dygraph/paddleseg/models/layers/pyramid_pool.py b/paddleseg/models/layers/pyramid_pool.py similarity index 100% rename from dygraph/paddleseg/models/layers/pyramid_pool.py rename to paddleseg/models/layers/pyramid_pool.py diff --git a/dygraph/paddleseg/models/losses/__init__.py b/paddleseg/models/losses/__init__.py similarity index 100% rename from dygraph/paddleseg/models/losses/__init__.py rename to paddleseg/models/losses/__init__.py diff --git a/dygraph/paddleseg/models/losses/cross_entroy_loss.py b/paddleseg/models/losses/cross_entroy_loss.py similarity index 100% rename from dygraph/paddleseg/models/losses/cross_entroy_loss.py rename to paddleseg/models/losses/cross_entroy_loss.py diff --git a/dygraph/paddleseg/models/ocrnet.py b/paddleseg/models/ocrnet.py similarity index 100% rename from dygraph/paddleseg/models/ocrnet.py rename to paddleseg/models/ocrnet.py diff --git a/dygraph/paddleseg/models/pspnet.py b/paddleseg/models/pspnet.py similarity index 100% rename from dygraph/paddleseg/models/pspnet.py rename to paddleseg/models/pspnet.py diff --git a/dygraph/paddleseg/models/unet.py b/paddleseg/models/unet.py similarity index 100% rename from dygraph/paddleseg/models/unet.py rename to paddleseg/models/unet.py diff --git a/dygraph/paddleseg/transforms/__init__.py b/paddleseg/transforms/__init__.py similarity index 100% rename from dygraph/paddleseg/transforms/__init__.py rename to paddleseg/transforms/__init__.py diff --git a/dygraph/paddleseg/transforms/functional.py b/paddleseg/transforms/functional.py similarity index 100% rename from dygraph/paddleseg/transforms/functional.py rename to paddleseg/transforms/functional.py diff --git a/dygraph/paddleseg/transforms/transforms.py b/paddleseg/transforms/transforms.py similarity index 100% rename from dygraph/paddleseg/transforms/transforms.py rename to paddleseg/transforms/transforms.py diff --git a/dygraph/paddleseg/utils/__init__.py b/paddleseg/utils/__init__.py similarity index 100% rename from dygraph/paddleseg/utils/__init__.py rename to paddleseg/utils/__init__.py diff --git a/dygraph/paddleseg/utils/download.py b/paddleseg/utils/download.py similarity index 100% rename from dygraph/paddleseg/utils/download.py rename to paddleseg/utils/download.py diff --git a/dygraph/paddleseg/utils/env/__init__.py b/paddleseg/utils/env/__init__.py similarity index 100% rename from dygraph/paddleseg/utils/env/__init__.py rename to paddleseg/utils/env/__init__.py diff --git a/dygraph/paddleseg/utils/env/seg_env.py b/paddleseg/utils/env/seg_env.py similarity index 100% rename from dygraph/paddleseg/utils/env/seg_env.py rename to paddleseg/utils/env/seg_env.py diff --git a/dygraph/paddleseg/utils/env/sys_env.py b/paddleseg/utils/env/sys_env.py similarity index 100% rename from dygraph/paddleseg/utils/env/sys_env.py rename to paddleseg/utils/env/sys_env.py diff --git a/dygraph/paddleseg/utils/logger.py b/paddleseg/utils/logger.py similarity index 100% rename from dygraph/paddleseg/utils/logger.py rename to paddleseg/utils/logger.py diff --git a/dygraph/paddleseg/utils/metrics.py b/paddleseg/utils/metrics.py similarity index 100% rename from dygraph/paddleseg/utils/metrics.py rename to paddleseg/utils/metrics.py diff --git a/dygraph/paddleseg/utils/progbar.py b/paddleseg/utils/progbar.py similarity index 100% rename from dygraph/paddleseg/utils/progbar.py rename to paddleseg/utils/progbar.py diff --git a/dygraph/paddleseg/utils/timer.py b/paddleseg/utils/timer.py similarity index 100% rename from dygraph/paddleseg/utils/timer.py rename to paddleseg/utils/timer.py diff --git a/dygraph/paddleseg/utils/utils.py b/paddleseg/utils/utils.py similarity index 100% rename from dygraph/paddleseg/utils/utils.py rename to paddleseg/utils/utils.py diff --git a/dygraph/paddleseg/utils/visualize.py b/paddleseg/utils/visualize.py similarity index 100% rename from dygraph/paddleseg/utils/visualize.py rename to paddleseg/utils/visualize.py diff --git a/dygraph/predict.py b/predict.py similarity index 100% rename from dygraph/predict.py rename to predict.py diff --git a/requirements.txt b/requirements.txt index 6200a94b71..237cf295bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,6 @@ yapf == 0.26.0 flake8 pyyaml >= 5.1 visualdl >= 2.0.0 +opencv-python +tqdm +filelock diff --git a/dygraph/tools/convert_cityscapes.py b/tools/convert_cityscapes.py similarity index 100% rename from dygraph/tools/convert_cityscapes.py rename to tools/convert_cityscapes.py diff --git a/dygraph/tools/voc_augment.py b/tools/voc_augment.py similarity index 100% rename from dygraph/tools/voc_augment.py rename to tools/voc_augment.py diff --git a/dygraph/train.py b/train.py similarity index 100% rename from dygraph/train.py rename to train.py diff --git a/dygraph/val.py b/val.py similarity index 100% rename from dygraph/val.py rename to val.py From d98663a8ea02afad9b062c0c38d10b53e833d15a Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 7 Dec 2020 15:23:30 +0800 Subject: [PATCH 19/35] add gscnn --- configs/gscnn/README.md | 13 + ...n_resnet50_os8_cityscapes_1024x512_80k.yml | 29 ++ paddleseg/core/train.py | 48 +-- paddleseg/datasets/ade.py | 12 +- paddleseg/datasets/cityscapes.py | 4 +- paddleseg/datasets/dataset.py | 13 +- paddleseg/datasets/optic_disc_seg.py | 8 +- paddleseg/datasets/voc.py | 4 +- paddleseg/models/__init__.py | 1 + paddleseg/models/backbones/resnet_vd.py | 2 + paddleseg/models/gscnn.py | 344 ++++++++++++++++++ paddleseg/models/losses/__init__.py | 3 + .../models/losses/binary_cross_entroy_loss.py | 158 ++++++++ paddleseg/models/losses/dual_task_loss.py | 139 +++++++ .../models/losses/edge_attention_loss.py | 75 ++++ paddleseg/transforms/functional.py | 66 ++++ 16 files changed, 890 insertions(+), 29 deletions(-) create mode 100644 configs/gscnn/README.md create mode 100644 configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml create mode 100644 paddleseg/models/gscnn.py create mode 100644 paddleseg/models/losses/binary_cross_entroy_loss.py create mode 100644 paddleseg/models/losses/dual_task_loss.py create mode 100644 paddleseg/models/losses/edge_attention_loss.py diff --git a/configs/gscnn/README.md b/configs/gscnn/README.md new file mode 100644 index 0000000000..a3806879f9 --- /dev/null +++ b/configs/gscnn/README.md @@ -0,0 +1,13 @@ +# Gated-scnn: Gated shape cnns for semantic segmentation + +## Reference + +> Takikawa T, Acuna D, Jampani V, et al. Gated-scnn: Gated shape cnns for semantic segmentation[C]//Proceedings of the IEEE International Conference on Computer Vision. 2019: 5229-5238. + +## Performance + +### Cityscapes + +| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|GSCNN|ResNet50_OS8|1024x512|80000|80.67%|80.88%|80.88%|[model](https://bj.bcebos.com/paddleseg/dygraph/cutyscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cutyscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=11b79b6a2899739c0d009b1ce34bad77)| diff --git a/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml new file mode 100644 index 0000000000..eacde21a0f --- /dev/null +++ b/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml @@ -0,0 +1,29 @@ +_base_: '../../configs/_base_/cityscapes.yml' + +batch_size: 2 +iters: 80000 + +model: + type: GSCNN + backbone: + type: ResNet50_vd + output_stride: 8 + multi_grid: [1, 2, 4] + pretrained: https://bj.bcebos.com/paddleseg/dygraph/resnet50_vd_ssld_v2.tar.gz + num_classes: 19 + backbone_indices: [0, 1, 2, 3] + aspp_ratios: [1, 12, 24, 36] + aspp_out_channels: 256 + align_corners: False + pretrained: null + +loss: + types: + - type: CrossEntropyLoss + - type: EdgeAttentionLoss + - type: BCELoss + - type: DualTaskLoss + coef: [1, 1, 20, 1] + +train_dataset: + edge: True diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index b9d4030a9d..4c2e33087e 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -22,29 +22,25 @@ from paddleseg.core.val import evaluate -def check_logits_losses(logits, losses): - len_logits = len(logits) +def check_logits_losses(logits_list, losses): + len_logits = len(logits_list) len_losses = len(losses['types']) if len_logits != len_losses: raise RuntimeError( - 'The length of logits should equal to the types of loss config: {} != {}.' + 'The length of logits_list should equal to the types of loss config: {} != {}.' .format(len_logits, len_losses)) -def loss_computation(logits, label, losses): - check_logits_losses(logits, losses) +def loss_computation(logits_list, labels, losses, edges=None): + check_logits_losses(logits_list, losses) loss = 0 - for i in range(len(logits)): - logit = logits[i] - if logit.shape[-2:] != label.shape[-2:]: - logit = F.interpolate( - logit, - label.shape[-2:], - mode='bilinear', - align_corners=True, - align_mode=1) - loss_i = losses['types'][i](logit, label) - loss += losses['coef'][i] * loss_i + for i in range(len(logits_list)): + logits = logits_list[i] + loss_i = losses['types'][i] + # Whether to use edges as labels According to loss type . + if loss_i.__class__.__name__ in ('BCELoss', ): + labels = edges + loss += losses['coef'][i] * loss_i(logits, labels) return loss @@ -111,14 +107,21 @@ def train(model, train_reader_cost += timer.elapsed_time() images = data[0] labels = data[1].astype('int64') + edges = None + if len(data) == 3: + edges = data[2].astype('int64') + if nranks > 1: - logits = ddp_model(images) - loss = loss_computation(logits, labels, losses) - loss.backward() + logits_list = ddp_model(images) else: - logits = model(images) - loss = loss_computation(logits, labels, losses) - loss.backward() + logits_list = model(images) + loss = loss_computation( + logits_list=logits_list, + labels=labels, + losses=losses, + edges=edges) + loss.backward() + optimizer.step() lr = optimizer.get_lr() if isinstance(optimizer._learning_rate, @@ -127,6 +130,7 @@ def train(model, model.clear_gradients() avg_loss += loss.numpy()[0] train_batch_cost += timer.elapsed_time() + if (iter) % log_iters == 0 and local_rank == 0: avg_loss /= log_iters avg_train_reader_cost = train_reader_cost / log_iters diff --git a/paddleseg/datasets/ade.py b/paddleseg/datasets/ade.py index b1a445285d..72620d2d87 100644 --- a/paddleseg/datasets/ade.py +++ b/paddleseg/datasets/ade.py @@ -22,6 +22,7 @@ from paddleseg.utils import seg_env from paddleseg.cvlibs import manager from paddleseg.transforms import Compose +import paddleseg.transforms.functional as F URL = "http://data.csail.mit.edu/places/ADEchallenge/ADEChallengeData2016.zip" @@ -35,9 +36,10 @@ class ADE20K(Dataset): transforms (list): A list of image transformations. dataset_root (str, optional): The ADK20K dataset directory. Default: None. mode (str, optional): A subset of the entire dataset. It should be one of ('train', 'val'). Default: 'train'. + edge (bool): Whether to compute edge while training. Defualt: False """ - def __init__(self, transforms, dataset_root=None, mode='train'): + def __init__(self, transforms, dataset_root=None, mode='train', edge=False): self.dataset_root = dataset_root self.transforms = Compose(transforms) mode = mode.lower() @@ -45,6 +47,7 @@ def __init__(self, transforms, dataset_root=None, mode='train'): self.file_list = list() self.num_classes = 150 self.ignore_index = 255 + self.edge = edge if mode not in ['train', 'val']: raise ValueError( @@ -97,4 +100,9 @@ def __getitem__(self, idx): else: im, label = self.transforms(im=image_path, label=label_path) label = label - 1 - return im, label + if self.edge: + edge_mask = F.mask_to_binary_edge( + label, radius=2, num_classes=self.num_classes) + return im, label, edge_mask + else: + return im, label diff --git a/paddleseg/datasets/cityscapes.py b/paddleseg/datasets/cityscapes.py index 27f0eb9d62..af7c122426 100644 --- a/paddleseg/datasets/cityscapes.py +++ b/paddleseg/datasets/cityscapes.py @@ -44,9 +44,10 @@ class Cityscapes(Dataset): transforms (list): Transforms for image. dataset_root (str): Cityscapes dataset directory. mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. + edge (bool): Whether to compute edge while training. Defualt: False """ - def __init__(self, transforms, dataset_root, mode='train'): + def __init__(self, transforms, dataset_root, mode='train', edge=False): self.dataset_root = dataset_root self.transforms = Compose(transforms) self.file_list = list() @@ -54,6 +55,7 @@ def __init__(self, transforms, dataset_root, mode='train'): self.mode = mode self.num_classes = 19 self.ignore_index = 255 + self.edge = edge if mode not in ['train', 'val', 'test']: raise ValueError( diff --git a/paddleseg/datasets/dataset.py b/paddleseg/datasets/dataset.py index 25e8a9035e..10decc1c05 100644 --- a/paddleseg/datasets/dataset.py +++ b/paddleseg/datasets/dataset.py @@ -20,6 +20,7 @@ from paddleseg.cvlibs import manager from paddleseg.transforms import Compose +import paddleseg.transforms.functional as F @manager.DATASETS.add_component @@ -41,6 +42,7 @@ class Dataset(paddle.io.Dataset): test_path (str): The test dataset file. When mode is 'test', test_path is necessary. The annotation file is not necessary in test_path file. separator (str): The separator of dataset list. Default: ' '. + edge (bool): Whether to compute edge while training. Defualt: False Examples: @@ -68,7 +70,8 @@ def __init__(self, val_path=None, test_path=None, separator=' ', - ignore_index=255): + ignore_index=255, + edge=False): self.dataset_root = dataset_root self.transforms = Compose(transforms) self.file_list = list() @@ -76,6 +79,7 @@ def __init__(self, self.mode = mode self.num_classes = num_classes self.ignore_index = ignore_index + self.edge = edge if mode.lower() not in ['train', 'val', 'test']: raise ValueError( @@ -149,7 +153,12 @@ def __getitem__(self, idx): return im, label else: im, label = self.transforms(im=image_path, label=label_path) - return im, label + if self.edge: + edge_mask = F.mask_to_binary_edge( + label, radius=2, num_classes=self.num_classes) + return im, label, edge_mask + else: + return im, label def __len__(self): return len(self.file_list) diff --git a/paddleseg/datasets/optic_disc_seg.py b/paddleseg/datasets/optic_disc_seg.py index c447f36858..dfb8806d5c 100644 --- a/paddleseg/datasets/optic_disc_seg.py +++ b/paddleseg/datasets/optic_disc_seg.py @@ -33,9 +33,14 @@ class OpticDiscSeg(Dataset): transforms (list): Transforms for image. dataset_root (str): The dataset directory. Default: None mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. + edge (bool): Whether to compute edge while training. Defualt: False """ - def __init__(self, dataset_root=None, transforms=None, mode='train'): + def __init__(self, + dataset_root=None, + transforms=None, + mode='train', + edge=False): self.dataset_root = dataset_root self.transforms = Compose(transforms) mode = mode.lower() @@ -43,6 +48,7 @@ def __init__(self, dataset_root=None, transforms=None, mode='train'): self.file_list = list() self.num_classes = 2 self.ignore_index = 255 + self.edge = edge if mode not in ['train', 'val', 'test']: raise ValueError( diff --git a/paddleseg/datasets/voc.py b/paddleseg/datasets/voc.py index 64511bc436..17ddc182d3 100644 --- a/paddleseg/datasets/voc.py +++ b/paddleseg/datasets/voc.py @@ -34,9 +34,10 @@ class PascalVOC(Dataset): dataset_root (str): The dataset directory. Default: None mode (str): Which part of dataset to use. it is one of ('train', 'trainval', 'trainaug', 'val'). If you want to set mode to 'trainaug', please make sure the dataset have been augmented. Default: 'train'. + edge (bool): Whether to compute edge while training. Defualt: False """ - def __init__(self, transforms, dataset_root=None, mode='train'): + def __init__(self, transforms, dataset_root=None, mode='train', edge=False): self.dataset_root = dataset_root self.transforms = Compose(transforms) mode = mode.lower() @@ -44,6 +45,7 @@ def __init__(self, transforms, dataset_root=None, mode='train'): self.file_list = list() self.num_classes = 21 self.ignore_index = 255 + self.edge = edge if mode not in ['train', 'trainval', 'trainaug', 'val']: raise ValueError( diff --git a/paddleseg/models/__init__.py b/paddleseg/models/__init__.py index 29212be0b2..2f525e8b2d 100644 --- a/paddleseg/models/__init__.py +++ b/paddleseg/models/__init__.py @@ -25,3 +25,4 @@ from .ocrnet import * from .pspnet import * from .unet import UNet +from .gscnn import GSCNN diff --git a/paddleseg/models/backbones/resnet_vd.py b/paddleseg/models/backbones/resnet_vd.py index 64a01842be..f521942e19 100644 --- a/paddleseg/models/backbones/resnet_vd.py +++ b/paddleseg/models/backbones/resnet_vd.py @@ -184,6 +184,7 @@ def __init__(self, pretrained=None): super(ResNet_vd, self).__init__() + self.conv1_logit = None # for gscnn shape stream self.layers = layers self.lr_mult_list = lr_mult_list supported_layers = [18, 34, 50, 101, 152, 200] @@ -298,6 +299,7 @@ def forward(self, inputs): y = self.conv1_1(inputs) y = self.conv1_2(y) y = self.conv1_3(y) + self.conv1_logit = y.clone() y = self.pool2d_max(y) # A feature list saves the output feature map of each stage. diff --git a/paddleseg/models/gscnn.py b/paddleseg/models/gscnn.py new file mode 100644 index 0000000000..401c5092c7 --- /dev/null +++ b/paddleseg/models/gscnn.py @@ -0,0 +1,344 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import cv2 +import numpy as np +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from paddleseg.cvlibs import manager +from paddleseg.models import layers +from paddleseg.models.backbones import resnet_vd +from paddleseg.models import deeplab +from paddleseg.utils import utils + + +@manager.MODELS.add_component +class GSCNN(nn.Layer): + """ + The GSCNN implementation based on PaddlePaddle. + + The original article refers to + Towaki Takikawa, et, al. "Gated-SCNN: Gated Shape CNNs for Semantic Segmentation" + (https://arxiv.org/pdf/1907.05740.pdf) + + Args: + num_classes (int): The unique number of target classes. + backbone (paddle.nn.Layer): Backbone network, currently support Resnet50_vd/Resnet101_vd. + backbone_indices (tuple, optional): Two values in the tuple indicate the indices of output of backbone. + Default: (0, 1, 2, 3). + aspp_ratios (tuple, optional): The dilation rate using in ASSP module. + If output_stride=16, aspp_ratios should be set as (1, 6, 12, 18). + If output_stride=8, aspp_ratios is (1, 12, 24, 36). + Default: (1, 6, 12, 18). + aspp_out_channels (int, optional): The output channels of ASPP module. Default: 256. + align_corners (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. + pretrained (str, optional): The path or url of pretrained model. Default: None. + """ + + def __init__(self, + num_classes, + backbone, + backbone_indices=(0, 1, 2, 3), + aspp_ratios=(1, 6, 12, 18), + aspp_out_channels=256, + align_corners=False, + pretrained=None): + super().__init__() + self.backbone = backbone + backbone_channels = self.backbone.feat_channels + self.head = GSCNNHead(num_classes, backbone_indices, backbone_channels, + aspp_ratios, aspp_out_channels, align_corners) + self.align_corners = align_corners + self.pretrained = pretrained + self.init_weight() + + def forward(self, x): + feat_list = self.backbone(x) + logit_list = self.head(x, feat_list, self.backbone.conv1_logit) + seg_logit, edge_logit = [ + F.interpolate( + logit, + x.shape[2:], + mode='bilinear', + align_corners=self.align_corners) for logit in logit_list + ] + return [seg_logit, (seg_logit, edge_logit), edge_logit, seg_logit] + + def init_weight(self): + if self.pretrained is not None: + utils.load_entire_model(self, self.pretrained) + + +class GSCNNHead(nn.Layer): + """ + The GSCNNHead implementation based on PaddlePaddle. + + Args: + num_classes (int): The unique number of target classes. + backbone_indices (tuple): Two values in the tuple indicate the indices of output of backbone. + the first index will be taken as a low-level feature in Decoder component; + the last one will be taken as input of ASPP component; the second to fourth + will be taken as input for GCL component. + Usually backbone consists of four downsampling stage, and return an output of + each stage. If we set it as (0, 1, 2, 3), it means taking feature map of the first + stage in backbone as low-level feature used in Decoder, feature map of the fourth + stage as input of ASPP, and the feature map of the second to fourth stage as input of GCL. + backbone_channels (tuple): The same length with "backbone_indices". It indicates the channels of corresponding index. + aspp_ratios (tuple): The dilation rates using in ASSP module. + aspp_out_channels (int): The output channels of ASPP module. + align_corners (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. + """ + + def __init__(self, num_classes, backbone_indices, backbone_channels, + aspp_ratios, aspp_out_channels, align_corners): + super().__init__() + self.backbone_indices = backbone_indices + self.align_corners = align_corners + + self.dsn1 = nn.Conv2D( + backbone_channels[backbone_indices[1]], 1, kernel_size=1) + self.dsn2 = nn.Conv2D( + backbone_channels[backbone_indices[2]], 1, kernel_size=1) + self.dsn3 = nn.Conv2D( + backbone_channels[backbone_indices[3]], 1, kernel_size=1) + + self.res1 = resnet_vd.BasicBlock(64, 64, stride=1) + self.d1 = nn.Conv2D(64, 32, kernel_size=1) + self.gate1 = GatedSpatailConv2d(32, 32) + self.res2 = resnet_vd.BasicBlock(32, 32, stride=1) + self.d2 = nn.Conv2D(32, 16, kernel_size=1) + self.gate2 = GatedSpatailConv2d(16, 16) + self.res3 = resnet_vd.BasicBlock(16, 16, stride=1) + self.d3 = nn.Conv2D(16, 8, kernel_size=1) + self.gate3 = GatedSpatailConv2d(8, 8) + self.fuse = nn.Conv2D(8, 1, kernel_size=1, bias_attr=False) + + self.cw = nn.Conv2D(2, 1, kernel_size=1, bias_attr=False) + + self.aspp = ASPPModule( + aspp_ratios=aspp_ratios, + in_channels=backbone_channels[-1], + out_channels=aspp_out_channels, + align_corners=self.align_corners, + image_pooling=True) + + self.decoder = deeplab.Decoder( + num_classes=num_classes, + in_channels=backbone_channels[0], + align_corners=self.align_corners) + + def forward(self, x, feat_list, s_input): + input_size = x.shape[-2:] + m1f = F.interpolate( + s_input, + input_size, + mode='bilinear', + align_corners=self.align_corners) + + l1, l2, l3 = [ + feat_list[self.backbone_indices[i]] + for i in range(1, len(self.backbone_indices)) + ] + s1 = F.interpolate( + self.dsn1(l1), + input_size, + mode='bilinear', + align_corners=self.align_corners) + s2 = F.interpolate( + self.dsn2(l2), + input_size, + mode='bilinear', + align_corners=self.align_corners) + s3 = F.interpolate( + self.dsn3(l3), + input_size, + mode='bilinear', + align_corners=self.align_corners) + + # Get image gradient + im_arr = x.numpy().transpose((0, 2, 3, 1)) + im_arr = ((im_arr * 0.5 + 0.5) * 255).astype(np.uint8) + canny = np.zeros((x.shape[0], 1, input_size[0], input_size[1])) + for i in range(x.shape[0]): + canny[i] = cv2.Canny(im_arr[i], 10, 100) + canny = canny / 255 + canny = paddle.to_tensor(canny).astype('float32') + canny.stop_gradient = True + + cs = self.res1(m1f) + cs = F.interpolate( + cs, input_size, mode='bilinear', align_corners=self.align_corners) + cs = self.d1(cs) + cs = self.gate1(cs, s1) + + cs = self.res2(cs) + cs = F.interpolate( + cs, input_size, mode='bilinear', align_corners=self.align_corners) + cs = self.d2(cs) + cs = self.gate2(cs, s2) + + cs = self.res3(cs) + cs = F.interpolate( + cs, input_size, mode='bilinear', align_corners=self.align_corners) + cs = self.d3(cs) + cs = self.gate3(cs, s3) + + cs = self.fuse(cs) + cs = F.interpolate( + cs, input_size, mode='bilinear', align_corners=self.align_corners) + edge_out = F.sigmoid(cs) # Ouput of shape stream + + cat = paddle.concat([edge_out, canny], axis=1) + acts = self.cw(cat) + acts = F.sigmoid(acts) # Input of fusion module + + x = self.aspp(l3, acts) + + low_level_feat = feat_list[self.backbone_indices[0]] + logit = self.decoder(x, low_level_feat) + logit_list = [logit, edge_out] + return logit_list + + +class GatedSpatailConv2d(nn.Layer): + def __init__(self, + in_channels, + out_channels, + kernel_size=1, + stride=1, + padding=0, + dilation=1, + groups=1, + bias_attr=False): + super().__init__() + self._gate_conv = nn.Sequential( + layers.SyncBatchNorm(in_channels + 1), + nn.Conv2D(in_channels + 1, in_channels + 1, kernel_size=1), + nn.ReLU(), nn.Conv2D(in_channels + 1, 1, kernel_size=1), + layers.SyncBatchNorm(1), nn.Sigmoid()) + self.conv = nn.Conv2D( + in_channels, + out_channels, + kernel_size=kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias_attr=bias_attr) + + def forward(self, input_features, gating_features): + cat = paddle.concat([input_features, gating_features], axis=1) + alphas = self._gate_conv(cat) + x = input_features * (alphas + 1) + x = self.conv(x) + return x + + +class ASPPModule(nn.Layer): + """ + Atrous Spatial Pyramid Pooling. + + Args: + aspp_ratios (tuple): The dilation rate using in ASSP module. + in_channels (int): The number of input channels. + out_channels (int): The number of output channels. + align_corners (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. + use_sep_conv (bool, optional): If using separable conv in ASPP module. Default: False. + image_pooling (bool, optional): If augmented with image-level features. Default: False + """ + + def __init__(self, + aspp_ratios, + in_channels, + out_channels, + align_corners, + use_sep_conv=False, + image_pooling=False): + super().__init__() + + self.align_corners = align_corners + self.aspp_blocks = nn.LayerList() + + for ratio in aspp_ratios: + if use_sep_conv and ratio > 1: + conv_func = layers.SeparableConvBNReLU + else: + conv_func = layers.ConvBNReLU + + block = conv_func( + in_channels=in_channels, + out_channels=out_channels, + kernel_size=1 if ratio == 1 else 3, + dilation=ratio, + padding=0 if ratio == 1 else ratio) + self.aspp_blocks.append(block) + + out_size = len(self.aspp_blocks) + + if image_pooling: + self.global_avg_pool = nn.Sequential( + nn.AdaptiveAvgPool2D(output_size=(1, 1)), + layers.ConvBNReLU( + in_channels, out_channels, kernel_size=1, bias_attr=False)) + out_size += 1 + self.image_pooling = image_pooling + + self.edge_conv = layers.ConvBNReLU( + 1, out_channels, kernel_size=1, bias_attr=False) + out_size += 1 + + self.conv_bn_relu = layers.ConvBNReLU( + in_channels=out_channels * out_size, + out_channels=out_channels, + kernel_size=1) + + self.dropout = nn.Dropout(p=0.1) # drop rate + + def forward(self, x, edge): + outputs = [] + for block in self.aspp_blocks: + y = block(x) + y = F.interpolate( + y, + x.shape[2:], + mode='bilinear', + align_corners=self.align_corners) + outputs.append(y) + + if self.image_pooling: + img_avg = self.global_avg_pool(x) + img_avg = F.interpolate( + img_avg, + x.shape[2:], + mode='bilinear', + align_corners=self.align_corners) + outputs.append(img_avg) + + edge_features = F.interpolate( + edge, + size=x.shape[2:], + mode='bilinear', + align_corners=self.align_corners) + edge_features = self.edge_conv(edge_features) + outputs.append(edge_features) + + x = paddle.concat(outputs, axis=1) + x = self.conv_bn_relu(x) + x = self.dropout(x) + return x diff --git a/paddleseg/models/losses/__init__.py b/paddleseg/models/losses/__init__.py index f58a9fe1dc..f566a58511 100644 --- a/paddleseg/models/losses/__init__.py +++ b/paddleseg/models/losses/__init__.py @@ -13,3 +13,6 @@ # limitations under the License. from .cross_entroy_loss import CrossEntropyLoss +from .binary_cross_entroy_loss import BCELoss +from .dual_task_loss import DualTaskLoss +from .edge_attention_loss import EdgeAttentionLoss diff --git a/paddleseg/models/losses/binary_cross_entroy_loss.py b/paddleseg/models/losses/binary_cross_entroy_loss.py new file mode 100644 index 0000000000..5af84b0a80 --- /dev/null +++ b/paddleseg/models/losses/binary_cross_entroy_loss.py @@ -0,0 +1,158 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from paddleseg.cvlibs import manager + + +@manager.LOSSES.add_component +class BCELoss(nn.Layer): + """ + This operator combines the sigmoid layer and the :ref:`api_nn_loss_BCELoss` layer. + Also, we can see it as the combine of ``sigmoid_cross_entropy_with_logits`` + layer and some reduce operations. + This measures the element-wise probability error in classification tasks + in which each class is independent. + This can be thought of as predicting labels for a data-point, where labels + are not mutually exclusive. For example, a news article can be about + politics, technology or sports at the same time or none of these. + First this operator calculate loss function as follows: + .. math:: + Out = -Labels * \\log(\\sigma(Logit)) - (1 - Labels) * \\log(1 - \\sigma(Logit)) + We know that :math:`\\sigma(Logit) = \\frac{1}{1 + \\e^{-Logit}}`. By substituting this we get: + .. math:: + Out = Logit - Logit * Labels + \\log(1 + \\e^{-Logit}) + For stability and to prevent overflow of :math:`\\e^{-Logit}` when Logit < 0, + we reformulate the loss as follows: + .. math:: + Out = \\max(Logit, 0) - Logit * Labels + \\log(1 + \\e^{-\|Logit\|}) + Then, if ``weight`` or ``pos_weight`` is not None, this operator multiply the + weight tensor on the loss `Out`. The ``weight`` tensor will attach different + weight on every items in the batch. The ``pos_weight`` will attach different + weight on the positive label of each class. + Finally, this operator applies reduce operation on the loss. + If :attr:`reduction` set to ``'none'``, the operator will return the original loss `Out`. + If :attr:`reduction` set to ``'mean'``, the reduced mean loss is :math:`Out = MEAN(Out)`. + If :attr:`reduction` set to ``'sum'``, the reduced sum loss is :math:`Out = SUM(Out)`. + Note that the target labels ``label`` should be numbers between 0 and 1. + Args: + weight (Tensor | str, optional): A manual rescaling weight given to the loss of each + batch element. If given, it has to be a 1D Tensor whose size is `[N, ]`, + The data type is float32, float64. If type is str, it should equal to 'dynamic'. + It will compute weight dynamically in every step. + Default is ``'None'``. + pos_weight (float|str, optional): A weight of positive examples. If type is str, + it should equal to 'dynamic'. It will compute weight dynamically in every step. + Default is ``'None'``. + ignore_index (int64): Specifies a target value that is ignored + and does not contribute to the input gradient. Default ``255``. + Shapes: + logit (Tensor): The input predications tensor. 2-D tensor with shape: [N, *], + N is batch_size, `*` means number of additional dimensions. The ``logit`` + is usually the output of Linear layer. Available dtype is float32, float64. + label (Tensor): The target labels tensor. 2-D tensor with the same shape as + ``logit``. The target labels which values should be numbers between 0 and 1. + Available dtype is float32, float64. + Returns: + A callable object of BCEWithLogitsLoss. + Examples: + .. code-block:: python + import paddle + paddle.disable_static() + logit = paddle.to_tensor([5.0, 1.0, 3.0], dtype="float32") + label = paddle.to_tensor([1.0, 0.0, 1.0], dtype="float32") + bce_logit_loss = paddle.nn.BCEWithLogitsLoss() + output = bce_logit_loss(logit, label) + print(output.numpy()) # [0.45618808] + """ + + def __init__(self, weight=None, pos_weight=None, ignore_index=255): + super().__init__() + self.weight = weight + self.pos_weight = pos_weight + self.ignore_index = ignore_index + + if self.weight is not None: + if isinstance(self.weight, str): + if self.weight != 'dynamic': + raise ValueError( + "if type of `weight` is str, it should equal to 'dynamic', but it is {}" + .format(self.weight)) + elif isinstance(self.weight, paddle.VarBase): + raise TypeError( + 'The type of `weight` is wrong, it should be Tensor or str, but it is {}' + .format(type(self.pos_weight))) + + if self.pos_weight is not None: + if isinstance(self.pos_weight, str): + if self.pos_weight != 'dynamic': + raise ValueError( + "if type of `pos_weight` is str, it should equal to 'dynamic', but it is {}" + .format(self.pos_weight)) + elif isinstance(self.pos_weight, float): + self.pos_weight = paddle.to_tensor( + self.pos_weight, dtype='float32') + else: + raise TypeError( + 'The type of `pos_weight` is wrong, it should be float or str, but it is {}' + .format(type(self.pos_weight))) + + def forward(self, logit, label): + """ + Forward computation. + + Args: + logit (Tensor): Logit tensor, the data type is float32, float64. Shape is + (N, C), where C is number of classes, and if shape is more than 2D, this + is (N, C, D1, D2,..., Dk), k >= 1. + label (Tensor): Label tensor, the data type is int64. Shape is (N, C), where each + value is 0 or 1, and if shape is more than 2D, this is + (N, C, D1, D2,..., Dk), k >= 1. + """ + eps = 1e-6 + if len(label.shape) != len(logit.shape): + label = paddle.unsqueeze(1) + mask = (label != self.ignore_index).astype('float32') + if isinstance(self.weight, str): + pos_index = (label == 1) + neg_index = (label == 0) + pos_num = paddle.sum(pos_index.astype('float32')) + neg_num = paddle.sum(neg_index.astype('float32')) + sum_num = pos_num + neg_num + weight_pos = 2 * neg_num / (sum_num + eps) + weight_neg = 2 * pos_num / (sum_num + eps) + self.weight = weight_pos * label + weight_neg * (1 - label) + if isinstance(self.pos_weight, str): + pos_index = (label == 1) + neg_index = (label == 0) + pos_num = paddle.sum(pos_index.astype('float32')) + neg_num = paddle.sum(neg_index.astype('float32')) + sum_num = pos_num + neg_num + self.pos_weight = 2 * neg_num / (sum_num + eps) + label = label.astype('float32') + loss = paddle.nn.functional.binary_cross_entropy_with_logits( + logit, + label, + weight=self.weight, + reduction='none', + pos_weight=self.pos_weight) + loss = loss * mask + loss = paddle.mean(loss) / paddle.mean(mask) + label.stop_gradient = True + mask.stop_gradient = True + + return loss diff --git a/paddleseg/models/losses/dual_task_loss.py b/paddleseg/models/losses/dual_task_loss.py new file mode 100644 index 0000000000..964cecc82b --- /dev/null +++ b/paddleseg/models/losses/dual_task_loss.py @@ -0,0 +1,139 @@ +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import paddle +import paddle.nn as nn +import paddle.nn.functional as F + +from paddleseg.cvlibs import manager + + +@manager.LOSSES.add_component +class DualTaskLoss(nn.Layer): + """ + The dual task loss implement of GSCNN + + Args: + ignore_index (int64): Specifies a target value that is ignored + and does not contribute to the input gradient. Default ``255``. + tau (float): the tau of gumbel softmax sample. + """ + + def __init__(self, ignore_index=255, tau=0.5): + super().__init__() + self.ignore_index = ignore_index + self.tau = tau + + def _gumbel_softmax_sample(self, logit, tau=1, eps=1e-10): + """ + Draw a sample from the Gumbel-Softmax distribution + + based on + https://github.com/ericjang/gumbel-softmax/blob/3c8584924603869e90ca74ac20a6a03d99a91ef9/Categorical%20VAE.ipynb + (MIT license) + """ + gumbel_noise = paddle.rand(logit.shape) + gumbel_noise = -paddle.log(eps - paddle.log(gumbel_noise + eps)) + logit = logit + gumbel_noise + return F.softmax(logit / tau, axis=1) + + def compute_grad_mag(self, x): + eps = 1e-6 + n, c, h, w = x.shape + if h <= 1 or w <= 1: + raise ValueError( + 'The width and height of tensor to compute grad must be greater than 1, but the shape is {}.' + .format(x.shape)) + + x = self.conv_tri(x, r=4) + kernel = [[-1, 0, 1]] + kernel = paddle.to_tensor(kernel).astype('float32') + kernel = 0.5 * kernel + + kernel_x = paddle.concat([kernel.unsqueeze((0, 1))] * c, axis=0) + grad_x = F.conv2d(x, kernel_x, padding='same', groups=c) + kernel_y = paddle.concat([kernel.t().unsqueeze((0, 1))] * c, axis=0) + grad_y = F.conv2d(x, kernel_y, padding='same', groups=c) + mag = paddle.sqrt(grad_x * grad_x + grad_y * grad_y + eps) + + return mag / mag.max() + + def conv_tri(self, input, r): + """ + Convolves an image by a 2D triangle filter (the 1D triangle filter f is + [1:r r+1 r:-1:1]/(r+1)^2, the 2D version is simply conv2(f,f')) + """ + if r <= 1: + raise ValueError( + '`r` should be greater than 1, but it is {}.'.format(r)) + + kernel = [ + list(range(1, r + 1)) + [r + 1] + list(reversed(range(1, r + 1))) + ] + kernel = paddle.to_tensor(kernel).astype('float32') + kernel = kernel / (r + 1)**2 + input_ = F.pad(input, [1, 1, 0, 0], mode='replicate') + input_ = F.pad(input_, [r, r, 0, 0], mode='reflect') + input_ = [input_[:, :, :, :r], input, input_[:, :, :, -r:]] + input_ = paddle.concat(input_, axis=3) + tem = input_.clone() + + input_ = F.pad(input_, [0, 0, 1, 1], mode='replicate') + input_ = F.pad(input_, [0, 0, r, r], mode='reflect') + input_ = [input_[:, :, :r, :], tem, input_[:, :, -r:, :]] + input_ = paddle.concat(input_, axis=2) + + c = input.shape[1] + kernel_x = paddle.concat([kernel.unsqueeze((0, 1))] * c, axis=0) + output = F.conv2d(input_, kernel_x, padding=0, groups=c) + kernel_y = paddle.concat([kernel.t().unsqueeze((0, 1))] * c, axis=0) + output = F.conv2d(output, kernel_y, padding=0, groups=c) + return output + + def forward(self, logit, labels): + # import pdb; pdb.set_trace() + n, c, h, w = logit.shape + th = 1e-8 + eps = 1e-10 + mask = (labels != self.ignore_index) + mask.stop_gradient = True + logit = logit * mask + + labels = labels * mask + if len(labels.shape) == 4: + labels = labels.squeeze(1) + labels.stop_gradient = True + labels = F.one_hot(labels, logit.shape[1]).transpose((0, 3, 1, 2)) + labels.stop_gradient = True + + g = self._gumbel_softmax_sample(logit, tau=self.tau) + g = self.compute_grad_mag(g) + g_hat = self.compute_grad_mag(labels) + loss = F.l1_loss(g, g_hat, reduction='none') + loss = loss * mask + + g_mask = (g > th).astype('float32') + g_mask.stop_gradient = True + g_mask_sum = paddle.sum(g_mask) + loss_g = paddle.sum(loss * g_mask) + if g_mask_sum > eps: + loss_g = loss_g / g_mask_sum + + g_hat_mask = (g_hat > th).astype('float32') + g_hat_mask.stop_gradient = True + g_hat_mask_sum = paddle.sum(g_hat_mask) + loss_g_hat = paddle.sum(loss * g_hat_mask) + if g_hat_mask_sum > eps: + loss_g_hat = loss_g_hat / g_hat_mask_sum + + total_loss = 0.5 * loss_g + 0.5 * loss_g_hat + + return total_loss diff --git a/paddleseg/models/losses/edge_attention_loss.py b/paddleseg/models/losses/edge_attention_loss.py new file mode 100644 index 0000000000..1fe8b8d8f6 --- /dev/null +++ b/paddleseg/models/losses/edge_attention_loss.py @@ -0,0 +1,75 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import paddle +from paddle import nn +import paddle.nn.functional as F + +from paddleseg.cvlibs import manager +from paddleseg.models import losses + + +@manager.LOSSES.add_component +class EdgeAttentionLoss(nn.Layer): + """ + Implements the cross entropy loss function. It only compute the edge part. + + Args: + edge_threshold (float): The pixels greater edge_threshold as edges. + ignore_index (int64): Specifies a target value that is ignored + and does not contribute to the input gradient. Default ``255``. + """ + + def __init__(self, edge_threshold=0.8, ignore_index=255): + super().__init__() + self.edge_threshold = edge_threshold + self.ignore_index = ignore_index + self.EPS = 1e-5 + + def forward(self, logits, label): + """ + Forward computation. + + Args: + logits (tuple|list): (seg_logit, edge_logit) Tensor, the data type is float32, float64. Shape is + (N, C), where C is number of classes, and if shape is more than 2D, this + is (N, C, D1, D2,..., Dk), k >= 1. C =1 of edge_logit . + label (Tensor): Label tensor, the data type is int64. Shape is (N, C), where each + value is 0 <= label[i] <= C-1, and if shape is more than 2D, this is + (N, C, D1, D2,..., Dk), k >= 1. + """ + seg_logit, edge_logit = logits[0], logits[1] + if len(label.shape) != len(seg_logit.shape): + label = paddle.unsqueeze(label, 1) + if edge_logit.shape != label.shape: + raise ValueError( + 'The shape of edge_logit should equal to the label, but they are {} != {}' + .format(edge_logit.shape, label.shape)) + + filler = paddle.ones_like(label) * self.ignore_index + label = paddle.where(edge_logit > self.edge_threshold, label, filler) + + seg_logit = paddle.transpose(seg_logit, [0, 2, 3, 1]) + label = paddle.transpose(label, [0, 2, 3, 1]) + loss = F.softmax_with_cross_entropy( + seg_logit, label, ignore_index=self.ignore_index, axis=-1) + + mask = label != self.ignore_index + mask = paddle.cast(mask, 'float32') + loss = loss * mask + avg_loss = paddle.mean(loss) / (paddle.mean(mask) + self.EPS) + + label.stop_gradient = True + mask.stop_gradient = True + return avg_loss diff --git a/paddleseg/transforms/functional.py b/paddleseg/transforms/functional.py index d3a9c2d3fe..d53fa8b84f 100644 --- a/paddleseg/transforms/functional.py +++ b/paddleseg/transforms/functional.py @@ -15,6 +15,7 @@ import cv2 import numpy as np from PIL import Image, ImageEnhance +from scipy.ndimage.morphology import distance_transform_edt def normalize(im, mean, std): @@ -92,3 +93,68 @@ def rotate(im, rotate_lower, rotate_upper): rotate_delta = np.random.uniform(rotate_lower, rotate_upper) im = im.rotate(int(rotate_delta)) return im + + +def mask_to_onehot(mask, num_classes): + """ + Convert a mask (H, W) to onehot (K, H, W). + + Args: + mask (np.ndarray): Label mask with shape (H, W) + num_classes (int): Number of classes. + + Returns: + np.ndarray: Onehot mask with shape(K, H, W). + """ + _mask = [mask == i for i in range(num_classes)] + _mask = np.array(_mask).astype(np.uint8) + return _mask + + +def onehot_to_binary_edge(mask, radius): + """ + Convert a onehot mask (K, H, W) to a edge mask. + + Args: + mask (np.ndarray): Onehot mask with shape (K, H, W) + radius (int|float): Radius of edge. + + Returns: + np.ndarray: Edge mask with shape(H, W). + """ + if radius < 1: + raise ValueError('`radius` should be greater than or equal to 1') + num_classes = mask.shape[0] + + edge = np.zeros(mask.shape[1:]) + # pad borders + mask = np.pad( + mask, ((0, 0), (1, 1), (1, 1)), mode='constant', constant_values=0) + for i in range(num_classes): + dist = distance_transform_edt( + mask[i, :]) + distance_transform_edt(1.0 - mask[i, :]) + dist = dist[1:-1, 1:-1] + dist[dist > radius] = 0 + edge += dist + + edge = np.expand_dims(edge, axis=0) + edge = (edge > 0).astype(np.uint8) + return edge + + +def mask_to_binary_edge(mask, radius, num_classes): + """ + Convert a segmentic segmentation mask (H, W) to a binary edge mask(H, W). + + Args: + mask (np.ndarray): Label mask with shape (H, W) + radius (int|float): Radius of edge. + num_classes (int): Number of classes. + + Returns: + np.ndarray: Edge mask with shape(H, W). + """ + mask = mask.squeeze() + onehot = mask_to_onehot(mask, num_classes) + edge = onehot_to_binary_edge(onehot, radius) + return edge From 431b218a591cbd56d331bccec1b66ca5723b4dfe Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 7 Dec 2020 15:47:55 +0800 Subject: [PATCH 20/35] add gscnn --- README.md | 1 + README_CN.md | 1 + configs/gscnn/README.md | 2 +- paddleseg/datasets/ade.py | 2 +- paddleseg/datasets/cityscapes.py | 2 +- paddleseg/datasets/dataset.py | 2 +- paddleseg/datasets/optic_disc_seg.py | 2 +- paddleseg/datasets/voc.py | 2 +- 8 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4e3b056e38..2f09f2502f 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ The full-detailed documents and tutorials are coming soon. So far there are mini |[Fast-SCNN](./configs/fastscnn)|-|-|-|-| |[FCN](./configs/fcn)|||✔|✔| |[GCNet](./configs/gcnet)|✔|✔||| +|[GSCNN](./configs/gscnn)|✔|✔||| |[OCRNet](./configs/ocrnet/)|||✔|✔| |[PSPNet](./configs/pspnet)|✔|✔||| |[UNet](./configs/unet)|-|-|-|-| diff --git a/README_CN.md b/README_CN.md index 7f8a8b1e15..01e2507831 100644 --- a/README_CN.md +++ b/README_CN.md @@ -16,6 +16,7 @@ |[Fast-SCNN](./configs/fastscnn)|-|-|-|-| |[FCN](./configs/fcn)|||✔|✔| |[GCNet](./configs/gcnet)|✔|✔||| +|[GSCNN](./configs/gscnn)|✔|✔||| |[OCRNet](./configs/ocrnet/)|||✔|✔| |[PSPNet](./configs/pspnet)|✔|✔||| |[UNet](./configs/unet)|-|-|-|-| diff --git a/configs/gscnn/README.md b/configs/gscnn/README.md index a3806879f9..81e99c7c96 100644 --- a/configs/gscnn/README.md +++ b/configs/gscnn/README.md @@ -10,4 +10,4 @@ | Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|GSCNN|ResNet50_OS8|1024x512|80000|80.67%|80.88%|80.88%|[model](https://bj.bcebos.com/paddleseg/dygraph/cutyscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cutyscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=11b79b6a2899739c0d009b1ce34bad77)| +|GSCNN|ResNet50_OS8|1024x512|80000|80.67%|80.88%|80.88%|[model](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/cityscapes/gscnn_resnet50_os8_cityscapes_1024x512_80k/train.log) \| [vdl](https://paddlepaddle.org.cn/paddle/visualdl/service/app?id=11b79b6a2899739c0d009b1ce34bad77)| diff --git a/paddleseg/datasets/ade.py b/paddleseg/datasets/ade.py index 72620d2d87..5ace6a3e56 100644 --- a/paddleseg/datasets/ade.py +++ b/paddleseg/datasets/ade.py @@ -36,7 +36,7 @@ class ADE20K(Dataset): transforms (list): A list of image transformations. dataset_root (str, optional): The ADK20K dataset directory. Default: None. mode (str, optional): A subset of the entire dataset. It should be one of ('train', 'val'). Default: 'train'. - edge (bool): Whether to compute edge while training. Defualt: False + edge (bool): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root=None, mode='train', edge=False): diff --git a/paddleseg/datasets/cityscapes.py b/paddleseg/datasets/cityscapes.py index af7c122426..7d3659bd6f 100644 --- a/paddleseg/datasets/cityscapes.py +++ b/paddleseg/datasets/cityscapes.py @@ -44,7 +44,7 @@ class Cityscapes(Dataset): transforms (list): Transforms for image. dataset_root (str): Cityscapes dataset directory. mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. - edge (bool): Whether to compute edge while training. Defualt: False + edge (bool): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root, mode='train', edge=False): diff --git a/paddleseg/datasets/dataset.py b/paddleseg/datasets/dataset.py index 10decc1c05..7ac6098693 100644 --- a/paddleseg/datasets/dataset.py +++ b/paddleseg/datasets/dataset.py @@ -42,7 +42,7 @@ class Dataset(paddle.io.Dataset): test_path (str): The test dataset file. When mode is 'test', test_path is necessary. The annotation file is not necessary in test_path file. separator (str): The separator of dataset list. Default: ' '. - edge (bool): Whether to compute edge while training. Defualt: False + edge (bool): Whether to compute edge while training. Default: False Examples: diff --git a/paddleseg/datasets/optic_disc_seg.py b/paddleseg/datasets/optic_disc_seg.py index dfb8806d5c..cad32a3307 100644 --- a/paddleseg/datasets/optic_disc_seg.py +++ b/paddleseg/datasets/optic_disc_seg.py @@ -33,7 +33,7 @@ class OpticDiscSeg(Dataset): transforms (list): Transforms for image. dataset_root (str): The dataset directory. Default: None mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. - edge (bool): Whether to compute edge while training. Defualt: False + edge (bool): Whether to compute edge while training. Default: False """ def __init__(self, diff --git a/paddleseg/datasets/voc.py b/paddleseg/datasets/voc.py index 17ddc182d3..dc5bf6c8b1 100644 --- a/paddleseg/datasets/voc.py +++ b/paddleseg/datasets/voc.py @@ -34,7 +34,7 @@ class PascalVOC(Dataset): dataset_root (str): The dataset directory. Default: None mode (str): Which part of dataset to use. it is one of ('train', 'trainval', 'trainaug', 'val'). If you want to set mode to 'trainaug', please make sure the dataset have been augmented. Default: 'train'. - edge (bool): Whether to compute edge while training. Defualt: False + edge (bool): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root=None, mode='train', edge=False): From 0e5f8936fb1b0cc7ca1763e30a66069ae2dff705 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Wed, 16 Dec 2020 11:51:08 +0800 Subject: [PATCH 21/35] add apis docs --- docs/apis/backbones.md | 182 +++++++ docs/apis/core.md | 72 +++ docs/apis/cvlibs.md | 179 +++++++ docs/apis/datasets.md | 106 ++++ docs/apis/models.md | 430 +++++++++++++++-- docs/apis/transforms.md | 183 +++++++ paddleseg/core/predict.py | 15 +- paddleseg/core/train.py | 19 + paddleseg/core/val.py | 21 + paddleseg/cvlibs/param_init.py | 3 + paddleseg/datasets/ade.py | 2 +- paddleseg/datasets/cityscapes.py | 4 +- paddleseg/datasets/dataset.py | 12 +- paddleseg/datasets/optic_disc_seg.py | 4 +- paddleseg/datasets/voc.py | 4 +- paddleseg/models/backbones/hrnet.py | 44 +- paddleseg/models/backbones/mobilenetv3.py | 16 +- paddleseg/models/backbones/resnet_vd.py | 35 +- .../models/backbones/xception_deeplab.py | 21 +- paddleseg/models/u2net.py | 452 +++++++++--------- 20 files changed, 1469 insertions(+), 335 deletions(-) diff --git a/docs/apis/backbones.md b/docs/apis/backbones.md index e69de29bb2..632ffac587 100644 --- a/docs/apis/backbones.md +++ b/docs/apis/backbones.md @@ -0,0 +1,182 @@ +# paddleseg.models.backbone + +The models subpackage contains backbones extracting features for sementic segmentation models. + +- [ResNet_vd](#ResNet_vd) +- [HRNet](#HRNet) +- [MobileNetV3](#MobileNetV3) +- [Xception_deeplab](Xception_deeplab) + + +## [ResNet_vd](../../paddleseg/models/backbones/resnet_vd.py) +ResNet_vd backbone from ["Bag of Tricks for Image Classification with Convolutional Neural Networks"](https://arxiv.org/pdf/1812.01187.pdf) + +> CLASS paddleseg.models.backbones.Resnet_vd(layers=50, output_stride=None, multi_grid=(1, 1, 1), lr_mult_list=(0.1, 0.1, 0.2, 0.2), pretrained=None) + +> > Args +> > > - **layers** (int, optional): The layers of ResNet_vd. The supported layers are [18, 34, 50, 101, 152, 200]. Default: 50. +> > > - **output_stride** (int, optional): The stride of output features compared to input images. It is 8 or 16. Default: 8. +> > > - **multi_grid** (tuple|list, optional): The grid of stage4. Defult: (1, 1, 1). +> > > - **pretrained** (str, optional): The path of pretrained model. + +> paddleseg.models.backbones.ResNet18_vd(**args) + + Return a object of ResNet_vd class which layers is 18. + +> paddleseg.models.backbones.ResNet34_vd(**args) + + Return a object of ResNet_vd class which layers is 34. + +> paddleseg.models.backbones.ResNet50_vd(**args) + + Return a object of ResNet_vd class which layers is 50. + +> paddleseg.models.backbones.ResNet101_vd(**args) + + Return a object of ResNet_vd class which layers is 101. + +> paddleseg.models.backbones.ResNet152_vd(**args) + + Return a object of ResNet_vd class which layers is 152. + +> padddelseg.models.backbones.ResNet200_vd(**args) + + Return a object of ResNet_vd class which layers is 200. + +## [HRNet](../../paddleseg/models/backbones/hrnet.py) +HRNet backbone from ["HRNet:Deep High-Resolution Representation Learning for Visual Recognition"](https://arxiv.org/pdf/1908.07919.pdf) + +> CLASS paddleseg.models.backbones.HRNet(pretrained=None, stage1_num_modules=1, stage1_num_blocks=(4,), stage1_num_channels=(64,), stage2_num_modules=1, stage2_num_blocks=(4, 4), stage2_num_channels=(18, 36), stage3_num_modules=4, stage3_num_blocks=(4, 4, 4), stage3_num_channels=(18, 36, 72), stage4_num_modules=3, stage4_num_blocks=(4, 4, 4, 4), stage4_num_channels=(18, 36, 72, 14), has_se=False, align_corners=False) + +> > Args +> > > - **pretrained** (str, optional): The path of pretrained model. +> > > - **stage1_num_modules** (int, optional): Number of modules for stage1. Default 1. +> > > - **stage1_num_blocks** (list, optional): Number of blocks per module for stage1. Default (4,). +> > > - **stage1_num_channels** (list, optional): Number of channels per branch for stage1. Default (64,). +> > > - **stage2_num_modules** (int, optional): Number of modules for stage2. Default 1. +> > > - **stage2_num_blocks** (list, optional): Number of blocks per module for stage2. Default (4, 4). +> > > - **stage2_num_channels** (list, optional): Number of channels per branch for stage2. Default (18, 36). +> > > - **stage3_num_modules** (int, optional): Number of modules for stage3. Default 4. +> > > - **stage3_num_blocks** (list, optional): Number of blocks per module for stage3. Default (4, 4, 4). +> > > - **stage3_num_channels** (list, optional): Number of channels per branch for stage3. Default (18, 36, 72). +> > > - **stage4_num_modules** (int, optional): Number of modules for stage4. Default 3. +> > > - **stage4_num_blocks** (list, optional): Number of blocks per module for stage4. Default (4, 4, 4, 4). +> > > - **stage4_num_channels** (list, optional): Number of channels per branch for stage4. Default (18, 36, 72. 144). +> > > - **has_se** (bool, optional): Whether to use Squeeze-and-Excitation module. Default False. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. + +> paddleseg.models.backbones.HRNet_W18_Small_V1(**kwargs) + + Return a object of HRNet class which width is 18 and it is smaller than HRNet_W18_Small_V2. + +> paddleseg.models.backbones.HRNet_W18_Small_V2(**kwargs) + + Return a object of HRNet class which width is 18 and it is smaller than HRNet_W18. + +> paddleseg.models.backbones.HRNet_W18(**kwargs) + + Return a object of HRNet class which width is 18. + +> paddleseg.models.backbones.HRNet_W30(**kwargs) + + Return a object of HRNet class which width is 30. + +> paddleseg.models.backbones.HRNet_W32(**kwargs) + + Return a object of HRNet class which width is 32. + +> paddleseg.models.backbones.HRNet_W40(**kwargs) + + Return a object of HRNet class which width is 40. + +> paddleseg.models.backbones.HRNet_W44(**kwargs) + + Return a object of HRNet class which width is 44. + +> paddleseg.models.backbones.HRNet_W48(**kwargs) + + Return a object of HRNet class which width is 48. + +> paddleseg.models.backbones.HRNet_W60(**kwargs) + + Return a object of HRNet class which width is 60. + +> paddleseg.models.backbones.HRNet_W64(**kwargs) + + Return a object of HRNet class which width is 64. + + + +## [MobileNetV3](../../paddleseg/models/backbones/mobilenetv3.py) +MobileNetV3 backbone from ["Searching for MobileNetV3"](https://arxiv.org/pdf/1905.02244.pdf). + +> CLASS paddleseg.models.backbones.MobileNetV3(pretrained=None, scale=1.0, model_name="small", output_stride=None) +> > Args +> > > - **pretrained** (str, optional): The path of pretrained model. +> > > - **scale** (float, optional): The scale of channels . Default: 1.0. +> > > - **model_name** (str, optional): Model name. It determines the type of MobileNetV3. The value is 'small' or 'large'. Defualt: 'small'. +> > > - **output_stride** (int, optional): The stride of output features compared to input images. The value should be one of [2, 4, 8, 16, 32]. Default: None. + +> paddleseg.models.backbones.MobileNetV3_small_x0_35(**args) + + Return a object of MobileNetV3 class which scale is 0.35 and model_name is small. + +> paddleseg.models.backbones.MobileNetV3_small_x0_5(**args) + + Return a object of MobileNetV3 class which scale is 0.5 and model_name is small. + +> paddleseg.models.backbones.MobileNetV3_small_x0_75(**args) + + Return a object of MobileNetV3 class which scale is 0.75 and model_name is small. + +> paddleseg.models.backbones.MobileNetV3_small_x1_0(**args) + + Return a object of MobileNetV3 class which scale is 1.0 and model_name is small. + +> paddleseg.models.backbones.MobileNetV3_small_x1_25(**args) + + Return a object of MobileNetV3 class which scale is 1.25 and model_name is small. + +> paddleseg.models.backbones.MobileNetV3_large_x0_35(**args) + + Return a object of MobileNetV3 class which scale is 0.35 and model_name is large. + +> paddleseg.models.backbones.MobileNetV3_large_x0_5(**args) + + Return a object of MobileNetV3 class which scale is 0.5 and model_name is large. + +> paddleseg.models.backbones.MobileNetV3_large_x0_75(**args) + + Return a object of MobileNetV3 class which scale is 0.75 and model_name is large. + +> paddleseg.models.backbones.MobileNetV3_large_x1_0(**args) + + Return a object of MobileNetV3 class which scale is 1.0 and model_name is large. + +> paddleseg.models.backbones.MobileNetV3_large_x1_25(**args) + + Return a object of MobileNetV3 class which scale is 1.25 and model_name is large. + + +## [XceptionDeeplab](../../paddleseg/models/backbones/xception_deeplab.py) +Xception backbone of DeepLabV3+ from ["Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation"](https://arxiv.org/abs/1802.02611) + +> CLASS paddleseg.models.backbones.XceptionDeeplab(backbone, pretrained=None, output_stride=16) + +> > Args +> > > - **backbone** (str): Which type of Xception_DeepLab to select. It should be one of ('xception_41', 'xception_65', 'xception_71'). +> > > - **pretrained** (str, optional): The path of pretrained model. +> > > - **output_stride** (int, optional): The stride of output features compared to input images. It is 8 or 16. Default: 16. + +> paddleseg.models.backbones.Xception41_deeplab(**args) + + Return a object of XceptionDeeplab class which layers is 41. + +> paddleseg.models.backbones.Xception65_deeplab(**args) + + Return a object of XceptionDeeplab class which layers is 65. + +> paddleseg.models.backbones.Xception71_deeplab(**args) + + Return a object of XceptionDeeplab class which layers is 71. diff --git a/docs/apis/core.md b/docs/apis/core.md index e69de29bb2..86acd380e8 100644 --- a/docs/apis/core.md +++ b/docs/apis/core.md @@ -0,0 +1,72 @@ +# paddleseg.core + +The interface for training, evaluation and prediction. +- [Training](#Training) +- [Evaluation](#Evaluation) +- [Prediction](#Prediction) + +## [Training](../../paddleseg/core/train.py) +> paddleseg.core.train(model, train_dataset, val_dataset=None, optimizer=None, save_dir='output', iters=10000, batch_size=2, resume_model=None, save_interval=1000, log_iters=10, num_workers=0, use_vdl=False, losses=None) + + Launch training. + +> Args +> > - **mode**l(nn.Layer): A sementic segmentation model. +> > - **train_dataset** (paddle.io.Dataset): Used to read and process training datasets. +> > - **val_dataset** (paddle.io.Dataset, optional): Used to read and process validation datasets. +> > - **optimizer** (paddle.optimizer.Optimizer): The optimizer. +> > - **save_dir** (str, optional): The directory for saving the model snapshot. Default: 'output'. +> > - **iters** (int, optional): How may iters to train the model. Defualt: 10000. +> > - **batch_size** (int, optional): Mini batch size of one gpu or cpu. Default: 2. +> > - **resume_model** (str, optional): The path of resume model. +> > - **save_interval** (int, optional): How many iters to save a model snapshot once during training. Default: 1000. +> > - **log_iters** (int, optional): Display logging information at every log_iters. Default: 10. +> > - **num_workers** (int, optional): Num workers for data loader. Default: 0. +> > - **use_vdl** (bool, optional): Whether to record the data to VisualDL during training. Default: False. +> > - **losses** (dict): A dict including 'types' and 'coef'. The length of coef should equal to 1 or len(losses['types']). + The 'types' item is a list of object of paddleseg.models.losses while the 'coef' item is a list of the relevant coefficient. + +## [Evaluation](../../paddleseg/core/val.py) +> paddleseg.core.evaluate(model, eval_dataset, aug_eval=False, scales=1.0, flip_horizontal=True, flip_vertical=False, is_slide=False, stride=None, crop_size=None, num_workers=0) + + Launch evaluation. + +> Args +> > - **model**(nn.Layer): A sementic segmentation model. +> > - **eval_dataset** (paddle.io.Dataset): Used to read and process validation datasets. +> > - **aug_eval** (bool, optional): Whether to use mulit-scales and flip augment for evaluation. Default: False. +> > - **scales** (list|float, optional): Scales for augment. It is valid when `aug_eval` is True. Default: 1.0. +> > - **flip_horizontal** (bool, optional): Whether to use flip horizontally augment. It is valid when `aug_eval` is True. Default: True. +> > - **flip_vertical** (bool, optional): Whether to use flip vertically augment. It is valid when `aug_eval` is True. Default: False. +> > - **is_slide** (bool, optional): Whether to evaluate by sliding window. Default: False. +> > - **stride** (tuple|list, optional): The stride of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. +> > - **crop_size** (tuple|list, optional): The crop size of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. +> > - **num_workers** (int, optional): Num workers for data loader. Default: 0. + +> Returns +> > - **float**: The mIoU of validation datasets. +> > - **float**: The accuracy of validation datasets. + +## [Prediction](../../paddleseg/core/predict.py) + +> paddleseg.core.predict(model, model_path, transforms, image_list, image_dir=None, save_dir='output', aug_pred=False, scales=1.0, flip_horizontal=True, flip_vertical=False, is_slide=False, stride=None, crop_size=None) + + Launch predict and visualize. + +> Args +> > - **model** (nn.Layer): Used to predict for input image. +> > - **model_path** (str): The path of pretrained model. +> > - **transforms** (transform.Compose): Preprocess for input image. +> > - **image_list** (list): A list of image path to be predicted. +> > - **image_dir** (str, optional): The root directory of the images predicted. Default: None. +> > - **save_dir**** (bool, optional): Whether to use mulit-scales and flip augment for predition. Default: False. +> > - **scales** (list|float, optional): Scales for augment. It is valid when `aug_pred` is True. Default: 1.0. +> > - **flip_horizontal** (bool, optional): Whether to use flip horizontally augment. It is valid when `aug_pred` is True. Default: True. +> > - **flip_vertical** (bool, optional): Whether to use flip vertically augment. It is valid when `aug_pred` is True. Default: False. +> > - **is_slide** (bool, optional): Whether to predict by sliding window. Default: False. +> > - **stride** (tuple|list, optional): The stride of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. +> > - **crop_size** (tuple|list, optional): The crop size of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. diff --git a/docs/apis/cvlibs.md b/docs/apis/cvlibs.md index e69de29bb2..fb73819bc0 100644 --- a/docs/apis/cvlibs.md +++ b/docs/apis/cvlibs.md @@ -0,0 +1,179 @@ +# paddleseg.cvlibs + +- [Manager](#Manager) +- [Parameters Initialization](#Parameters Initialization) +- [Config](#Config) + + +## [Manager](../../paddleseg/cvlibs/manager.py) +> CLASS paddleseg.cvlibs.manager.ComponentManager(name) + + Implement a manager class to add the new component properly. + The component can be added as either class or function type. + +> > Args +> > > - **name** (str): The name of component. + +> > Examples 1 + +```python +from paddleseg.cvlibs.manager import ComponentManager + +model_manager = ComponentManager() + +class AlexNet: ... +class ResNet: ... + +model_manager.add_component(AlexNet) +model_manager.add_component(ResNet) + +# Or pass a sequence alliteratively: +model_manager.add_component([AlexNet, ResNet]) +print(model_manager.components_dict) +# {'AlexNet': , 'ResNet': } +``` + +> > Examples 2: + +```python +# Or an easier way, using it as a Python decorator, while just add it above the class declaration. +from paddleseg.cvlibs.manager import ComponentManager + +model_manager = ComponentManager() + +@model_manager.add_component +class AlexNet: ... + +@model_manager.add_component +class ResNet: ... + +print(model_manager.components_dict) +# {'AlexNet': , 'ResNet': } +``` + +> > add_component(components) + + Add component(s) into the corresponding manager. + +> > > Args +> > > > - **components** (function|class|list|tuple): Support four types of components. +> > Returns +> > > > - **components** (function|class|list|tuple): Same with input components. + +## [Parameters Initialization](../../paddleseg/cvlibs/param_init.py) +initialization method + +### Constant Initialization + +> constant_init(param, **kwargs): + + Initialize the `param` with constants. + +> > Args +> > > - **param** (Tensor): Tensor that needs to be initialized. + +> > Examples + +```python +from paddleseg.cvlibs import param_init +import paddle.nn as nn + +linear = nn.Linear(2, 4) +param_init.constant_init(linear.weight, value=2.0) +print(linear.weight.numpy()) +# result is [[2. 2. 2. 2.], [2. 2. 2. 2.]] +``` + +### Normal Initialization +> normal_init(param, **kwargs) + + Initialize the `param` with a Normal distribution. + +> > Args +> > > - **param** (Tensor): Tensor that needs to be initialized. + +> > Examples + +```python +from paddleseg.cvlibs import param_init +import paddle.nn as nn + +linear = nn.Linear(2, 4) +param_init.normal_init(linear.weight, loc=0.0, scale=1.0) +``` + +### Kaiming Normal Initialization +> kaiming_normal_init(param, **kwargs): + + Initialize the input tensor with Kaiming Normal initialization. + + This function implements the `param` initialization from the paper + `Delving Deep into Rectifiers: Surpassing Human-Level Performance on + ImageNet Classification ` + by Kaiming He, Xiangyu Zhang, Shaoqing Ren and Jian Sun. This is a + robust initialization method that particularly considers the rectifier + nonlinearities. In case of Uniform distribution, the range is [-x, x], where + .. math:: + x = \sqrt{\\frac{6.0}{fan\_in}} + In case of Normal distribution, the mean is 0 and the standard deviation + is + .. math:: + \sqrt{\\frac{2.0}{fan\_in}} + +> > Args +> > > - **param** (Tensor): Tensor that needs to be initialized. + +> > Examples + +```python +from paddleseg.cvlibs import param_init +import paddle.nn as nn + +linear = nn.Linear(2, 4) +# uniform is used to decide whether to use uniform or normal distribution +param_init.kaiming_normal_init(linear.weight) +``` + +## [Config](../../paddleseg/cvlibs/config.py) +> CLASS Config(path, learning_rate, batch_size, iters) + + Training configuration parsing. The only yaml/yml file is supported. + + The following hyper-parameters are available in the config file: + batch_size: The number of samples per gpu. + iters: The total training steps. + train_dataset: A training data config including type/data_root/transforms/mode. + For data type, please refer to paddleseg.datasets. + For specific transforms, please refer to paddleseg.transforms.transforms. + val_dataset: A validation data config including type/data_root/transforms/mode. + optimizer: A optimizer config, but currently PaddleSeg only supports sgd with momentum in config file. + In addition, weight_decay could be set as a regularization. + learning_rate: A learning rate config. If decay is configured, learning _rate value is the starting learning rate, + where only poly decay is supported using the config file. In addition, decay power and end_lr are tuned experimentally. + loss: A loss config. Multi-loss config is available. The loss type order is consistent with the seg model outputs, + where the coef term indicates the weight of corresponding loss. Note that the number of coef must be the same as the number of + model outputs, and there could be only one loss type if using the same loss type among the outputs, otherwise the number of + loss type must be consistent with coef. + model: A model config including type/backbone and model-dependent arguments. + For model type, please refer to paddleseg.models. + For backbone, please refer to paddleseg.models.backbones. + +> > Args +> > > - **path** (str) : The path of config file, supports yaml format only. + +> > Examples + +```python +from paddleseg.cvlibs.config import Config + +# Create a cfg object with yaml file path. +cfg = Config(yaml_cfg_path) + +# Parsing the argument when its property is used. +train_dataset = cfg.train_dataset + +# the argument of model should be parsed after dataset, +# since the model builder uses some properties in dataset. +model = cfg.model +... +``` diff --git a/docs/apis/datasets.md b/docs/apis/datasets.md index e69de29bb2..1ad6917dda 100644 --- a/docs/apis/datasets.md +++ b/docs/apis/datasets.md @@ -0,0 +1,106 @@ +# paddleseg.datasets +- [Custom Dataset](#Custom) +- [Cityscapes](#Cityscapes) +- [PascalVOC](#PascalVOC) +- [ADE20K](#ADE20K) +- [OpticDiscSeg](#OpticDiscSeg) + +## [Custom Dataset](../../paddleseg/datasets/dataset.py) +> CLASS paddleseg.datasets.Dataset(transforms, dataset_root, num_classes, mode='train', train_path=None, val_path=None, test_path=None, separator=' ', ignore_index=255, edge=False) + + Pass in a custom dataset that conforms to the format. + +> > Args +> > > - **transforms** (list): Transforms for image. +> > > - **dataset_root** (str): The dataset directory. +> > > - **num_classes** (int): Number of classes. +> > > - **mode** (str, optional): which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. +> > > - **train_path** (str, optional): The train d**ataset file. When mode is 'train', train_path is necessary. + The contents of train_path file are as follow: + image1.jpg ground_truth1.png + image2.jpg ground_truth2.png +> > > - **val_path** (str, optional): The evaluation dataset file. When mode is 'val', val_path is necessary. + The contents is the same as train_path +> > > - **test_path** (str, optional): The test dataset file. When mode is 'test', test_path is necessary. + The annotation file is not necessary in test_path file. +> > > - **separator** (str, optional): The separator of dataset list. Default: ' '. +> > > - **edge** (bool, optional): Whether to compute edge while training. Default: False + +> > Examples + +```python +import paddleseg.transforms as T +from paddleseg.datasets import Dataset + +transforms = [T.RandomPaddingCrop(crop_size=(512,512)), T.Normalize()] +dataset_root = 'dataset_root_path' +train_path = 'train_path' +num_classes = 2 +dataset = Dataset(transforms = transforms, + dataset_root = dataset_root, + num_classes = 2, + train_path = train_path, + mode = 'train') +``` + +## [Cityscapes](../../paddleseg/datasets/cityscapes.py) +> CLASS paddleseg.datasets.Cityscapes(transforms, dataset_root, mode='train', edge=False) + + Cityscapes dataset `https://www.cityscapes-dataset.com/`. + The folder structure is as follow: + + cityscapes + | + |--leftImg8bit + | |--train + | |--val + | |--test + | + |--gtFine + | |--train + | |--val + | |--test + + Make sure there are **labelTrainIds.png in gtFine directory. If not, please run the conver_cityscapes.py in tools. + +> > Args +> > > - **transforms** (list): Transforms for image. +> > > - **dataset_root** (str): Cityscapes dataset directory. +> > > - **mode** (str, optional): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. +> > > - **edge** (bool, optional): Whether to compute edge while training. Default: False + + +## [PascalVOC](../../paddleseg/datasets/voc.py) +> CLASS paddleseg.datasets.PascalVOC(transforms, dataset_root=None, mode='train', edge=False) + + PascalVOC2012 dataset `http://host.robots.ox.ac.uk/pascal/VOC/`. + If you want to augment the dataset, please run the voc_augment.py in tools. + +> > Args +> > > - **transforms** (list): Transforms for image. +> > > - **dataset_root** (str): The dataset directory. Default: None +> > > - **mode** (str, optional): Which part of dataset to use. it is one of ('train', 'trainval', 'trainaug', 'val'). + If you want to set mode to 'trainaug', please make sure the dataset have been augmented. Default: 'train'. +> > > - **edge** (bool, optional): Whether to compute edge while training. Default: False + +## [ADE20K](../../paddleseg/datasets/ade.py) +> CLASS paddleseg.datasets.ADE20K(transforms, dataset_root=None, mode='train', edge=False) + + ADE20K dataset `http://sceneparsing.csail.mit.edu/`. + +> > Args +> > > - **transforms** (list): A list of image transformations. +> > > - **dataset_root** (str, optional): The ADK20K dataset directory. Default: None. +> > > - **mode** (str, optional): A subset of the entire dataset. It should be one of ('train', 'val'). Default: 'train'. +> > > - **edge** (bool, optional): Whether to compute edge while training. Default: False + +## [OpticDiscSeg](../../paddleseg/datasets/optic_disc_seg.py) +> CLASS paddleseg.datasets.OpticDiscSeg(dataset_root=None, transforms=None, mode='train', edge=False) + + OpticDiscSeg dataset is extraced from iChallenge-AMD `https://ai.baidu.com/broad/subordinate?dataset=amd`. + +> > Args +> > > - **transforms** (list): Transforms for image. +> > > - **dataset_root** (str): The dataset directory. Default: None +> > > - **mode** (str, optional): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. +> > > - **edge** (bool, optional): Whether to compute edge while training. Default: False diff --git a/docs/apis/models.md b/docs/apis/models.md index e97f7c7834..54b5138afd 100644 --- a/docs/apis/models.md +++ b/docs/apis/models.md @@ -1,53 +1,379 @@ +# paddleseg.models -# API References ------ - -```python -class paddleseg.models.OCRNet( - num_classes, - backbone, - backbone_indices=None, - ocr_mid_channels=512, - ocr_key_channels=256, - pretrained=None -) -``` - -The OCRNet implementation based on PaddlePaddle. The original article refers to [Yuan, Yuhui, et al. "Object-Contextual Representations for Semantic Segmentation"](https://arxiv.org/pdf/1909.11065.pdf) - -> **Parameters** -> -> *num_classes(int)*: the unique number of target classes. -> -> *backbone(Paddle.nn.Layer)*: backbone network. -> -> *backbone_indices(tuple)*: two values in the tuple indicate the indices of output of backbone. the first index will be taken as a deep-supervision feature in auxiliary layer; the second one will be taken as input of pixel representation. -> -> *ocr_mid_channels(int)*: the number of middle channels in OCRHead. -> -> *ocr_key_channels(int)*: the number of key channels in ObjectAttentionBlock. -> -> *pretrained(str)*: the path or url of pretrained model. Default to None. - ------ - -```python -class paddleseg.models.BiSeNetv2( - num_classes, - backbone, - backbone_indices=None, - ocr_mid_channels=512, - ocr_key_channels=256, - pretrained=None -) -``` - -The BiSeNet V2 implementation based on PaddlePaddle. The original article refers to [Yu, Changqian, et al. "BiSeNet V2: Bilateral Network with Guided Aggregation for Real-time Semantic Segmentation"](https://arxiv.org/abs/2004.02147) - -> **Parameters** -> -> *num_classes(int)*: the unique number of target classes. -> -> *lambd(float)*: factor for controlling the size of semantic branch channels. Default to 0.25. -> -> *pretrained(str)*: the path or url of pretrained model. Default to None. +The models subpackage contains the following model for image sementic segmentaion. +- [DeepLabV3+](#DeepLabV3+) +- [DeepLabV3](#DeepLabV3) +- [FCN](#FCN) +- [OCRNet](#OCRNet) +- [PSPNet](#PSPNet) +- [ANN](#ANN) +- [BiSeNetV2](#BiSeNetV2) +- [DANet](#DANet) +- [FastSCNN](#FastSCNN) +- [GCNet](#GCNet) +- [GSCNN](#GSCNN) +- [HarDNet](#HarDNet) +- [UNet](#UNet) +- [U2Net](#U2Net) +- [U2Net+](#U2Net+) +- [AttentionUNet](#AttentionUNet) + +## [DeepLabV3+](../../paddleseg/models/deeplab.py) +> CLASS paddleseg.models.DeepLabV3P(num_classes, backbone, backbone_indices=(0, 3), aspp_ratios=(1, 6, 12, 18), aspp_out_channels=256, align_corners=False, pretrained=None) + + The DeepLabV3Plus implementation based on PaddlePaddle. + + The original article refers to + Liang-Chieh Chen, et, al. "Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" + (https://arxiv.org/abs/1802.02611) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (paddle.nn.Layer): Backbone network, currently support Resnet50_vd/Resnet101_vd/Xception65. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. + Default: (0, 3). +> > > - **aspp_ratios** (tuple, optional): The dilation rate using in ASSP module. + If output_stride=16, aspp_ratios should be set as (1, 6, 12, 18). + If output_stride=8, aspp_ratios is (1, 12, 24, 36). + Default: (1, 6, 12, 18). +> > > - **aspp_out_channels** (int, optional): The output channels of ASPP module. Default: 256. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [DeepLabV3](../../paddleseg/models/deeplab.py) +> CLASS paddleseg.models.DeepLabV3(num_classes, backbone, backbone_indices=(3, ), aspp_ratios=(1, 6, 12, 18), aspp_out_channels=256, align_corners=False, pretrained=None) + + The DeepLabV3 implementation based on PaddlePaddle. + + The original article refers to + Liang-Chieh Chen, et, al. "Rethinking Atrous Convolution for Semantic Image Segmentation" + (https://arxiv.org/pdf/1706.05587.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (paddle.nn.Layer): Backbone network, currently support Resnet50_vd/Resnet101_vd/Xception65. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. + Default: (3, ). +> > > - **aspp_ratios** (tuple, optional): The dilation rate using in ASSP module. + If output_stride=16, aspp_ratios should be set as (1, 6, 12, 18). + If output_stride=8, aspp_ratios is (1, 12, 24, 36). + Default: (1, 6, 12, 18). +> > > - **aspp_out_channels** (int, optional): The output channels of ASPP module. Default: 256. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [FCN](../../paddleseg/models/deeplab.py) +> CLASS paddleseg.models.FCN(num_classes, + backbone_indices=(-1, ), + backbone_channels=(270, ), + channels=None) + + A simple implementation for FCN based on PaddlePaddle. + + The original article refers to + Evan Shelhamer, et, al. "Fully Convolutional Networks for Semantic Segmentation" + (https://arxiv.org/abs/1411.4038). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (paddle.nn.Layer): Backbone networks. +> > > - **backbone_indices** (tuple, optional): The values in the tuple indicate the indices of output of backbone. + Default: (-1, ). +> > > - **channels** (int, optional): The channels between conv layer and the last layer of FCNHead. + If None, it will be the number of channels of input features. Default: None. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None + +## [OCRNet](../../paddleseg/models/ocrnet.py) +> CLASS paddleseg.models.OCRNet(num_classes, + backbone, + backbone_indices, + ocr_mid_channels=512, + ocr_key_channels=256, + align_corners=False, + pretrained=None) + + The OCRNet implementation based on PaddlePaddle. + The original article refers to + Yuan, Yuhui, et al. "Object-Contextual Representations for Semantic Segmentation" + (https://arxiv.org/pdf/1909.11065.pdf) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (Paddle.nn.Layer): Backbone network. +> > > - **backbone_indices** (tuple): A tuple indicates the indices of output of backbone. + It can be either one or two values, if two values, the first index will be taken as + a deep-supervision feature in auxiliary layer; the second one will be taken as + input of pixel representation. If one value, it is taken by both above. +> > > - **ocr_mid_channels** (int, optional): The number of middle channels in OCRHead. Default: 512. +> > > - **ocr_key_channels** (int, optional): The number of key channels in ObjectAttentionBlock. Default: 256. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [PSPNet](../../paddleseg/models/pspnet.py) +> CLASS paddleseg.models.PSPNet(num_classes, + backbone, + backbone_indices=(2, 3), + pp_out_channels=1024, + bin_sizes=(1, 2, 3, 6), + enable_auxiliary_loss=True, + align_corners=False, + pretrained=None) + + The PSPNet implementation based on PaddlePaddle. + + The original article refers to + Zhao, Hengshuang, et al. "Pyramid scene parsing network" + (https://openaccess.thecvf.com/content_cvpr_2017/papers/Zhao_Pyramid_Scene_Parsing_CVPR_2017_paper.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (Paddle.nn.Layer): Backbone network, currently support Resnet50/101. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. +> > > - **pp_out_channels** (int, optional): The output channels after Pyramid Pooling Module. Default: 1024. +> > > - **bin_sizes** (tuple, optional): The out size of pooled feature maps. Default: (1,2,3,6). +> > > - **enable_auxiliary_loss** (bool, optional): A bool value indicates whether adding auxiliary loss. Default: True. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [ANN](../../paddleseg/models/ann.py) +> CLASS paddleseg.models.ANN(num_classes, + backbone, + backbone_indices=(2, 3), + key_value_channels=256, + inter_channels=512, + psp_size=(1, 3, 6, 8), + enable_auxiliary_loss=True, + align_corners=False, + pretrained=None) + + The ANN implementation based on PaddlePaddle. + + The original article refers to + Zhen, Zhu, et al. "Asymmetric Non-local Neural Networks for Semantic Segmentation" + (https://arxiv.org/pdf/1908.07678.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (Paddle.nn.Layer): Backbone network, currently support Resnet50/101. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. +> > > - **key_value_channels** (int, optional): The key and value channels of self-attention map in both AFNB and APNB modules. + Default: 256. +> > > - **inter_channels** (int, optional): Both input and output channels of APNB modules. Default: 512. +> > > - **psp_size** (tuple, optional): The out size of pooled feature maps. Default: (1, 3, 6, 8). +> > > - **enable_auxiliary_loss** (bool, optional): A bool value indicates whether adding auxiliary loss. Default: True. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [BiSeNetV2](../../paddleseg/models/bisenet.py) +> CLASS paddleseg.models.BiSeNetV2(num_classes, + lambd=0.25, + align_corners=False, + pretrained=None) + + The BiSeNet V2 implementation based on PaddlePaddle. + + The original article refers to + Yu, Changqian, et al. "BiSeNet V2: Bilateral Network with Guided Aggregation for Real-time Semantic Segmentation" + (https://arxiv.org/abs/2004.02147) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **lambd** (float, optional): A factor for controlling the size of semantic branch channels. Default: 0.25. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [DANet](../../paddleseg/models/danet.py) +> CLASS paddleseg.models.DANet(num_classes, + lambd=0.25, + align_corners=False, + pretrained=None) + + The DANet implementation based on PaddlePaddle. + + The original article refers to + Fu, jun, et al. "Dual Attention Network for Scene Segmentation" + (https://arxiv.org/pdf/1809.02983.pdf) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (Paddle.nn.Layer): A backbone network. +> > > - **backbone_indices** (tuple): The values in the tuple indicate the indices of + output of backbone. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [FastSCNN](../../paddleseg/models/fast_scnn.py) +> CLASS paddleseg.models.FastSCNN(num_classes, + enable_auxiliary_loss=True, + align_corners=False, + pretrained=None) + + The FastSCNN implementation based on PaddlePaddle. + As mentioned in the original paper, FastSCNN is a real-time segmentation algorithm (123.5fps) + even for high resolution images (1024x2048). + The original article refers to + Poudel, Rudra PK, et al. "Fast-scnn: Fast semantic segmentation network" + (https://arxiv.org/pdf/1902.04502.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **enable_auxiliary_loss** (bool, optional): A bool value indicates whether adding auxiliary loss. + If true, auxiliary loss will be added after LearningToDownsample module. Default: False. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769.. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [GCNet](../../paddleseg/models/gcnet.py) +> CLASS paddleseg.models.GCNet(num_classes, + backbone, + backbone_indices=(2, 3), + gc_channels=512, + ratio=0.25, + enable_auxiliary_loss=True, + align_corners=False, + pretrained=None) + + The GCNet implementation based on PaddlePaddle. + + The original article refers to + Cao, Yue, et al. "GCnet: Non-local networks meet squeeze-excitation networks and beyond" + (https://arxiv.org/pdf/1904.11492.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (Paddle.nn.Layer): Backbone network, currently support Resnet50/101. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. +> > > - **gc_channels** (int, optional): The input channels to Global Context Block. Default: 512. +> > > - **ratio** (float, optional): It indicates the ratio of attention channels and gc_channels. Default: 0.25. +> > > - **enable_auxiliary_loss** (bool, optional): A bool value indicates whether adding auxiliary loss. Default: True. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + + +## [GSCNN](../../paddleseg/models/gscnn.py) +> CLASS paddleseg.models.GSCNN(num_classes, + backbone, + backbone_indices=(0, 1, 2, 3), + aspp_ratios=(1, 6, 12, 18), + aspp_out_channels=256, + align_corners=False, + pretrained=None) + + The GSCNN implementation based on PaddlePaddle. + + The original article refers to + Towaki Takikawa, et, al. "Gated-SCNN: Gated Shape CNNs for Semantic Segmentation" + (https://arxiv.org/pdf/1907.05740.pdf) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **backbone** (paddle.nn.Layer): Backbone network, currently support Resnet50_vd/Resnet101_vd. +> > > - **backbone_indices** (tuple, optional): Two values in the tuple indicate the indices of output of backbone. + Default: (0, 1, 2, 3). +> > > - **aspp_ratios** (tuple, optional): The dilation rate using in ASSP module. + If output_stride=16, aspp_ratios should be set as (1, 6, 12, 18). + If output_stride=8, aspp_ratios is (1, 12, 24, 36). + Default: (1, 6, 12, 18). +> > > - **aspp_out_channels** (int, optional): The output channels of ASPP module. Default: 256. +> > > - **align_corners** (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, + e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [HarDNet](../../paddleseg/models/hardnet.py) +> CLASS paddleseg.models.HarDNet(num_classes, + stem_channels=(16, 24, 32, 48), + ch_list=(64, 96, 160, 224, 320), + grmul=1.7, + gr=(10, 16, 18, 24, 32), + n_layers=(4, 4, 8, 8, 8), + align_corners=False, + pretrained=None) + + [Real Time] The FC-HardDNet 70 implementation based on PaddlePaddle. + The original article refers to + Chao, Ping, et al. "HarDNet: A Low Memory Traffic Network" + (https://arxiv.org/pdf/1909.00948.pdf) + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **stem_channels** (tuple|list, optional): The number of channels before the encoder. Default: (16, 24, 32, 48). +> > > - **ch_list** (tuple|list, optional): The number of channels at each block in the encoder. Default: (64, 96, 160, 224, 320). +> > > - **grmul** (float, optional): The channel multiplying factor in HarDBlock, which is m in the paper. Default: 1.7. +> > > - **gr** (tuple|list, optional): The growth rate in each HarDBlock, which is k in the paper. Default: (10, 16, 18, 24, 32). +> > > - **n_layers** (tuple|list, optional): The number of layers in each HarDBlock. Default: (4, 4, 8, 8, 8). +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [UNet](../../paddleseg/models/unet.py) +> CLASS paddleseg.models.UNet(num_classes, + align_corners=False, + use_deconv=False, + pretrained=None) + + The UNet implementation based on PaddlePaddle. + + The original article refers to + Olaf Ronneberger, et, al. "U-Net: Convolutional Networks for Biomedical Image Segmentation" + (https://arxiv.org/abs/1505.04597). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **use_deconv** (bool, optional): A bool value indicates whether using deconvolution in upsampling. + If False, use resize_bilinear. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model for fine tuning. Default: None. + +## [U2Net](../../paddleseg/models/u2net.py) +> CLASS paddleseg.models.U2Net(num_classes, in_ch=3, pretrained=None) + + The U^2-Net implementation based on PaddlePaddle. + + The original article refers to + Xuebin Qin, et, al. "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection" + (https://arxiv.org/abs/1505.04597). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **in_ch** (int, optional): Input channels. Default: 3. +> > > - **pretrained** (str, optional): The path or url of pretrained model for fine tuning. Default: None. + +## [U2Net+](../../paddleseg/models/u2net.py) +> CLASS paddleseg.models.U2Netp(num_classes, in_ch=3, pretrained=None) + + The U^2-Netp implementation based on PaddlePaddle. + + The original article refers to + Xuebin Qin, et, al. "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection" + (https://arxiv.org/abs/1505.04597). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **in_ch** (int, optional): Input channels. Default: 3. +> > > - **pretrained** (str, optional): The path or url of pretrained model for fine tuning. Default: None. + +## [AttentionUNet](../../paddleseg/models/attention_unet.py) +> CLASS paddleseg.models.AttentionUNet(num_classes, pretrained=None) + + The Attention-UNet implementation based on PaddlePaddle. + As mentioned in the original paper, author proposes a novel attention gate (AG) + that automatically learns to focus on target structures of varying shapes and sizes. + Models trained with AGs implicitly learn to suppress irrelevant regions in an input image while + highlighting salient features useful for a specific task. + + The original article refers to + Oktay, O, et, al. "Attention u-net: Learning where to look for the pancreas." + (https://arxiv.org/pdf/1804.03999.pdf). + +> > Args +> > > - **num_classes** (int): The unique number of target classes. +> > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. diff --git a/docs/apis/transforms.md b/docs/apis/transforms.md index e69de29bb2..956a2ac7d7 100644 --- a/docs/apis/transforms.md +++ b/docs/apis/transforms.md @@ -0,0 +1,183 @@ +# [paddleseg.transforms](../../paddleseg/transforms/transforms.py) + +## Compose +> CLASS paddleseg.transforms.Compose(transforms, to_rgb=True) + + Do transformation on input data with corresponding pre-processing and augmentation operations. + The shape of input data to all operations is [height, width, channels]. + +> > Args +> > > - **transforms** (list): A list contains data pre-processing or augmentation. +> > > - **to_rgb** (bool, optional): If converting image to RGB color space. Default: True. + +> > Raises +> > > - TypeError: When 'transforms' is not a list. +> > > - ValueError: when the length of 'transforms' is less than 1. + +## RandomHorizontalFlip + +> CLASS paddleseg.transforms.RandomHorizontalFlip(prob=0.5) + + Flip an image horizontally with a certain probability. + +> > Args +> > > - **prob** (float, optional): A probability of horizontally flipping. Default: 0.5. + +## RandomVerticalFlip + +> CLASS paddleseg.transforms.RandomVerticalFlip(prob=0.1) + + Flip an image vertically with a certain probability. + +> > Args +> > > - **prob** (float, optional): A probability of vertical flipping. Default: 0.1. + +## Resize +> CLASS paddleseg.transforms.Resize(target_size=(512, 512), interp='LINEAR') + + Resize an image. + +> > Args +> > > - **target_size** (list|tuple, optional): The target size of image. Default: (512, 512). +> > > - **interp** (str, optional): The interpolation mode of resize is consistent with opencv. + ['NEAREST', 'LINEAR', 'CUBIC', 'AREA', 'LANCZOS4', 'RANDOM']. Note that when it is + 'RANDOM', a random interpolation mode would be specified. Default: "LINEAR". + +> > Raises +> > > - TypeError: When 'target_size' type is neither list nor tuple. +> > > - ValueError: When "interp" is out of pre-defined methods ('NEAREST', 'LINEAR', 'CUBIC', + 'AREA', 'LANCZOS4', 'RANDOM'). + +## ResizeByLong +> CLASS paddleseg.transforms.ResizeByLong(long_size) + + Resize the long side of an image to given size, and then scale the other side proportionally. + +> > Args +> > > - **long_size** (int): The target size of long side. + +## ResizeRangeScaling +> CLASS paddleseg.transforms.ResizeRangeScaling(min_value=400, max_value=600) + + Resize the long side of an image into a range, and then scale the other side proportionally. + +> > Args +> > > - **min_value** (int, optional): The minimum value of long side after resize. Default: 400. +> > > - **max_value** (int, optional): The maximum value of long side after resize. Default: 600. + +## ResizeStepScaling +> CLASS paddleseg.transforms.ResizeStepScaling(min_scale_factor=0.75, + max_scale_factor=1.25, + scale_step_size=0.25) + + Scale an image proportionally within a range. + +> > Args +> > > - **min_scale_factor**** (float, optional): The minimum scale. Default: 0.75. +> > > - **max_scale_factor** (float, optional): The maximum scale. Default: 1.25. +> > > - **scale_step_size** (float, optional): The scale interval. Default: 0.25. + +> > Raises +> > > - ValueError: When min_scale_factor is smaller than max_scale_factor. + +## Normalize +> CLASS paddleseg.transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) + + Normalize an image. + +> > Args +> > > - **mean** (list, optional): The mean value of a data set. Default: [0.5, 0.5, 0.5]. +> > > - **std** (list, optional): The standard deviation of a data set. Default: [0.5, 0.5, 0.5]. + +> > Raises +> > > - ValueError: When mean/std is not list or any value in std is 0. + +## Padding +> CLASS paddleseg.transforms.Padding(target_size, + im_padding_value=(127.5, 127.5, 127.5), + label_padding_value=255) + + Add bottom-right padding to a raw image or annotation image. + +> > Args +> > > - **target_size** (list|tuple): The target size after padding. +> > > - **im_padding_value** (list, optional): The padding value of raw image. + Default: [127.5, 127.5, 127.5]. +> > > - **label_padding_value** (int, optional): The padding value of annotation image. Default: 255. + +> > Raises +> > > - TypeError: When target_size is neither list nor tuple. +> > > - ValueError: When the length of target_size is not 2. + +## RandomPaddingCrop +> CLASS paddleseg.transforms.RandomPaddingCrop(crop_size=(512, 512), + im_padding_value=(127.5, 127.5, 127.5), + label_padding_value=255) + + Crop a sub-image from a raw image and annotation image randomly. If the target cropping size + is larger than original image, then the bottom-right padding will be added. + +> > Args +> > > - **crop_size** (tuple, optional): The target cropping size. Default: (512, 512). +> > > - **im_padding_value** (list, optional): The padding value of raw image. + Default: [127.5, 127.5, 127.5]. +> > > - **label_padding_value** (int, optional): The padding value of annotation image. Default: 255. + +> > Raises +> > > - TypeError: When crop_size is neither list nor tuple. +> > > - ValueError: When the length of crop_size is not 2. + + +## RandomBlur +> CLASS paddleseg.transforms.RandomBlur(prob=0.1) + + Blurring an image by a Gaussian function with a certain probability. + +> > Args +> > > - **prob** (float, optional): A probability of blurring an image. Default: 0.1. + +## RandomRotation +> CLASS paddleseg.transforms.RandomRotation(max_rotation=15, + im_padding_value=(127.5, 127.5, 127.5), + label_padding_value=255) + + Rotate an image randomly with padding. + +> > Args +> > > - **max_rotation** (float, optional): The maximum rotation degree. Default: 15. +> > > - **im_padding_value** (list, optional): The padding value of raw image. + Default: [127.5, 127.5, 127.5]. +> > > - **label_padding_value** (int, optional): The padding value of annotation image. Default: 255. + +## RandomScaleAspect +> CLASS paddleseg.transforms.RandomScaleAspect(min_scale=0.5, aspect_ratio=0.33) + + Crop a sub-image from an original image with a range of area ratio and aspect and + then scale the sub-image back to the size of the original image. + +> > Args +> > > - **min_scale** (float, optional): The minimum area ratio of cropped image to the original image. Default: 0.5. +> > > - **aspect_ratio** (float, optional): The minimum aspect ratio. Default: 0.33. + + +## RandomDistort +> CLASS paddleseg.transforms.RandomDistort(brightness_range=0.5, + brightness_prob=0.5, + contrast_range=0.5, + contrast_prob=0.5, + saturation_range=0.5, + saturation_prob=0.5, + hue_range=18, + hue_prob=0.5) + + Distort an image with random configurations. + +> > Args +> > > - **brightness_range** (float, optional): A range of brightness. Default: 0.5. +> > > - **brightness_prob** (float, optional): A probability of adjusting brightness. Default: 0.5. +> > > - **contrast_range** (float, optional): A range of contrast. Default: 0.5. +> > > - **contrast_prob** (float, optional): A probability of adjusting contrast. Default: 0.5. +> > > - **saturation_range** (float, optional): A range of saturation. Default: 0.5. +> > > - **saturation_prob** (float, optional): A probability of adjusting saturation. Default: 0.5. +> > > - **hue_range** (int, optional): A range of hue. Default: 18. +> > > - **hue_prob** (float, optional): A probability of adjusting hue. Default: 0.5. diff --git a/paddleseg/core/predict.py b/paddleseg/core/predict.py index 6eaa5453af..c95c45c493 100644 --- a/paddleseg/core/predict.py +++ b/paddleseg/core/predict.py @@ -49,9 +49,18 @@ def predict(model, model (nn.Layer): Used to predict for input image. model_path (str): The path of pretrained model. transforms (transform.Compose): Preprocess for input image. - image_list (list): A list of images to be predicted. - image_dir (str): The directory of the images to be predicted. Default: None. - save_dir (str): The directory to save the visualized results. Default: 'output'. + image_list (list): A list of image path to be predicted. + image_dir (str, optional): The root directory of the images predicted. Default: None. + save_dir (str, optional): The directory to save the visualized results. Default: 'output'. + aug_pred (bool, optional): Whether to use mulit-scales and flip augment for predition. Default: False. + scales (list|float, optional): Scales for augment. It is valid when `aug_pred` is True. Default: 1.0. + flip_horizontal (bool, optional): Whether to use flip horizontally augment. It is valid when `aug_pred` is True. Default: True. + flip_vertical (bool, optional): Whether to use flip vertically augment. It is valid when `aug_pred` is True. Default: False. + is_slide (bool, optional): Whether to predict by sliding window. Default: False. + stride (tuple|list, optional): The stride of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. + crop_size (tuple|list, optional): The crop size of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. """ para_state_dict = paddle.load(model_path) diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index 4c2e33087e..d3cc4b42af 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -57,6 +57,25 @@ def train(model, num_workers=0, use_vdl=False, losses=None): + """ + Launch training. + + Args: + model(nn.Layer): A sementic segmentation model. + train_dataset (paddle.io.Dataset): Used to read and process training datasets. + val_dataset (paddle.io.Dataset, optional): Used to read and process validation datasets. + optimizer (paddle.optimizer.Optimizer): The optimizer. + save_dir (str, optional): The directory for saving the model snapshot. Default: 'output'. + iters (int, optional): How may iters to train the model. Defualt: 10000. + batch_size (int, optional): Mini batch size of one gpu or cpu. Default: 2. + resume_model (str, optional): The path of resume model. + save_interval (int, optional): How many iters to save a model snapshot once during training. Default: 1000. + log_iters (int, optional): Display logging information at every log_iters. Default: 10. + num_workers (int, optional): Num workers for data loader. Default: 0. + use_vdl (bool, optional): Whether to record the data to VisualDL during training. Default: False. + losses (dict): A dict including 'types' and 'coef'. The length of coef should equal to 1 or len(losses['types']). + The 'types' item is a list of object of paddleseg.models.losses while the 'coef' item is a list of the relevant coefficient. + """ nranks = paddle.distributed.ParallelEnv().nranks local_rank = paddle.distributed.ParallelEnv().local_rank diff --git a/paddleseg/core/val.py b/paddleseg/core/val.py index 11f14cbc51..c5447cbcb8 100644 --- a/paddleseg/core/val.py +++ b/paddleseg/core/val.py @@ -34,6 +34,27 @@ def evaluate(model, stride=None, crop_size=None, num_workers=0): + """ + Launch evalution. + + Args: + model(nn.Layer): A sementic segmentation model. + eval_dataset (paddle.io.Dataset): Used to read and process validation datasets. + aug_eval (bool, optional): Whether to use mulit-scales and flip augment for evaluation. Default: False. + scales (list|float, optional): Scales for augment. It is valid when `aug_eval` is True. Default: 1.0. + flip_horizontal (bool, optional): Whether to use flip horizontally augment. It is valid when `aug_eval` is True. Default: True. + flip_vertical (bool, optional): Whether to use flip vertically augment. It is valid when `aug_eval` is True. Default: False. + is_slide (bool, optional): Whether to evaluate by sliding window. Default: False. + stride (tuple|list, optional): The stride of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. + crop_size (tuple|list, optional): The crop size of sliding window, the first is width and the second is height. + It should be provided when `is_slide` is True. + num_workers (int, optional): Num workers for data loader. Default: 0. + + Returns: + float: The mIoU of validation datasets. + float: The accuracy of validation datasets. + """ model.eval() nranks = paddle.distributed.ParallelEnv().nranks local_rank = paddle.distributed.ParallelEnv().local_rank diff --git a/paddleseg/cvlibs/param_init.py b/paddleseg/cvlibs/param_init.py index 106dc8f628..335281242e 100644 --- a/paddleseg/cvlibs/param_init.py +++ b/paddleseg/cvlibs/param_init.py @@ -74,6 +74,9 @@ def kaiming_normal_init(param, **kwargs): .. math:: \sqrt{\\frac{2.0}{fan\_in}} + Args: + param (Tensor): Tensor that needs to be initialized. + Examples: from paddleseg.cvlibs import param_init diff --git a/paddleseg/datasets/ade.py b/paddleseg/datasets/ade.py index 5ace6a3e56..dae7de4360 100644 --- a/paddleseg/datasets/ade.py +++ b/paddleseg/datasets/ade.py @@ -36,7 +36,7 @@ class ADE20K(Dataset): transforms (list): A list of image transformations. dataset_root (str, optional): The ADK20K dataset directory. Default: None. mode (str, optional): A subset of the entire dataset. It should be one of ('train', 'val'). Default: 'train'. - edge (bool): Whether to compute edge while training. Default: False + edge (bool, optional): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root=None, mode='train', edge=False): diff --git a/paddleseg/datasets/cityscapes.py b/paddleseg/datasets/cityscapes.py index 7d3659bd6f..a501722098 100644 --- a/paddleseg/datasets/cityscapes.py +++ b/paddleseg/datasets/cityscapes.py @@ -43,8 +43,8 @@ class Cityscapes(Dataset): Args: transforms (list): Transforms for image. dataset_root (str): Cityscapes dataset directory. - mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. - edge (bool): Whether to compute edge while training. Default: False + mode (str, optional): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. + edge (bool, optional): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root, mode='train', edge=False): diff --git a/paddleseg/datasets/dataset.py b/paddleseg/datasets/dataset.py index 7ac6098693..913f3df10c 100644 --- a/paddleseg/datasets/dataset.py +++ b/paddleseg/datasets/dataset.py @@ -32,17 +32,17 @@ class Dataset(paddle.io.Dataset): transforms (list): Transforms for image. dataset_root (str): The dataset directory. num_classes (int): Number of classes. - mode (str): which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. - train_path (str): The train dataset file. When mode is 'train', train_path is necessary. + mode (str, optional): which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. + train_path (str, optional): The train dataset file. When mode is 'train', train_path is necessary. The contents of train_path file are as follow: image1.jpg ground_truth1.png image2.jpg ground_truth2.png - val_path (str): The evaluation dataset file. When mode is 'val', val_path is necessary. + val_path (str. optional): The evaluation dataset file. When mode is 'val', val_path is necessary. The contents is the same as train_path - test_path (str): The test dataset file. When mode is 'test', test_path is necessary. + test_path (str, optional): The test dataset file. When mode is 'test', test_path is necessary. The annotation file is not necessary in test_path file. - separator (str): The separator of dataset list. Default: ' '. - edge (bool): Whether to compute edge while training. Default: False + separator (str, optional): The separator of dataset list. Default: ' '. + edge (bool, optional): Whether to compute edge while training. Default: False Examples: diff --git a/paddleseg/datasets/optic_disc_seg.py b/paddleseg/datasets/optic_disc_seg.py index cad32a3307..12f8bafd3c 100644 --- a/paddleseg/datasets/optic_disc_seg.py +++ b/paddleseg/datasets/optic_disc_seg.py @@ -32,8 +32,8 @@ class OpticDiscSeg(Dataset): Args: transforms (list): Transforms for image. dataset_root (str): The dataset directory. Default: None - mode (str): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. - edge (bool): Whether to compute edge while training. Default: False + mode (str, optional): Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'. + edge (bool, optional): Whether to compute edge while training. Default: False """ def __init__(self, diff --git a/paddleseg/datasets/voc.py b/paddleseg/datasets/voc.py index dc5bf6c8b1..91589b3775 100644 --- a/paddleseg/datasets/voc.py +++ b/paddleseg/datasets/voc.py @@ -32,9 +32,9 @@ class PascalVOC(Dataset): Args: transforms (list): Transforms for image. dataset_root (str): The dataset directory. Default: None - mode (str): Which part of dataset to use. it is one of ('train', 'trainval', 'trainaug', 'val'). + mode (str, optional): Which part of dataset to use. it is one of ('train', 'trainval', 'trainaug', 'val'). If you want to set mode to 'trainaug', please make sure the dataset have been augmented. Default: 'train'. - edge (bool): Whether to compute edge while training. Default: False + edge (bool, optional): Whether to compute edge while training. Default: False """ def __init__(self, transforms, dataset_root=None, mode='train', edge=False): diff --git a/paddleseg/models/backbones/hrnet.py b/paddleseg/models/backbones/hrnet.py index 5de97497e5..40ed660d9d 100644 --- a/paddleseg/models/backbones/hrnet.py +++ b/paddleseg/models/backbones/hrnet.py @@ -37,20 +37,20 @@ class HRNet(nn.Layer): (https://arxiv.org/pdf/1908.07919.pdf). Args: - pretrained (str): The path of pretrained model. - stage1_num_modules (int): Number of modules for stage1. Default 1. - stage1_num_blocks (list): Number of blocks per module for stage1. Default [4]. - stage1_num_channels (list): Number of channels per branch for stage1. Default [64]. - stage2_num_modules (int): Number of modules for stage2. Default 1. - stage2_num_blocks (list): Number of blocks per module for stage2. Default [4, 4] - stage2_num_channels (list): Number of channels per branch for stage2. Default [18, 36]. - stage3_num_modules (int): Number of modules for stage3. Default 4. - stage3_num_blocks (list): Number of blocks per module for stage3. Default [4, 4, 4] - stage3_num_channels (list): Number of channels per branch for stage3. Default [18, 36, 72]. - stage4_num_modules (int): Number of modules for stage4. Default 3. - stage4_num_blocks (list): Number of blocks per module for stage4. Default [4, 4, 4, 4] - stage4_num_channels (list): Number of channels per branch for stage4. Default [18, 36, 72. 144]. - has_se (bool): Whether to use Squeeze-and-Excitation module. Default False. + pretrained (str, optional): The path of pretrained model. + stage1_num_modules (int, optional): Number of modules for stage1. Default 1. + stage1_num_blocks (list, optional): Number of blocks per module for stage1. Default (4). + stage1_num_channels (list, optional): Number of channels per branch for stage1. Default (64). + stage2_num_modules (int, optional): Number of modules for stage2. Default 1. + stage2_num_blocks (list, optional): Number of blocks per module for stage2. Default (4, 4). + stage2_num_channels (list, optional): Number of channels per branch for stage2. Default (18, 36). + stage3_num_modules (int, optional): Number of modules for stage3. Default 4. + stage3_num_blocks (list, optional): Number of blocks per module for stage3. Default (4, 4, 4). + stage3_num_channels (list, optional): Number of channels per branch for stage3. Default [18, 36, 72). + stage4_num_modules (int, optional): Number of modules for stage4. Default 3. + stage4_num_blocks (list, optional): Number of blocks per module for stage4. Default (4, 4, 4, 4). + stage4_num_channels (list, optional): Number of channels per branch for stage4. Default (18, 36, 72. 144). + has_se (bool, optional): Whether to use Squeeze-and-Excitation module. Default False. align_corners (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. """ @@ -58,17 +58,17 @@ class HRNet(nn.Layer): def __init__(self, pretrained=None, stage1_num_modules=1, - stage1_num_blocks=[4], - stage1_num_channels=[64], + stage1_num_blocks=(4, ), + stage1_num_channels=(64, ), stage2_num_modules=1, - stage2_num_blocks=[4, 4], - stage2_num_channels=[18, 36], + stage2_num_blocks=(4, 4), + stage2_num_channels=(18, 36), stage3_num_modules=4, - stage3_num_blocks=[4, 4, 4], - stage3_num_channels=[18, 36, 72], + stage3_num_blocks=(4, 4, 4), + stage3_num_channels=(18, 36, 72), stage4_num_modules=3, - stage4_num_blocks=[4, 4, 4, 4], - stage4_num_channels=[18, 36, 72, 144], + stage4_num_blocks=(4, 4, 4, 4), + stage4_num_channels=(18, 36, 72, 144), has_se=False, align_corners=False): super(HRNet, self).__init__() diff --git a/paddleseg/models/backbones/mobilenetv3.py b/paddleseg/models/backbones/mobilenetv3.py index b01199264e..7a83f04c00 100644 --- a/paddleseg/models/backbones/mobilenetv3.py +++ b/paddleseg/models/backbones/mobilenetv3.py @@ -39,11 +39,25 @@ def make_divisible(v, divisor=8, min_value=None): class MobileNetV3(nn.Layer): + """ + The MobileNetV3 implementation based on PaddlePaddle. + + The original article refers to Jingdong + Andrew Howard, et, al. "Searching for MobileNetV3" + (https://arxiv.org/pdf/1905.02244.pdf). + + Args: + pretrained (str, optional): The path of pretrained model. + scale (float, optional): The scale of channels . Default: 1.0. + model_name (str, optional): Model name. It determines the type of MobileNetV3. The value is 'small' or 'large'. Defualt: 'small'. + output_stride (int, optional): The stride of output features compared to input images. The value should be one of (2, 4, 8, 16, 32). Default: None. + + """ + def __init__(self, pretrained=None, scale=1.0, model_name="small", - class_dim=1000, output_stride=None): super(MobileNetV3, self).__init__() diff --git a/paddleseg/models/backbones/resnet_vd.py b/paddleseg/models/backbones/resnet_vd.py index f521942e19..068a7e2b00 100644 --- a/paddleseg/models/backbones/resnet_vd.py +++ b/paddleseg/models/backbones/resnet_vd.py @@ -176,17 +176,30 @@ def forward(self, inputs): class ResNet_vd(nn.Layer): + """ + The ResNet_vd implementation based on PaddlePaddle. + + The original article refers to Jingdong + Tong He, et, al. "Bag of Tricks for Image Classification with Convolutional Neural Networks" + (https://arxiv.org/pdf/1812.01187.pdf). + + Args: + layers (int, optional): The layers of ResNet_vd. The supported layers are (18, 34, 50, 101, 152, 200). Default: 50. + output_stride (int, optional): The stride of output features compared to input images. It is 8 or 16. Default: 8. + multi_grid (tuple|list, optional): The grid of stage4. Defult: (1, 1, 1). + pretrained (str, optional): The path of pretrained model. + + """ + def __init__(self, layers=50, - output_stride=None, + output_stride=8, multi_grid=(1, 1, 1), - lr_mult_list=(0.1, 0.1, 0.2, 0.2), pretrained=None): super(ResNet_vd, self).__init__() self.conv1_logit = None # for gscnn shape stream self.layers = layers - self.lr_mult_list = lr_mult_list supported_layers = [18, 34, 50, 101, 152, 200] assert layers in supported_layers, \ "supported layers are {} but input layer is {}".format( @@ -314,22 +327,6 @@ def forward(self, inputs): def init_weight(self): utils.load_pretrained_model(self, self.pretrained) - # for idx, stage in enumerate(self.stage_list): - # for layer in stage: - # for sublayer in layer.sublayers(): - # if isinstance(sublayer, nn.Conv2D): - # sublayer.weight.optimize_attr[ - # 'learning_rate'] = self.lr_mult_list[idx] - # if sublayer.bias: - # sublayer.bias.optimize_attr[ - # 'learning_rate'] = self.lr_mult_list[idx] - - # if isinstance(sublayer, nn.SyncBatchNorm): - # sublayer.weight.optimize_attr[ - # 'learning_rate'] = self.lr_mult_list[idx] - # sublayer.bias.optimize_attr[ - # 'learning_rate'] = self.lr_mult_list[idx] - @manager.BACKBONES.add_component def ResNet18_vd(**args): diff --git a/paddleseg/models/backbones/xception_deeplab.py b/paddleseg/models/backbones/xception_deeplab.py index ad42e993c3..b83caec51d 100644 --- a/paddleseg/models/backbones/xception_deeplab.py +++ b/paddleseg/models/backbones/xception_deeplab.py @@ -247,14 +247,21 @@ def forward(self, inputs): class XceptionDeeplab(nn.Layer): + """ + The Xception backobne of DeepLabv3+ implementation based on PaddlePaddle. - # def __init__(self, backbone, class_dim=1000): - # add output_stride - def __init__(self, - backbone, - pretrained=None, - output_stride=16, - class_dim=1000): + The original article refers to + Liang-Chieh Chen, et, al. "Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" + (https://arxiv.org/abs/1802.02611) + + Args: + backbone (str): Which type of Xception_DeepLab to select. It should be one of ('xception_41', 'xception_65', 'xception_71'). + pretrained (str, optional): The path of pretrained model. + output_stride (int, optional): The stride of output features compared to input images. It is 8 or 16. Default: 16. + + """ + + def __init__(self, backbone, pretrained=None, output_stride=16): super(XceptionDeeplab, self).__init__() diff --git a/paddleseg/models/u2net.py b/paddleseg/models/u2net.py index 83d017c4a5..50dd3d94cb 100644 --- a/paddleseg/models/u2net.py +++ b/paddleseg/models/u2net.py @@ -6,64 +6,66 @@ __all__ = ['U2Net', 'U2Netp'] + class REBNCONV(nn.Layer): - def __init__(self,in_ch=3,out_ch=3,dirate=1): - super(REBNCONV,self).__init__() + def __init__(self, in_ch=3, out_ch=3, dirate=1): + super(REBNCONV, self).__init__() - self.conv_s1 = nn.Conv2D(in_ch,out_ch,3,padding=1*dirate,dilation=1*dirate) + self.conv_s1 = nn.Conv2D( + in_ch, out_ch, 3, padding=1 * dirate, dilation=1 * dirate) self.bn_s1 = nn.BatchNorm2D(out_ch) self.relu_s1 = nn.ReLU() - def forward(self,x): + def forward(self, x): hx = x xout = self.relu_s1(self.bn_s1(self.conv_s1(hx))) return xout + ## upsample tensor 'src' to have the same spatial size with tensor 'tar' -def _upsample_like(src,tar): +def _upsample_like(src, tar): - src = F.upsample(src,size=tar.shape[2:],mode='bilinear') + src = F.upsample(src, size=tar.shape[2:], mode='bilinear') return src ### RSU-7 ### -class RSU7(nn.Layer):#UNet07DRES(nn.Layer): - +class RSU7(nn.Layer): #UNet07DRES(nn.Layer): def __init__(self, in_ch=3, mid_ch=12, out_ch=3): - super(RSU7,self).__init__() + super(RSU7, self).__init__() - self.rebnconvin = REBNCONV(in_ch,out_ch,dirate=1) + self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1) - self.rebnconv1 = REBNCONV(out_ch,mid_ch,dirate=1) - self.pool1 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1) + self.pool1 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv2 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool2 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool2 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv3 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool3 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool3 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv4 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool4 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool4 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv5 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool5 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool5 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv6 = REBNCONV(mid_ch,mid_ch,dirate=1) + self.rebnconv6 = REBNCONV(mid_ch, mid_ch, dirate=1) - self.rebnconv7 = REBNCONV(mid_ch,mid_ch,dirate=2) + self.rebnconv7 = REBNCONV(mid_ch, mid_ch, dirate=2) - self.rebnconv6d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv5d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv4d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv1d = REBNCONV(mid_ch*2,out_ch,dirate=1) + self.rebnconv6d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv5d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv4d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1) - def forward(self,x): + def forward(self, x): hx = x hxin = self.rebnconvin(hx) @@ -87,56 +89,56 @@ def forward(self,x): hx7 = self.rebnconv7(hx6) - hx6d = self.rebnconv6d(paddle.concat((hx7,hx6),1)) - hx6dup = _upsample_like(hx6d,hx5) + hx6d = self.rebnconv6d(paddle.concat((hx7, hx6), 1)) + hx6dup = _upsample_like(hx6d, hx5) - hx5d = self.rebnconv5d(paddle.concat((hx6dup,hx5),1)) - hx5dup = _upsample_like(hx5d,hx4) + hx5d = self.rebnconv5d(paddle.concat((hx6dup, hx5), 1)) + hx5dup = _upsample_like(hx5d, hx4) - hx4d = self.rebnconv4d(paddle.concat((hx5dup,hx4),1)) - hx4dup = _upsample_like(hx4d,hx3) + hx4d = self.rebnconv4d(paddle.concat((hx5dup, hx4), 1)) + hx4dup = _upsample_like(hx4d, hx3) - hx3d = self.rebnconv3d(paddle.concat((hx4dup,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.rebnconv3d(paddle.concat((hx4dup, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.rebnconv2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) + hx2d = self.rebnconv2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) - hx1d = self.rebnconv1d(paddle.concat((hx2dup,hx1),1)) + hx1d = self.rebnconv1d(paddle.concat((hx2dup, hx1), 1)) return hx1d + hxin -### RSU-6 ### -class RSU6(nn.Layer):#UNet06DRES(nn.Layer): +### RSU-6 ### +class RSU6(nn.Layer): #UNet06DRES(nn.Layer): def __init__(self, in_ch=3, mid_ch=12, out_ch=3): - super(RSU6,self).__init__() + super(RSU6, self).__init__() - self.rebnconvin = REBNCONV(in_ch,out_ch,dirate=1) + self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1) - self.rebnconv1 = REBNCONV(out_ch,mid_ch,dirate=1) - self.pool1 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1) + self.pool1 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv2 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool2 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool2 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv3 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool3 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool3 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv4 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool4 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool4 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv5 = REBNCONV(mid_ch,mid_ch,dirate=1) + self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=1) - self.rebnconv6 = REBNCONV(mid_ch,mid_ch,dirate=2) + self.rebnconv6 = REBNCONV(mid_ch, mid_ch, dirate=2) - self.rebnconv5d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv4d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv1d = REBNCONV(mid_ch*2,out_ch,dirate=1) + self.rebnconv5d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv4d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1) - def forward(self,x): + def forward(self, x): hx = x @@ -158,50 +160,49 @@ def forward(self,x): hx6 = self.rebnconv6(hx5) + hx5d = self.rebnconv5d(paddle.concat((hx6, hx5), 1)) + hx5dup = _upsample_like(hx5d, hx4) - hx5d = self.rebnconv5d(paddle.concat((hx6,hx5),1)) - hx5dup = _upsample_like(hx5d,hx4) - - hx4d = self.rebnconv4d(paddle.concat((hx5dup,hx4),1)) - hx4dup = _upsample_like(hx4d,hx3) + hx4d = self.rebnconv4d(paddle.concat((hx5dup, hx4), 1)) + hx4dup = _upsample_like(hx4d, hx3) - hx3d = self.rebnconv3d(paddle.concat((hx4dup,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.rebnconv3d(paddle.concat((hx4dup, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.rebnconv2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) + hx2d = self.rebnconv2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) - hx1d = self.rebnconv1d(paddle.concat((hx2dup,hx1),1)) + hx1d = self.rebnconv1d(paddle.concat((hx2dup, hx1), 1)) return hx1d + hxin -### RSU-5 ### -class RSU5(nn.Layer):#UNet05DRES(nn.Layer): +### RSU-5 ### +class RSU5(nn.Layer): #UNet05DRES(nn.Layer): def __init__(self, in_ch=3, mid_ch=12, out_ch=3): - super(RSU5,self).__init__() + super(RSU5, self).__init__() - self.rebnconvin = REBNCONV(in_ch,out_ch,dirate=1) + self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1) - self.rebnconv1 = REBNCONV(out_ch,mid_ch,dirate=1) - self.pool1 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1) + self.pool1 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv2 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool2 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool2 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv3 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool3 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool3 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv4 = REBNCONV(mid_ch,mid_ch,dirate=1) + self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=1) - self.rebnconv5 = REBNCONV(mid_ch,mid_ch,dirate=2) + self.rebnconv5 = REBNCONV(mid_ch, mid_ch, dirate=2) - self.rebnconv4d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv1d = REBNCONV(mid_ch*2,out_ch,dirate=1) + self.rebnconv4d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1) - def forward(self,x): + def forward(self, x): hx = x @@ -220,42 +221,42 @@ def forward(self,x): hx5 = self.rebnconv5(hx4) - hx4d = self.rebnconv4d(paddle.concat((hx5,hx4),1)) - hx4dup = _upsample_like(hx4d,hx3) + hx4d = self.rebnconv4d(paddle.concat((hx5, hx4), 1)) + hx4dup = _upsample_like(hx4d, hx3) - hx3d = self.rebnconv3d(paddle.concat((hx4dup,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.rebnconv3d(paddle.concat((hx4dup, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.rebnconv2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) + hx2d = self.rebnconv2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) - hx1d = self.rebnconv1d(paddle.concat((hx2dup,hx1),1)) + hx1d = self.rebnconv1d(paddle.concat((hx2dup, hx1), 1)) return hx1d + hxin -### RSU-4 ### -class RSU4(nn.Layer):#UNet04DRES(nn.Layer): +### RSU-4 ### +class RSU4(nn.Layer): #UNet04DRES(nn.Layer): def __init__(self, in_ch=3, mid_ch=12, out_ch=3): - super(RSU4,self).__init__() + super(RSU4, self).__init__() - self.rebnconvin = REBNCONV(in_ch,out_ch,dirate=1) + self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1) - self.rebnconv1 = REBNCONV(out_ch,mid_ch,dirate=1) - self.pool1 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1) + self.pool1 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv2 = REBNCONV(mid_ch,mid_ch,dirate=1) - self.pool2 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=1) + self.pool2 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.rebnconv3 = REBNCONV(mid_ch,mid_ch,dirate=1) + self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=1) - self.rebnconv4 = REBNCONV(mid_ch,mid_ch,dirate=2) + self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=2) - self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch,dirate=1) - self.rebnconv1d = REBNCONV(mid_ch*2,out_ch,dirate=1) + self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=1) + self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1) - def forward(self,x): + def forward(self, x): hx = x @@ -271,35 +272,35 @@ def forward(self,x): hx4 = self.rebnconv4(hx3) - hx3d = self.rebnconv3d(paddle.concat((hx4,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.rebnconv3d(paddle.concat((hx4, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.rebnconv2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) + hx2d = self.rebnconv2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) - hx1d = self.rebnconv1d(paddle.concat((hx2dup,hx1),1)) + hx1d = self.rebnconv1d(paddle.concat((hx2dup, hx1), 1)) return hx1d + hxin -### RSU-4F ### -class RSU4F(nn.Layer):#UNet04FRES(nn.Layer): +### RSU-4F ### +class RSU4F(nn.Layer): #UNet04FRES(nn.Layer): def __init__(self, in_ch=3, mid_ch=12, out_ch=3): - super(RSU4F,self).__init__() + super(RSU4F, self).__init__() - self.rebnconvin = REBNCONV(in_ch,out_ch,dirate=1) + self.rebnconvin = REBNCONV(in_ch, out_ch, dirate=1) - self.rebnconv1 = REBNCONV(out_ch,mid_ch,dirate=1) - self.rebnconv2 = REBNCONV(mid_ch,mid_ch,dirate=2) - self.rebnconv3 = REBNCONV(mid_ch,mid_ch,dirate=4) + self.rebnconv1 = REBNCONV(out_ch, mid_ch, dirate=1) + self.rebnconv2 = REBNCONV(mid_ch, mid_ch, dirate=2) + self.rebnconv3 = REBNCONV(mid_ch, mid_ch, dirate=4) - self.rebnconv4 = REBNCONV(mid_ch,mid_ch,dirate=8) + self.rebnconv4 = REBNCONV(mid_ch, mid_ch, dirate=8) - self.rebnconv3d = REBNCONV(mid_ch*2,mid_ch,dirate=4) - self.rebnconv2d = REBNCONV(mid_ch*2,mid_ch,dirate=2) - self.rebnconv1d = REBNCONV(mid_ch*2,out_ch,dirate=1) + self.rebnconv3d = REBNCONV(mid_ch * 2, mid_ch, dirate=4) + self.rebnconv2d = REBNCONV(mid_ch * 2, mid_ch, dirate=2) + self.rebnconv1d = REBNCONV(mid_ch * 2, out_ch, dirate=1) - def forward(self,x): + def forward(self, x): hx = x @@ -311,9 +312,9 @@ def forward(self,x): hx4 = self.rebnconv4(hx3) - hx3d = self.rebnconv3d(paddle.concat((hx4,hx3),1)) - hx2d = self.rebnconv2d(paddle.concat((hx3d,hx2),1)) - hx1d = self.rebnconv1d(paddle.concat((hx2d,hx1),1)) + hx3d = self.rebnconv3d(paddle.concat((hx4, hx3), 1)) + hx2d = self.rebnconv2d(paddle.concat((hx3d, hx2), 1)) + hx1d = self.rebnconv1d(paddle.concat((hx2d, hx1), 1)) return hx1d + hxin @@ -321,46 +322,60 @@ def forward(self,x): ##### U^2-Net #### @manager.MODELS.add_component class U2Net(nn.Layer): - def __init__(self,in_ch=3,num_classes=1,pretrained=None): - super(U2Net,self).__init__() + """ + The U^2-Net implementation based on PaddlePaddle. + + The original article refers to + Xuebin Qin, et, al. "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection" + (https://arxiv.org/abs/1505.04597). + + Args: + num_classes (int): The unique number of target classes. + in_ch (int, optional): Input channels. Default: 3. + pretrained (str, optional): The path or url of pretrained model for fine tuning. Default: None. - self.stage1 = RSU7(in_ch,32,64) - self.pool12 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + """ - self.stage2 = RSU6(64,32,128) - self.pool23 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + def __init__(self, num_classes, in_ch=3, pretrained=None): + super(U2Net, self).__init__() - self.stage3 = RSU5(128,64,256) - self.pool34 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage1 = RSU7(in_ch, 32, 64) + self.pool12 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage4 = RSU4(256,128,512) - self.pool45 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage2 = RSU6(64, 32, 128) + self.pool23 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage5 = RSU4F(512,256,512) - self.pool56 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage3 = RSU5(128, 64, 256) + self.pool34 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage6 = RSU4F(512,256,512) + self.stage4 = RSU4(256, 128, 512) + self.pool45 = nn.MaxPool2D(2, stride=2, ceil_mode=True) + + self.stage5 = RSU4F(512, 256, 512) + self.pool56 = nn.MaxPool2D(2, stride=2, ceil_mode=True) + + self.stage6 = RSU4F(512, 256, 512) # decoder - self.stage5d = RSU4F(1024,256,512) - self.stage4d = RSU4(1024,128,256) - self.stage3d = RSU5(512,64,128) - self.stage2d = RSU6(256,32,64) - self.stage1d = RSU7(128,16,64) + self.stage5d = RSU4F(1024, 256, 512) + self.stage4d = RSU4(1024, 128, 256) + self.stage3d = RSU5(512, 64, 128) + self.stage2d = RSU6(256, 32, 64) + self.stage1d = RSU7(128, 16, 64) - self.side1 = nn.Conv2D(64,num_classes,3,padding=1) - self.side2 = nn.Conv2D(64,num_classes,3,padding=1) - self.side3 = nn.Conv2D(128,num_classes,3,padding=1) - self.side4 = nn.Conv2D(256,num_classes,3,padding=1) - self.side5 = nn.Conv2D(512,num_classes,3,padding=1) - self.side6 = nn.Conv2D(512,num_classes,3,padding=1) + self.side1 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side2 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side3 = nn.Conv2D(128, num_classes, 3, padding=1) + self.side4 = nn.Conv2D(256, num_classes, 3, padding=1) + self.side5 = nn.Conv2D(512, num_classes, 3, padding=1) + self.side6 = nn.Conv2D(512, num_classes, 3, padding=1) - self.outconv = nn.Conv2D(6*num_classes,num_classes,1) + self.outconv = nn.Conv2D(6 * num_classes, num_classes, 1) self.pretrained = pretrained self.init_weight() - - def forward(self,x): + + def forward(self, x): hx = x @@ -386,93 +401,95 @@ def forward(self,x): #stage 6 hx6 = self.stage6(hx) - hx6up = _upsample_like(hx6,hx5) + hx6up = _upsample_like(hx6, hx5) #-------------------- decoder -------------------- - hx5d = self.stage5d(paddle.concat((hx6up,hx5),1)) - hx5dup = _upsample_like(hx5d,hx4) + hx5d = self.stage5d(paddle.concat((hx6up, hx5), 1)) + hx5dup = _upsample_like(hx5d, hx4) - hx4d = self.stage4d(paddle.concat((hx5dup,hx4),1)) - hx4dup = _upsample_like(hx4d,hx3) + hx4d = self.stage4d(paddle.concat((hx5dup, hx4), 1)) + hx4dup = _upsample_like(hx4d, hx3) - hx3d = self.stage3d(paddle.concat((hx4dup,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.stage3d(paddle.concat((hx4dup, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.stage2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) - - hx1d = self.stage1d(paddle.concat((hx2dup,hx1),1)) + hx2d = self.stage2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) + hx1d = self.stage1d(paddle.concat((hx2dup, hx1), 1)) #side output d1 = self.side1(hx1d) d2 = self.side2(hx2d) - d2 = _upsample_like(d2,d1) + d2 = _upsample_like(d2, d1) d3 = self.side3(hx3d) - d3 = _upsample_like(d3,d1) + d3 = _upsample_like(d3, d1) d4 = self.side4(hx4d) - d4 = _upsample_like(d4,d1) + d4 = _upsample_like(d4, d1) d5 = self.side5(hx5d) - d5 = _upsample_like(d5,d1) + d5 = _upsample_like(d5, d1) d6 = self.side6(hx6) - d6 = _upsample_like(d6,d1) + d6 = _upsample_like(d6, d1) - d0 = self.outconv(paddle.concat((d1,d2,d3,d4,d5,d6),1)) + d0 = self.outconv(paddle.concat((d1, d2, d3, d4, d5, d6), 1)) - return [d0,d1,d2,d3,d4,d5,d6] + return [d0, d1, d2, d3, d4, d5, d6] def init_weight(self): if self.pretrained is not None: utils.load_entire_model(self, self.pretrained) + ### U^2-Net small ### @manager.MODELS.add_component class U2Netp(nn.Layer): - def __init__(self,in_ch=3,num_classes=1,pretrained=None): - super(U2Netp,self).__init__() + """Please Refer to DeepLabV3P above.""" + + def __init__(self, num_classes, in_ch=3, pretrained=None): + super(U2Netp, self).__init__() - self.stage1 = RSU7(in_ch,16,64) - self.pool12 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage1 = RSU7(in_ch, 16, 64) + self.pool12 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage2 = RSU6(64,16,64) - self.pool23 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage2 = RSU6(64, 16, 64) + self.pool23 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage3 = RSU5(64,16,64) - self.pool34 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage3 = RSU5(64, 16, 64) + self.pool34 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage4 = RSU4(64,16,64) - self.pool45 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage4 = RSU4(64, 16, 64) + self.pool45 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage5 = RSU4F(64,16,64) - self.pool56 = nn.MaxPool2D(2,stride=2,ceil_mode=True) + self.stage5 = RSU4F(64, 16, 64) + self.pool56 = nn.MaxPool2D(2, stride=2, ceil_mode=True) - self.stage6 = RSU4F(64,16,64) + self.stage6 = RSU4F(64, 16, 64) # decoder - self.stage5d = RSU4F(128,16,64) - self.stage4d = RSU4(128,16,64) - self.stage3d = RSU5(128,16,64) - self.stage2d = RSU6(128,16,64) - self.stage1d = RSU7(128,16,64) + self.stage5d = RSU4F(128, 16, 64) + self.stage4d = RSU4(128, 16, 64) + self.stage3d = RSU5(128, 16, 64) + self.stage2d = RSU6(128, 16, 64) + self.stage1d = RSU7(128, 16, 64) - self.side1 = nn.Conv2D(64,num_classes,3,padding=1) - self.side2 = nn.Conv2D(64,num_classes,3,padding=1) - self.side3 = nn.Conv2D(64,num_classes,3,padding=1) - self.side4 = nn.Conv2D(64,num_classes,3,padding=1) - self.side5 = nn.Conv2D(64,num_classes,3,padding=1) - self.side6 = nn.Conv2D(64,num_classes,3,padding=1) + self.side1 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side2 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side3 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side4 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side5 = nn.Conv2D(64, num_classes, 3, padding=1) + self.side6 = nn.Conv2D(64, num_classes, 3, padding=1) - self.outconv = nn.Conv2D(6*num_classes,num_classes,1) + self.outconv = nn.Conv2D(6 * num_classes, num_classes, 1) self.pretrained = pretrained self.init_weight() - def forward(self,x): + def forward(self, x): hx = x @@ -498,46 +515,45 @@ def forward(self,x): #stage 6 hx6 = self.stage6(hx) - hx6up = _upsample_like(hx6,hx5) + hx6up = _upsample_like(hx6, hx5) #decoder - hx5d = self.stage5d(paddle.concat((hx6up,hx5),1)) - hx5dup = _upsample_like(hx5d,hx4) + hx5d = self.stage5d(paddle.concat((hx6up, hx5), 1)) + hx5dup = _upsample_like(hx5d, hx4) - hx4d = self.stage4d(paddle.concat((hx5dup,hx4),1)) - hx4dup = _upsample_like(hx4d,hx3) + hx4d = self.stage4d(paddle.concat((hx5dup, hx4), 1)) + hx4dup = _upsample_like(hx4d, hx3) - hx3d = self.stage3d(paddle.concat((hx4dup,hx3),1)) - hx3dup = _upsample_like(hx3d,hx2) + hx3d = self.stage3d(paddle.concat((hx4dup, hx3), 1)) + hx3dup = _upsample_like(hx3d, hx2) - hx2d = self.stage2d(paddle.concat((hx3dup,hx2),1)) - hx2dup = _upsample_like(hx2d,hx1) - - hx1d = self.stage1d(paddle.concat((hx2dup,hx1),1)) + hx2d = self.stage2d(paddle.concat((hx3dup, hx2), 1)) + hx2dup = _upsample_like(hx2d, hx1) + hx1d = self.stage1d(paddle.concat((hx2dup, hx1), 1)) #side output d1 = self.side1(hx1d) d2 = self.side2(hx2d) - d2 = _upsample_like(d2,d1) + d2 = _upsample_like(d2, d1) d3 = self.side3(hx3d) - d3 = _upsample_like(d3,d1) + d3 = _upsample_like(d3, d1) d4 = self.side4(hx4d) - d4 = _upsample_like(d4,d1) + d4 = _upsample_like(d4, d1) d5 = self.side5(hx5d) - d5 = _upsample_like(d5,d1) + d5 = _upsample_like(d5, d1) d6 = self.side6(hx6) - d6 = _upsample_like(d6,d1) + d6 = _upsample_like(d6, d1) - d0 = self.outconv(paddle.concat((d1,d2,d3,d4,d5,d6),1)) + d0 = self.outconv(paddle.concat((d1, d2, d3, d4, d5, d6), 1)) - return [d0,d1,d2,d3,d4,d5,d6] + return [d0, d1, d2, d3, d4, d5, d6] def init_weight(self): if self.pretrained is not None: - utils.load_entire_model(self, self.pretrained) \ No newline at end of file + utils.load_entire_model(self, self.pretrained) From e488c14ea2efd32964cd00476d4158ffbce9e3c9 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Wed, 16 Dec 2020 21:26:33 +0800 Subject: [PATCH 22/35] add unet++ --- docs/apis/models.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/apis/models.md b/docs/apis/models.md index 54b5138afd..51e63d1a34 100644 --- a/docs/apis/models.md +++ b/docs/apis/models.md @@ -17,6 +17,7 @@ The models subpackage contains the following model for image sementic segmentaio - [U2Net](#U2Net) - [U2Net+](#U2Net+) - [AttentionUNet](#AttentionUNet) +- [UNet++](#UNet++) ## [DeepLabV3+](../../paddleseg/models/deeplab.py) > CLASS paddleseg.models.DeepLabV3P(num_classes, backbone, backbone_indices=(0, 3), aspp_ratios=(1, 6, 12, 18), aspp_out_channels=256, align_corners=False, pretrained=None) @@ -377,3 +378,27 @@ The models subpackage contains the following model for image sementic segmentaio > > Args > > > - **num_classes** (int): The unique number of target classes. > > > - **pretrained** (str, optional): The path or url of pretrained model. Default: None. + +## [UNet++](../../paddleseg/models/unet_plusplus.py) +> class UNetPlusPlus(in_channels, + num_classes, + use_deconv=False, + align_corners=False, + pretrained=None, + is_ds=True) + + The UNet++ implementation based on PaddlePaddle. + + The original article refers to + Zongwei Zhou, et, al. "UNet++: A Nested U-Net Architecture for Medical Image Segmentation" + (https://arxiv.org/abs/1807.10165). + +> > Args +> > > - **in_channels** (int): The channel number of input image. +> > > - **num_classes** (int): The unique number of target classes. +> > > - **use_deconv** (bool, optional): A bool value indicates whether using deconvolution in upsampling. + If False, use resize_bilinear. Default: False. +> > > - **align_corners** (bool): An argument of F.interpolate. It should be set to False when the output size of feature + is even, e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False. +> > > - **pretrained** (str, optional): The path or url of pretrained model for fine tuning. Default: None. +> > > - **is_ds** (bool): use deep supervision or not. Default: True From 063e3a887ede42cf8fd582dc3593aa07e9b4b1c2 Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:37:43 +0800 Subject: [PATCH 23/35] Update models.md --- docs/apis/models.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/apis/models.md b/docs/apis/models.md index 51e63d1a34..4511f7e3bd 100644 --- a/docs/apis/models.md +++ b/docs/apis/models.md @@ -1,8 +1,8 @@ # paddleseg.models The models subpackage contains the following model for image sementic segmentaion. -- [DeepLabV3+](#DeepLabV3+) -- [DeepLabV3](#DeepLabV3) +- [DeepLabV3+](#DeepLabV3) +- [DeepLabV3](#DeepLabV3-1) - [FCN](#FCN) - [OCRNet](#OCRNet) - [PSPNet](#PSPNet) @@ -14,10 +14,10 @@ The models subpackage contains the following model for image sementic segmentaio - [GSCNN](#GSCNN) - [HarDNet](#HarDNet) - [UNet](#UNet) -- [U2Net](#U2Net) -- [U2Net+](#U2Net+) +- [U2Net](#U2Net) +- [U2Net+](#U2Net-1) - [AttentionUNet](#AttentionUNet) -- [UNet++](#UNet++) +- [UNet++](#UNet-1) ## [DeepLabV3+](../../paddleseg/models/deeplab.py) > CLASS paddleseg.models.DeepLabV3P(num_classes, backbone, backbone_indices=(0, 3), aspp_ratios=(1, 6, 12, 18), aspp_out_channels=256, align_corners=False, pretrained=None) From a58530ce9bac4d9566f15ee645f7945537af47a2 Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:39:08 +0800 Subject: [PATCH 24/35] Update backbones.md --- docs/apis/backbones.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/apis/backbones.md b/docs/apis/backbones.md index 632ffac587..e7eaeebc86 100644 --- a/docs/apis/backbones.md +++ b/docs/apis/backbones.md @@ -5,7 +5,7 @@ The models subpackage contains backbones extracting features for sementic segmen - [ResNet_vd](#ResNet_vd) - [HRNet](#HRNet) - [MobileNetV3](#MobileNetV3) -- [Xception_deeplab](Xception_deeplab) +- [XceptionDeeplab](XceptionDeeplab) ## [ResNet_vd](../../paddleseg/models/backbones/resnet_vd.py) From 74529e75186b6b3e3d02ebc026a50bcec2d2e9de Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:41:47 +0800 Subject: [PATCH 25/35] Update backbones.md --- docs/apis/backbones.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/apis/backbones.md b/docs/apis/backbones.md index e7eaeebc86..45b863b305 100644 --- a/docs/apis/backbones.md +++ b/docs/apis/backbones.md @@ -5,7 +5,7 @@ The models subpackage contains backbones extracting features for sementic segmen - [ResNet_vd](#ResNet_vd) - [HRNet](#HRNet) - [MobileNetV3](#MobileNetV3) -- [XceptionDeeplab](XceptionDeeplab) +- [XceptionDeeplab](#xceptiondeeplab) ## [ResNet_vd](../../paddleseg/models/backbones/resnet_vd.py) From f5712fc192c2ce717d1dc8634d0685ba773a9ee6 Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:44:03 +0800 Subject: [PATCH 26/35] Update cvlibs.md --- docs/apis/cvlibs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/apis/cvlibs.md b/docs/apis/cvlibs.md index fb73819bc0..9ea3ad9343 100644 --- a/docs/apis/cvlibs.md +++ b/docs/apis/cvlibs.md @@ -1,7 +1,7 @@ # paddleseg.cvlibs - [Manager](#Manager) -- [Parameters Initialization](#Parameters Initialization) +- [Parameters Initialization](#parameters-initialization) - [Config](#Config) From fb09b9c21c53deceb090ad642cfb96a991ad561a Mon Sep 17 00:00:00 2001 From: wuyefeilin <30919197+wuyefeilin@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:45:11 +0800 Subject: [PATCH 27/35] Update datasets.md --- docs/apis/datasets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/apis/datasets.md b/docs/apis/datasets.md index 1ad6917dda..bef2aa7a87 100644 --- a/docs/apis/datasets.md +++ b/docs/apis/datasets.md @@ -1,5 +1,5 @@ # paddleseg.datasets -- [Custom Dataset](#Custom) +- [Custom Dataset](#custom-dataset) - [Cityscapes](#Cityscapes) - [PascalVOC](#PascalVOC) - [ADE20K](#ADE20K) From 751193a6092f344c014ee276e73b8b162de294ac Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 18 Dec 2020 10:30:13 +0800 Subject: [PATCH 28/35] add api tutorial --- README.md | 1 + README_CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index ae4bdbfe78..0513545a76 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml ## Tutorials * [Get Started](./docs/quick_start.md) +* [API Tutorial](https://aistudio.baidu.com/aistudio/projectdetail/1339458) * [Data Preparation](./docs/data_prepare.md) * [Training Configuration](./configs/) * [Add New Components](./docs/add_new_model.md) diff --git a/README_CN.md b/README_CN.md index 522d21041b..33211a0dea 100644 --- a/README_CN.md +++ b/README_CN.md @@ -74,6 +74,7 @@ python train.py --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml ## 使用教程 * [快速入门](./docs/quick_start.md) +* [API使用教程](https://aistudio.baidu.com/aistudio/projectdetail/1339458) * [数据集准备](./docs/data_prepare.md) * [配置项](./configs/) * [Add New Components](./docs/add_new_model.md) From 8b25d0672e84ef07e797aaea5bf17337d9ff17b9 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 18 Dec 2020 11:58:35 +0800 Subject: [PATCH 29/35] fix bce loss bug --- ...gscnn_resnet50_os8_cityscapes_1024x512_80k.yml | 1 + paddleseg/core/train.py | 3 ++- paddleseg/models/losses/__init__.py | 2 +- .../models/losses/binary_cross_entroy_loss.py | 15 +++++++++++++-- ...{dual_task_loss.py => gscnn_dual_task_loss.py} | 0 5 files changed, 17 insertions(+), 4 deletions(-) rename paddleseg/models/losses/{dual_task_loss.py => gscnn_dual_task_loss.py} (100%) diff --git a/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml b/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml index eacde21a0f..35a5f32c3a 100644 --- a/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml +++ b/configs/gscnn/gscnn_resnet50_os8_cityscapes_1024x512_80k.yml @@ -22,6 +22,7 @@ loss: - type: CrossEntropyLoss - type: EdgeAttentionLoss - type: BCELoss + edge_label: True - type: DualTaskLoss coef: [1, 1, 20, 1] diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index d3cc4b42af..06d003caf9 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -39,7 +39,8 @@ def loss_computation(logits_list, labels, losses, edges=None): loss_i = losses['types'][i] # Whether to use edges as labels According to loss type . if loss_i.__class__.__name__ in ('BCELoss', ): - labels = edges + if loss_i.edge_label: + labels = edges loss += losses['coef'][i] * loss_i(logits, labels) return loss diff --git a/paddleseg/models/losses/__init__.py b/paddleseg/models/losses/__init__.py index 110ff3fe02..c62b560770 100644 --- a/paddleseg/models/losses/__init__.py +++ b/paddleseg/models/losses/__init__.py @@ -14,7 +14,7 @@ from .cross_entroy_loss import CrossEntropyLoss from .binary_cross_entroy_loss import BCELoss -from .dual_task_loss import DualTaskLoss +from .gscnn_dual_task_loss import DualTaskLoss from .edge_attention_loss import EdgeAttentionLoss from .bootstrapped_cross_entropy import BootstrappedCrossEntropyLoss from .dice_loss import DiceLoss diff --git a/paddleseg/models/losses/binary_cross_entroy_loss.py b/paddleseg/models/losses/binary_cross_entroy_loss.py index 49e11f57f0..cb1f2ce8d8 100644 --- a/paddleseg/models/losses/binary_cross_entroy_loss.py +++ b/paddleseg/models/losses/binary_cross_entroy_loss.py @@ -58,8 +58,9 @@ class BCELoss(nn.Layer): pos_weight (float|str, optional): A weight of positive examples. If type is str, it should equal to 'dynamic'. It will compute weight dynamically in every step. Default is ``'None'``. - ignore_index (int64): Specifies a target value that is ignored + ignore_index (int64, optional): Specifies a target value that is ignored and does not contribute to the input gradient. Default ``255``. + edge_label (bool, optional): Whether to use edge label. Default: False Shapes: logit (Tensor): The input predications tensor. 2-D tensor with shape: [N, *], N is batch_size, `*` means number of additional dimensions. The ``logit`` @@ -80,11 +81,16 @@ class BCELoss(nn.Layer): print(output.numpy()) # [0.45618808] """ - def __init__(self, weight=None, pos_weight=None, ignore_index=255): + def __init__(self, + weight=None, + pos_weight=None, + ignore_index=255, + edge_label=False): super().__init__() self.weight = weight self.pos_weight = pos_weight self.ignore_index = ignore_index + self.edge_label = edge_label if self.weight is not None: if isinstance(self.weight, str): @@ -126,6 +132,11 @@ def forward(self, logit, label): eps = 1e-6 if len(label.shape) != len(logit.shape): label = paddle.unsqueeze(label, 1) + # label.shape should equal to the logit.shape + if label.shape[1] != logit.shape[1]: + label = label.squeeze(1) + label = F.one_hot(label, logit.shape[1]) + label = label.transpose((0, 3, 1, 2)) mask = (label != self.ignore_index) mask = paddle.cast(mask, 'float32') if isinstance(self.weight, str): diff --git a/paddleseg/models/losses/dual_task_loss.py b/paddleseg/models/losses/gscnn_dual_task_loss.py similarity index 100% rename from paddleseg/models/losses/dual_task_loss.py rename to paddleseg/models/losses/gscnn_dual_task_loss.py From 160b5c457eaa131d2c607bb2cbe7aa1070d65a02 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 21 Dec 2020 17:27:25 +0800 Subject: [PATCH 30/35] update paddle-2.0rc1 --- paddleseg/core/predict.py | 117 ++++++++++++++++++----------------- paddleseg/core/val.py | 127 +++++++++++++++++++------------------- 2 files changed, 123 insertions(+), 121 deletions(-) diff --git a/paddleseg/core/predict.py b/paddleseg/core/predict.py index c95c45c493..1f7a16a0a6 100644 --- a/paddleseg/core/predict.py +++ b/paddleseg/core/predict.py @@ -72,61 +72,62 @@ def predict(model, logger.info("Start to predict...") progbar_pred = progbar.Progbar(target=len(image_list), verbose=1) - for i, im_path in enumerate(image_list): - im = cv2.imread(im_path) - ori_shape = im.shape[:2] - im, _ = transforms(im) - im = im[np.newaxis, ...] - im = paddle.to_tensor(im) - - if aug_pred: - pred = infer.aug_inference( - model, - im, - ori_shape=ori_shape, - transforms=transforms.transforms, - scales=scales, - flip_horizontal=flip_horizontal, - flip_vertical=flip_vertical, - is_slide=is_slide, - stride=stride, - crop_size=crop_size) - else: - pred = infer.inference( - model, - im, - ori_shape=ori_shape, - transforms=transforms.transforms, - is_slide=is_slide, - stride=stride, - crop_size=crop_size) - pred = paddle.squeeze(pred) - pred = pred.numpy().astype('uint8') - - # get the saved name - if image_dir is not None: - im_file = im_path.replace(image_dir, '') - else: - im_file = os.path.basename(im_path) - if im_file[0] == '/': - im_file = im_file[1:] - - # save added image - added_image = utils.visualize.visualize(im_path, pred, weight=0.6) - added_image_path = os.path.join(added_saved_dir, im_file) - mkdir(added_image_path) - cv2.imwrite(added_image_path, added_image) - - # save pseudo color prediction - pred_mask = utils.visualize.get_pseudo_color_map(pred) - pred_saved_path = os.path.join(pred_saved_dir, - im_file.rsplit(".")[0] + ".png") - mkdir(pred_saved_path) - pred_mask.save(pred_saved_path) - - # pred_im = utils.visualize(im_path, pred, weight=0.0) - # pred_saved_path = os.path.join(pred_saved_dir, im_file) - # mkdir(pred_saved_path) - # cv2.imwrite(pred_saved_path, pred_im) - - progbar_pred.update(i + 1) + with paddle.no_grad(): + for i, im_path in enumerate(image_list): + im = cv2.imread(im_path) + ori_shape = im.shape[:2] + im, _ = transforms(im) + im = im[np.newaxis, ...] + im = paddle.to_tensor(im) + + if aug_pred: + pred = infer.aug_inference( + model, + im, + ori_shape=ori_shape, + transforms=transforms.transforms, + scales=scales, + flip_horizontal=flip_horizontal, + flip_vertical=flip_vertical, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + else: + pred = infer.inference( + model, + im, + ori_shape=ori_shape, + transforms=transforms.transforms, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + pred = paddle.squeeze(pred) + pred = pred.numpy().astype('uint8') + + # get the saved name + if image_dir is not None: + im_file = im_path.replace(image_dir, '') + else: + im_file = os.path.basename(im_path) + if im_file[0] == '/': + im_file = im_file[1:] + + # save added image + added_image = utils.visualize.visualize(im_path, pred, weight=0.6) + added_image_path = os.path.join(added_saved_dir, im_file) + mkdir(added_image_path) + cv2.imwrite(added_image_path, added_image) + + # save pseudo color prediction + pred_mask = utils.visualize.get_pseudo_color_map(pred) + pred_saved_path = os.path.join(pred_saved_dir, + im_file.rsplit(".")[0] + ".png") + mkdir(pred_saved_path) + pred_mask.save(pred_saved_path) + + # pred_im = utils.visualize(im_path, pred, weight=0.0) + # pred_saved_path = os.path.join(pred_saved_dir, im_file) + # mkdir(pred_saved_path) + # cv2.imwrite(pred_saved_path, pred_im) + + progbar_pred.update(i + 1) diff --git a/paddleseg/core/val.py b/paddleseg/core/val.py index c5447cbcb8..cdf0a348b9 100644 --- a/paddleseg/core/val.py +++ b/paddleseg/core/val.py @@ -81,69 +81,70 @@ def evaluate(model, len(eval_dataset), total_iters)) progbar_val = progbar.Progbar(target=total_iters, verbose=1) timer = Timer() - for iter, (im, label) in enumerate(loader): - reader_cost = timer.elapsed_time() - label = label.astype('int64') - - ori_shape = label.shape[-2:] - if aug_eval: - pred = infer.aug_inference( - model, - im, - ori_shape=ori_shape, - transforms=eval_dataset.transforms.transforms, - scales=scales, - flip_horizontal=flip_horizontal, - flip_vertical=flip_vertical, - is_slide=is_slide, - stride=stride, - crop_size=crop_size) - else: - pred = infer.inference( - model, - im, - ori_shape=ori_shape, - transforms=eval_dataset.transforms.transforms, - is_slide=is_slide, - stride=stride, - crop_size=crop_size) - - intersect_area, pred_area, label_area = metrics.calculate_area( - pred, - label, - eval_dataset.num_classes, - ignore_index=eval_dataset.ignore_index) - - # Gather from all ranks - if nranks > 1: - intersect_area_list = [] - pred_area_list = [] - label_area_list = [] - paddle.distributed.all_gather(intersect_area_list, intersect_area) - paddle.distributed.all_gather(pred_area_list, pred_area) - paddle.distributed.all_gather(label_area_list, label_area) - - # Some image has been evaluated and should be eliminated in last iter - if (iter + 1) * nranks > len(eval_dataset): - valid = len(eval_dataset) - iter * nranks - intersect_area_list = intersect_area_list[:valid] - pred_area_list = pred_area_list[:valid] - label_area_list = label_area_list[:valid] - - for i in range(len(intersect_area_list)): - intersect_area_all = intersect_area_all + intersect_area_list[i] - pred_area_all = pred_area_all + pred_area_list[i] - label_area_all = label_area_all + label_area_list[i] - else: - intersect_area_all = intersect_area_all + intersect_area - pred_area_all = pred_area_all + pred_area - label_area_all = label_area_all + label_area - batch_cost = timer.elapsed_time() - timer.restart() - - if local_rank == 0: - progbar_val.update(iter + 1, [('batch_cost', batch_cost), - ('reader cost', reader_cost)]) + with paddle.no_grad(): + for iter, (im, label) in enumerate(loader): + reader_cost = timer.elapsed_time() + label = label.astype('int64') + + ori_shape = label.shape[-2:] + if aug_eval: + pred = infer.aug_inference( + model, + im, + ori_shape=ori_shape, + transforms=eval_dataset.transforms.transforms, + scales=scales, + flip_horizontal=flip_horizontal, + flip_vertical=flip_vertical, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + else: + pred = infer.inference( + model, + im, + ori_shape=ori_shape, + transforms=eval_dataset.transforms.transforms, + is_slide=is_slide, + stride=stride, + crop_size=crop_size) + + intersect_area, pred_area, label_area = metrics.calculate_area( + pred, + label, + eval_dataset.num_classes, + ignore_index=eval_dataset.ignore_index) + + # Gather from all ranks + if nranks > 1: + intersect_area_list = [] + pred_area_list = [] + label_area_list = [] + paddle.distributed.all_gather(intersect_area_list, intersect_area) + paddle.distributed.all_gather(pred_area_list, pred_area) + paddle.distributed.all_gather(label_area_list, label_area) + + # Some image has been evaluated and should be eliminated in last iter + if (iter + 1) * nranks > len(eval_dataset): + valid = len(eval_dataset) - iter * nranks + intersect_area_list = intersect_area_list[:valid] + pred_area_list = pred_area_list[:valid] + label_area_list = label_area_list[:valid] + + for i in range(len(intersect_area_list)): + intersect_area_all = intersect_area_all + intersect_area_list[i] + pred_area_all = pred_area_all + pred_area_list[i] + label_area_all = label_area_all + label_area_list[i] + else: + intersect_area_all = intersect_area_all + intersect_area + pred_area_all = pred_area_all + pred_area + label_area_all = label_area_all + label_area + batch_cost = timer.elapsed_time() + timer.restart() + + if local_rank == 0: + progbar_val.update(iter + 1, [('batch_cost', batch_cost), + ('reader cost', reader_cost)]) class_iou, miou = metrics.mean_iou(intersect_area_all, pred_area_all, label_area_all) From d7bc1e65ddabbe46d788abe66f38f455600951e5 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Tue, 29 Dec 2020 11:35:29 +0800 Subject: [PATCH 31/35] add keep_checkpoint_max --- docs/quick_start.md | 1 + paddleseg/core/train.py | 22 +++++++++++----------- paddleseg/utils/utils.py | 14 ++------------ train.py | 11 ++++++----- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/docs/quick_start.md b/docs/quick_start.md index 30f14b1c17..b4d4a232ea 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -40,6 +40,7 @@ python train.py \ |do_eval|是否在保存模型时启动评估, 启动时将会根据mIoU保存最佳模型至best_model|否|否| |log_iters|打印日志的间隔步数|否|10| |resume_model|恢复训练模型路径,如:`output/iter_1000`|否|None| +|keep_checkpoint_max|最新模型保存个数|否|5| **注意**:如果想要使用多卡训练的话,需要将环境变量CUDA_VISIBLE_DEVICES指定为多卡(不指定时默认使用所有的gpu),并使用paddle.distributed.launch启动训练脚本(windows下由于不支持nccl,无法使用多卡训练): diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index 8331829fa8..46b14a991f 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -14,6 +14,8 @@ import os import time +from collections import deque +import shutil import paddle import paddle.nn.functional as F @@ -58,7 +60,7 @@ def train(model, num_workers=0, use_vdl=False, losses=None, - save_latest_only=False): + keep_checkpoint_max=5): """ Launch training. @@ -77,7 +79,7 @@ def train(model, use_vdl (bool, optional): Whether to record the data to VisualDL during training. Default: False. losses (dict): A dict including 'types' and 'coef'. The length of coef should equal to 1 or len(losses['types']). The 'types' item is a list of object of paddleseg.models.losses while the 'coef' item is a list of the relevant coefficient. - save_latest_only (bool, optional): Save latest model only. Default: False. + keep_checkpoint_max (int, optional): The max checkpoints to save. Default: 5. """ nranks = paddle.distributed.ParallelEnv().nranks local_rank = paddle.distributed.ParallelEnv().local_rank @@ -118,6 +120,7 @@ def train(model, best_model_iter = -1 train_reader_cost = 0.0 train_batch_cost = 0.0 + save_models = deque() timer.start() iter = start_iter @@ -183,21 +186,18 @@ def train(model, model.train() if (iter % save_interval == 0 or iter == iters) and local_rank == 0: - if save_latest_only: - current_save_dir = os.path.join(save_dir, 'latest_model') - else: - current_save_dir = os.path.join(save_dir, - "iter_{}".format(iter)) + current_save_dir = os.path.join(save_dir, + "iter_{}".format(iter)) if not os.path.isdir(current_save_dir): os.makedirs(current_save_dir) paddle.save(model.state_dict(), os.path.join(current_save_dir, 'model.pdparams')) paddle.save(optimizer.state_dict(), os.path.join(current_save_dir, 'model.pdopt')) - if save_latest_only: - with open(os.path.join(current_save_dir, 'iter.txt'), - 'w') as f: - f.write(str(iter)) + save_models.append(current_save_dir) + if len(save_models) > keep_checkpoint_max > 0: + model_to_remove = save_models.popleft() + shutil.rmtree(model_to_remove) if val_dataset is not None: if mean_iou > best_mean_iou: diff --git a/paddleseg/utils/utils.py b/paddleseg/utils/utils.py index 20a461be64..73a298d196 100644 --- a/paddleseg/utils/utils.py +++ b/paddleseg/utils/utils.py @@ -109,18 +109,8 @@ def resume(model, optimizer, resume_model): model.set_state_dict(para_state_dict) optimizer.set_state_dict(opti_state_dict) - iter_txt = os.path.join(resume_model, 'iter.txt') - if os.path.exists(iter_txt): - with open(iter_txt, 'r') as f: - iter = f.read() - iter = int(iter) - elif 'iter' in resume_model: - iter = resume_model.split('_')[-1] - iter = int(iter) - else: - raise ValueError( - 'Can not get iter. Please check your resume_model: {}'. - format(resume_model)) + iter = resume_model.split('_')[-1] + iter = int(iter) return iter else: raise ValueError( diff --git a/train.py b/train.py index c940c4c2c1..58319f7051 100644 --- a/train.py +++ b/train.py @@ -63,10 +63,11 @@ def parse_args(): type=str, default='./output') parser.add_argument( - '--save_latest_only', - dest='save_latest_only', - help='Save latest model only', - action='store_true') + '--keep_checkpoint_max', + dest='keep_checkpoint_max', + help='The max checkpoints to save', + type=int, + default=5) parser.add_argument( '--num_workers', dest='num_workers', @@ -139,7 +140,7 @@ def main(args): num_workers=args.num_workers, use_vdl=args.use_vdl, losses=losses, - save_latest_only=args.save_latest_only) + keep_checkpoint_max=args.keep_checkpoint_max) if __name__ == '__main__': From 25852a0d0c29a64a1b08d637290829334927df02 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Mon, 4 Jan 2021 11:11:12 +0800 Subject: [PATCH 32/35] update unet.py --- paddleseg/models/unet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddleseg/models/unet.py b/paddleseg/models/unet.py index 2c9eaa9e50..0dc8cf75e8 100644 --- a/paddleseg/models/unet.py +++ b/paddleseg/models/unet.py @@ -127,7 +127,7 @@ def __init__(self, self.use_deconv = use_deconv if self.use_deconv: - self.deconv = nn.ConvTranspose2D( + self.deconv = nn.Conv2DTranspose( in_channels, out_channels // 2, kernel_size=2, From ca8d5da8dd16c15d3d72efab24a33f377e6904dd Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Fri, 8 Jan 2021 15:24:23 +0800 Subject: [PATCH 33/35] add flops calculation --- paddleseg/core/train.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index 881e1da4cf..dfb8eb6653 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -216,6 +216,20 @@ def train(model, log_writer.add_scalar('Evaluate/Acc', acc, iter) timer.restart() + # Calculate flops. + if local_rank == 0: + + def count_syncbn(m, x, y): + x = x[0] + nelements = x.numel() + m.total_ops += int(2 * nelements) + + _, c, h, w = images.shape + flops = paddle.flops( + model, [1, c, h, w], + custom_ops={paddle.nn.SyncBatchNorm: count_syncbn}) + logger.info(flops) + # Sleep for half a second to let dataloader release resources. time.sleep(0.5) if use_vdl: From e559aa2c6d36ced5ba8eebc65f078c889e34cccc Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Wed, 13 Jan 2021 17:59:32 +0800 Subject: [PATCH 34/35] rm prepare_context --- paddleseg/core/train.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/paddleseg/core/train.py b/paddleseg/core/train.py index dfb8eb6653..746abc8948 100644 --- a/paddleseg/core/train.py +++ b/paddleseg/core/train.py @@ -96,8 +96,7 @@ def train(model, if nranks > 1: # Initialize parallel training environment. paddle.distributed.init_parallel_env() - strategy = paddle.distributed.prepare_context() - ddp_model = paddle.DataParallel(model, strategy) + ddp_model = paddle.DataParallel(model) batch_sampler = paddle.io.DistributedBatchSampler( train_dataset, batch_size=batch_size, shuffle=True, drop_last=True) From c95b82ff11cbcceafb54e8d714d124734be5155c Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Thu, 14 Jan 2021 10:18:06 +0800 Subject: [PATCH 35/35] add LimitLong transform --- paddleseg/core/infer.py | 17 ++++++++ paddleseg/core/val.py | 6 ++- paddleseg/transforms/transforms.py | 65 ++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/paddleseg/core/infer.py b/paddleseg/core/infer.py index bfb3888909..9d6df78b8a 100644 --- a/paddleseg/core/infer.py +++ b/paddleseg/core/infer.py @@ -42,6 +42,23 @@ def get_reverse_list(ori_shape, transforms): if op.__class__.__name__ in ['Padding']: reverse_list.append(('padding', (h, w))) w, h = op.target_size[0], op.target_size[1] + if op.__class__.__name__ in ['LimitLong']: + long_edge = max(h, w) + short_edge = min(h, w) + if ((op.max_long is not None) and (long_edge > op.max_long)): + reverse_list.append(('resize', (h, w))) + long_edge = op.max_long + short_edge = int(round(short_edge * op.max_long / long_edge)) + elif ((op.min_long is not None) and (long_edge < op.min_long)): + reverse_list.append(('resize', (h, w))) + long_edge = op.min_long + short_edge = int(round(short_edge * op.min_long / long_edge)) + if h > w: + h = long_edge + w = short_edge + else: + w = long_edge + h = short_edge return reverse_list diff --git a/paddleseg/core/val.py b/paddleseg/core/val.py index cdf0a348b9..a1a4526b2e 100644 --- a/paddleseg/core/val.py +++ b/paddleseg/core/val.py @@ -120,7 +120,8 @@ def evaluate(model, intersect_area_list = [] pred_area_list = [] label_area_list = [] - paddle.distributed.all_gather(intersect_area_list, intersect_area) + paddle.distributed.all_gather(intersect_area_list, + intersect_area) paddle.distributed.all_gather(pred_area_list, pred_area) paddle.distributed.all_gather(label_area_list, label_area) @@ -132,7 +133,8 @@ def evaluate(model, label_area_list = label_area_list[:valid] for i in range(len(intersect_area_list)): - intersect_area_all = intersect_area_all + intersect_area_list[i] + intersect_area_all = intersect_area_all + intersect_area_list[ + i] pred_area_all = pred_area_all + pred_area_list[i] label_area_all = label_area_all + label_area_list[i] else: diff --git a/paddleseg/transforms/transforms.py b/paddleseg/transforms/transforms.py index 7f285ed340..52ba7a29f7 100644 --- a/paddleseg/transforms/transforms.py +++ b/paddleseg/transforms/transforms.py @@ -228,6 +228,71 @@ def __call__(self, im, label=None): return (im, label) +@manager.TRANSFORMS.add_component +class LimitLong: + """ + Limit the long edge of image. + + If the long edge is larger than max_long, resize the long edge + to max_long, while scale the short edge proportionally. + + If the long edge is smaller than min_long, resize the long edge + to min_long, while scale the short edge proportionally. + + Args: + max_long (int, optional): If the long edge of image is larger than max_long, + it will be resize to max_long. Default: None. + min_long (int, optional): If the long edge of image is smaller than min_long, + it will be resize to min_long. Default: None. + """ + + def __init__(self, max_long=None, min_long=None): + if max_long is not None: + if not isinstance(max_long, int): + raise TypeError( + "Type of `max_long` is invalid. It should be int, but it is {}" + .format(type(max_long))) + if min_long is not None: + if not isinstance(min_long, int): + raise TypeError( + "Type of `min_long` is invalid. It should be int, but it is {}" + .format(type(min_long))) + if (max_long is not None) and (min_long is not None): + if min_long > max_long: + raise ValueError( + '`max_long should not smaller than min_long, but they are {} and {}' + .format(max_long, min_long)) + self.max_long = max_long + self.min_long = min_long + + def __call__(self, im, label=None): + """ + Args: + im (np.ndarray): The Image data. + label (np.ndarray, optional): The label data. Default: None. + + Returns: + (tuple). When label is None, it returns (im, ), otherwise it returns (im, label). + """ + h, w = im.shape[0], im.shape[1] + long_edge = max(h, w) + target = long_edge + if (self.max_long is not None) and (long_edge > self.max_long): + target = self.max_long + elif (self.min_long is not None) and (long_edge < self.min_long): + target = self.min_long + + if target != long_edge: + im = functional.resize_long(im, target) + if label is not None: + label = functional.resize_long(label, target, cv2.INTER_NEAREST) + + if label is None: + return (im, ) + else: + return (im, label) + + @manager.TRANSFORMS.add_component class ResizeRangeScaling: """