Skip to content

Commit

Permalink
[CityscapesSOTA] Fix incompatibility in PaddlePaddle 2.2 (#1595) (#1671)
Browse files Browse the repository at this point in the history
  • Loading branch information
LutaoChu authored Dec 29, 2021
1 parent 6800933 commit 13cb99c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
20 changes: 14 additions & 6 deletions contrib/CityscapesSOTA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).

<div align="center">
<img src=https://user-images.githubusercontent.com/30695251/144982303-51d40188-c00d-46b7-9012-41955c4e2156.gif width = "500" />
</div>

## Installation

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions contrib/CityscapesSOTA/models/mscale_ocrnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion contrib/CityscapesSOTA/scripts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down

0 comments on commit 13cb99c

Please sign in to comment.