From 13cb99cf5eca06a479c6fc80f36f25abc08aeb99 Mon Sep 17 00:00:00 2001 From: LutaoChu <30695251+LutaoChu@users.noreply.github.com> Date: Wed, 29 Dec 2021 19:39:52 +0800 Subject: [PATCH] [CityscapesSOTA] Fix incompatibility in PaddlePaddle 2.2 (#1595) (#1671) --- contrib/CityscapesSOTA/README.md | 20 +++++++++++++------ .../CityscapesSOTA/models/mscale_ocrnet.py | 5 +---- contrib/CityscapesSOTA/scripts/train.py | 3 ++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/contrib/CityscapesSOTA/README.md b/contrib/CityscapesSOTA/README.md index 0a016b9dbb..8594e126d4 100644 --- a/contrib/CityscapesSOTA/README.md +++ b/contrib/CityscapesSOTA/README.md @@ -8,8 +8,11 @@ Based on the above work, we made some optimizations: We achieve mIoU of **87%** on Cityscapes validation set. -![demo](https://user-images.githubusercontent.com/53808988/130719591-3e0d44b4-59a8-4633-bff2-7ce7da1c52fc.gif) +The actual effect is as follows (for high-definition pictures, please click [here](https://github.com/PaddlePaddle/PaddleSeg/blob/release/v2.0/docs/images/cityscapes.gif)). +
+ +
## Installation @@ -37,9 +40,9 @@ mkdir -p data/cityscapes ``` Firstly please download 3 files from [Cityscapes dataset](https://www.cityscapes-dataset.com/downloads/) -- leftImg8bit_trainvaltest.zip -- gtFine_trainvaltest.zip -- leftImg8bit_trainextra.zip +- leftImg8bit_trainvaltest.zip (11GB) +- gtFine_trainvaltest.zip (241MB) +- leftImg8bit_trainextra.zip (44GB) Run the following commands to do the label conversion: ```shell @@ -48,8 +51,13 @@ python ../../tools/convert_cityscapes.py --cityscapes_path data/cityscapes --num ``` Where 'cityscapes_path' should be adjusted according to the actual dataset path. 'num_workers' determines the number of processes started and the size can be adjusted according to the actual situation. -Then download Autolabelled-Data from [google drive](https://drive.google.com/file/d/1DtPo-WP-hjaOwsbj6ZxTtOo_7R_4TKRG/view?usp=sharing) -- refinement_final_v0.zip +Then download and uncompress Autolabelled-Data from [google drive](https://drive.google.com/file/d/1DtPo-WP-hjaOwsbj6ZxTtOo_7R_4TKRG/view?usp=sharing) +- refinement_final_v0.zip # This file is needed for autolabelled training for recreating SOTA + +Delete useless `tmp` directory in `refinement_final` directory. +``` +rm -r tmp/ +``` Convert autolabelled data according to PaddleSeg data format: ```shell diff --git a/contrib/CityscapesSOTA/models/mscale_ocrnet.py b/contrib/CityscapesSOTA/models/mscale_ocrnet.py index 9b992e06e4..0d7be21e71 100644 --- a/contrib/CityscapesSOTA/models/mscale_ocrnet.py +++ b/contrib/CityscapesSOTA/models/mscale_ocrnet.py @@ -196,8 +196,5 @@ def scale_as(x, y, align_corners=False): ''' y_shape = paddle.shape(y) x_scaled = nn.functional.interpolate( - x, - size=(y_shape[2], y_shape[3]), - mode='bilinear', - align_corners=align_corners) + x, size=y_shape[2:], mode='bilinear', align_corners=align_corners) return x_scaled diff --git a/contrib/CityscapesSOTA/scripts/train.py b/contrib/CityscapesSOTA/scripts/train.py index 445e6969c0..11cd6f353d 100644 --- a/contrib/CityscapesSOTA/scripts/train.py +++ b/contrib/CityscapesSOTA/scripts/train.py @@ -207,7 +207,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( + metrics = evaluate( model, val_dataset, aug_eval=aug_eval, @@ -218,6 +218,7 @@ def train(model, stride=None, crop_size=None, num_workers=num_workers) + mean_iou, acc = metrics[0], metrics[1] model.train() if (iter % save_interval == 0 or iter == iters) and local_rank == 0: