Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support DDRNet #2855

Merged
merged 9 commits into from
Apr 27, 2023
Merged

[Feature] Support DDRNet #2855

merged 9 commits into from
Apr 27, 2023

Conversation

whu-pzhang
Copy link
Contributor

@whu-pzhang whu-pzhang commented Apr 6, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Support DDRNet
Paper: Deep Dual-resolution Networks for Real-time and Accurate Semantic Segmentation of Road Scenes
official Code: https://github.com/ydhongHIT/DDRNet

There is already a PR #1722 , but it has been inactive for a long time.

Current Result

Cityscapes

inference with converted official weights

Method Backbone mIoU(official) mIoU(converted weight)
DDRNet DDRNet23-slim 77.8 77.84
DDRNet DDRNet23 79.5 79.53

training with converted pretrained backbone

Method Backbone Crop Size Lr schd Inf time(fps) Device mIoU mIoU(ms+flip) config download
DDRNet DDRNet23-slim 1024x1024 120000 85.85 RTX 8000 77.85 79.80 config model | log
DDRNet DDRNet23 1024x1024 120000 33.41 RTX 8000 79.53 80.98 config model | log

The converted pretrained backbone weights download link:

  1. ddrnet23s_in1k_mmseg.pth
  2. ddrnet23_in1k_mmseg.pth

To do

  • support inference with converted official weights
  • support training on cityscapes dataset

@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.42 ⚠️

Comparison is base (534b27b) 83.33% compared to head (4e63cb2) 82.92%.

❗ Current head 4e63cb2 differs from pull request most recent head 14f6176. Consider uploading reports for the commit 14f6176 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           dev-1.x    #2855      +/-   ##
===========================================
- Coverage    83.33%   82.92%   -0.42%     
===========================================
  Files          143      158      +15     
  Lines         8127     9465    +1338     
  Branches      1211     1384     +173     
===========================================
+ Hits          6773     7849    +1076     
- Misses        1165     1374     +209     
- Partials       189      242      +53     
Flag Coverage Δ
unittests 82.92% <ø> (-0.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/__init__.py 92.10% <ø> (ø)
mmseg/apis/__init__.py 100.00% <ø> (+100.00%) ⬆️
mmseg/apis/inference.py 23.15% <ø> (+23.15%) ⬆️
mmseg/apis/mmseg_inferencer.py 74.38% <ø> (ø)
mmseg/datasets/__init__.py 100.00% <ø> (ø)
mmseg/datasets/basesegdataset.py 100.00% <ø> (+1.02%) ⬆️
mmseg/datasets/dataset_wrappers.py 49.18% <ø> (ø)
mmseg/datasets/isaid.py 100.00% <ø> (ø)
mmseg/datasets/mapillary.py 91.66% <ø> (ø)
mmseg/datasets/refuge.py 100.00% <ø> (ø)
... and 15 more

... and 27 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MengzhangLI
Copy link
Contributor

The results look pretty good, the old pr was not merged mainly because I can not re-implement training metric. And it was not in developing schedule so I did not have time to figure it out.

@whu-pzhang
Copy link
Contributor Author

Hi, how to download mmseg style checkpoint file? I ran into an error like this using official pretrained weights unexpected key in source state_dict: model.conv1.0.weight, model.conv1.0.bias, model.conv1.1.weight, model.conv1.1.bias, model.conv1.1.running_mean, model.conv1.1.running_var, model.conv1.1.num_batches_tracked, model.conv1.3.weight, model.conv1.3.bias, model.conv1.4.weight, model.conv1.4.bias, model.conv1.4.running_mean, model.conv1.4.running_var, model.conv1.4.num_batches_tracked, model.layer1.0.conv1.weight, model.layer1.0.bn1.weight, model.layer1.0.bn1.bias, model.layer1.0.bn1.running_mean, model.layer1.0.bn1.running_var, model.layer1.0.bn1.num_batches_tracked, model.layer1.0.conv2.weight, model.layer1.0.bn2.weight, model.layer1.0.bn2.bias, model.layer1.0.bn2.running_mean, model.layer1.0.bn2.running_var, model.layer1.0.bn2.num_batches_tracked, model.layer1.1.conv1.weight, model.layer1.1.bn1.weight, model.layer1.1.bn1.bias, model.layer1.1.bn1.running_mean, model.layer1.1.bn1.running_var, model.layer1.1.bn1.num_batches_tracked, model.layer1.1.conv2.weight, model.layer1.1.bn2.weight, model.layer1.1.bn2.bias, model.layer1.1.bn2.running_mean, model.layer1.1.bn2.running_var, model.layer1.1.bn2.num_batches_tracked, model.layer2.0.conv1.weight, model.layer2.0.bn1.weight, model.layer2.0.bn1.bias, model.layer2.0.bn1.running_mean, model.layer2.0.bn1.running_var, model.layer2.0.bn1.num_batches_tracked, model.layer2.0.conv2.weight, model.layer2.0.bn2.weight, model.layer2.0.bn2.bias, model.layer2.0.bn2.running_mean, model.layer2.0.bn2.running_var, model.layer2.0.bn2.num_batches_tracked, model.layer2.0.downsample.0.weight, model.layer2.0.downsample.1.weight, model.layer2.0.downsample.1.bias, model.layer2.0.downsample.1.running_mean, model.layer2.0.downsample.1.running_var, model.layer2.0.downsample.1.num_batches_tracked, model.layer2.1.conv1.weight, model.layer2.1.bn1.weight, model.layer2.1.bn1.bias, model.layer2.1.bn1.running_mean, model.layer2.1.bn1.running_var, model.layer2.1.bn1.num_batches_tracked, model.layer2.1.conv2.weight, model.layer2.1.bn2.weight, model.layer2.1.bn2.bias, model.layer2.1.bn2.running_mean, model.layer2.1.bn2.running_var, model.layer2.1.bn2.num_batches_tracked, model.layer3.0.conv1.weight, model.layer3.0.bn1.weight, model.layer3.0.bn1.bias, model.layer3.0.bn1.running_mean, model.layer3.0.bn1.running_var, model.layer3.0.bn1.num_batches_tracked, model.layer3.0.conv2.weight, model.layer3.0.bn2.weight, model.layer3.0.bn2.bias, model.layer3.0.bn2.running_mean, model.layer3.0.bn2.running_var, model.layer3.0.bn2.num_batches_tracked, model.layer3.0.downsample.0.weight, model.layer3.0.downsample.1.weight, model.layer3.0.downsample.1.bias, model.layer3.0.downsample.1.running_mean, model.layer3.0.downsample.1.running_var, model.layer3.0.downsample.1.num_batches_tracked, model.layer3.1.conv1.weight, model.layer3.1.bn1.weight, model.layer3.1.bn1.bias, model.layer3.1.bn1.running_mean, model.layer3.1.bn1.running_var, model.layer3.1.bn1.num_batches_tracked, model.layer3.1.conv2.weight, model.layer3.1.bn2.weight, model.layer3.1.bn2.bias, model.layer3.1.bn2.running_mean, model.layer3.1.bn2.running_var, model.layer3.1.bn2.num_batches_tracked, model.layer4.0.conv1.weight, model.layer4.0.bn1.weight, model.layer4.0.bn1.bias, model.layer4.0.bn1.running_mean, model.layer4.0.bn1.running_var, model.layer4.0.bn1.num_batches_tracked, model.layer4.0.conv2.weight, model.layer4.0.bn2.weight, model.layer4.0.bn2.bias, model.layer4.0.bn2.running_mean, model.layer4.0.bn2.running_var, model.layer4.0.bn2.num_batches_tracked, model.layer4.0.downsample.0.weight, model.layer4.0.downsample.1.weight, model.layer4.0.downsample.1.bias, model.layer4.0.downsample.1.running_mean, model.layer4.0.downsample.1.running_var, model.layer4.0.downsample.1.num_batches_tracked, model.layer4.1.conv1.weight, model.layer4.1.bn1.weight, model.layer4.1.bn1.bias, model.layer4.1.bn1.running_mean, model.layer4.1.bn1.running_var, model.layer4.1.bn1.num_batches_tracked, model.layer4.1.conv2.weight, model.layer4.1.bn2.weight, model.layer4.1.bn2.bias, model.layer4.1.bn2.running_mean, model.layer4.1.bn2.running_var, model.layer4.1.bn2.num_batches_tracked, model.compression3.0.weight, model.compression3.1.weight, model.compression3.1.bias, model.compression3.1.running_mean, model.compression3.1.running_var, model.compression3.1.num_batches_tracked, model.compression4.0.weight, model.compression4.1.weight, model.compression4.1.bias, model.compression4.1.running_mean, model.compression4.1.running_var, model.compression4.1.num_batches_tracked, model.down3.0.weight, model.down3.1.weight, model.down3.1.bias, model.down3.1.running_mean, model.down3.1.running_var, model.down3.1.num_batches_tracked, model.down4.0.weight, model.down4.1.weight, model.down4.1.bias, model.down4.1.running_mean, model.down4.1.running_var, model.down4.1.num_batches_tracked, model.down4.3.weight, model.down4.4.weight, model.down4.4.bias, model.down4.4.running_mean, model.down4.4.running_var, model.down4.4.num_batches_tracked, model.layer3_.0.conv1.weight, model.layer3_.0.bn1.weight, model.layer3_.0.bn1.bias, model.layer3_.0.bn1.running_mean, model.layer3_.0.bn1.running_var, model.layer3_.0.bn1.num_batches_tracked, model.layer3_.0.conv2.weight, model.layer3_.0.bn2.weight, model.layer3_.0.bn2.bias, model.layer3_.0.bn2.running_mean, model.layer3_.0.bn2.running_var, model.layer3_.0.bn2.num_batches_tracked, model.layer3_.1.conv1.weight, model.layer3_.1.bn1.weight, model.layer3_.1.bn1.bias, model.layer3_.1.bn1.running_mean, model.layer3_.1.bn1.running_var, model.layer3_.1.bn1.num_batches_tracked, model.layer3_.1.conv2.weight, model.layer3_.1.bn2.weight, model.layer3_.1.bn2.bias, model.layer3_.1.bn2.running_mean, model.layer3_.1.bn2.running_var, model.layer3_.1.bn2.num_batches_tracked, model.layer4_.0.conv1.weight, model.layer4_.0.bn1.weight, model.layer4_.0.bn1.bias, model.layer4_.0.bn1.running_mean, model.layer4_.0.bn1.running_var, model.layer4_.0.bn1.num_batches_tracked, model.layer4_.0.conv2.weight, model.layer4_.0.bn2.weight, model.layer4_.0.bn2.bias, model.layer4_.0.bn2.running_mean, model.layer4_.0.bn2.running_var, model.layer4_.0.bn2.num_batches_tracked, model.layer4_.1.conv1.weight, model.layer4_.1.bn1.weight, model.layer4_.1.bn1.bias, model.layer4_.1.bn1.running_mean, model.layer4_.1.bn1.running_var, model.layer4_.1.bn1.num_batches_tracked, model.layer4_.1.conv2.weight, model.layer4_.1.bn2.weight, model.layer4_.1.bn2.bias, model.layer4_.1.bn2.running_mean, model.layer4_.1.bn2.running_var, model.layer4_.1.bn2.num_batches_tracked, model.layer5_.0.conv1.weight, model.layer5_.0.bn1.weight, model.layer5_.0.bn1.bias, model.layer5_.0.bn1.running_mean, model.layer5_.0.bn1.running_var, model.layer5_.0.bn1.num_batches_tracked, model.layer5_.0.conv2.weight, model.layer5_.0.bn2.weight, model.layer5_.0.bn2.bias, model.layer5_.0.bn2.running_mean, model.layer5_.0.bn2.running_var, model.layer5_.0.bn2.num_batches_tracked, model.layer5_.0.conv3.weight, model.layer5_.0.bn3.weight, model.layer5_.0.bn3.bias, model.layer5_.0.bn3.running_mean, model.layer5_.0.bn3.running_var, model.layer5_.0.bn3.num_batches_tracked, model.layer5_.0.downsample.0.weight, model.layer5_.0.downsample.1.weight, model.layer5_.0.downsample.1.bias, model.layer5_.0.downsample.1.running_mean, model.layer5_.0.downsample.1.running_var, model.layer5_.0.downsample.1.num_batches_tracked, model.layer5.0.conv1.weight, model.layer5.0.bn1.weight, model.layer5.0.bn1.bias, model.layer5.0.bn1.running_mean, model.layer5.0.bn1.running_var, model.layer5.0.bn1.num_batches_tracked, model.layer5.0.conv2.weight, model.layer5.0.bn2.weight, model.layer5.0.bn2.bias, model.layer5.0.bn2.running_mean, model.layer5.0.bn2.running_var, model.layer5.0.bn2.num_batches_tracked, model.layer5.0.conv3.weight, model.layer5.0.bn3.weight, model.layer5.0.bn3.bias, model.layer5.0.bn3.running_mean, model.layer5.0.bn3.running_var, model.layer5.0.bn3.num_batches_tracked, model.layer5.0.downsample.0.weight, model.layer5.0.downsample.1.weight, model.layer5.0.downsample.1.bias, model.layer5.0.downsample.1.running_mean, model.layer5.0.downsample.1.running_var, model.layer5.0.downsample.1.num_batches_tracked, model.spp.scale1.1.weight, model.spp.scale1.1.bias, model.spp.scale1.1.running_mean, model.spp.scale1.1.running_var, model.spp.scale1.1.num_batches_tracked, model.spp.scale1.3.weight, model.spp.scale2.1.weight, model.spp.scale2.1.bias, model.spp.scale2.1.running_mean, model.spp.scale2.1.running_var, model.spp.scale2.1.num_batches_tracked, model.spp.scale2.3.weight, model.spp.scale3.1.weight, model.spp.scale3.1.bias, model.spp.scale3.1.running_mean, model.spp.scale3.1.running_var, model.spp.scale3.1.num_batches_tracked, model.spp.scale3.3.weight, model.spp.scale4.1.weight, model.spp.scale4.1.bias, model.spp.scale4.1.running_mean, model.spp.scale4.1.running_var, model.spp.scale4.1.num_batches_tracked, model.spp.scale4.3.weight, model.spp.scale0.0.weight, model.spp.scale0.0.bias, model.spp.scale0.0.running_mean, model.spp.scale0.0.running_var, model.spp.scale0.0.num_batches_tracked, model.spp.scale0.2.weight, model.spp.process1.0.weight, model.spp.process1.0.bias, model.spp.process1.0.running_mean, model.spp.process1.0.running_var, model.spp.process1.0.num_batches_tracked, model.spp.process1.2.weight, model.spp.process2.0.weight, model.spp.process2.0.bias, model.spp.process2.0.running_mean, model.spp.process2.0.running_var, model.spp.process2.0.num_batches_tracked, model.spp.process2.2.weight, model.spp.process3.0.weight, model.spp.process3.0.bias, model.spp.process3.0.running_mean, model.spp.process3.0.running_var, model.spp.process3.0.num_batches_tracked, model.spp.process3.2.weight, model.spp.process4.0.weight, model.spp.process4.0.bias, model.spp.process4.0.running_mean, model.spp.process4.0.running_var, model.spp.process4.0.num_batches_tracked, model.spp.process4.2.weight, model.spp.compression.0.weight, model.spp.compression.0.bias, model.spp.compression.0.running_mean, model.spp.compression.0.running_var, model.spp.compression.0.num_batches_tracked, model.spp.compression.2.weight, model.spp.shortcut.0.weight, model.spp.shortcut.0.bias, model.spp.shortcut.0.running_mean, model.spp.shortcut.0.running_var, model.spp.shortcut.0.num_batches_tracked, model.spp.shortcut.2.weight, model.seghead_extra.bn1.weight, model.seghead_extra.bn1.bias, model.seghead_extra.bn1.running_mean, model.seghead_extra.bn1.running_var, model.seghead_extra.bn1.num_batches_tracked, model.seghead_extra.conv1.weight, model.seghead_extra.bn2.weight, model.seghead_extra.bn2.bias, model.seghead_extra.bn2.running_mean, model.seghead_extra.bn2.running_var, model.seghead_extra.bn2.num_batches_tracked, model.seghead_extra.conv2.weight, model.seghead_extra.conv2.bias, model.final_layer.bn1.weight, model.final_layer.bn1.bias, model.final_layer.bn1.running_mean, model.final_layer.bn1.running_var, model.final_layer.bn1.num_batches_tracked, model.final_layer.conv1.weight, model.final_layer.bn2.weight, model.final_layer.bn2.bias, model.final_layer.bn2.running_mean, model.final_layer.bn2.running_var, model.final_layer.bn2.num_batches_tracked, model.final_layer.conv2.weight, model.final_layer.conv2.bias, loss.criterion.weight

I have update the pretrained weight link, u can retry

Copy link
Collaborator

@xiexinch xiexinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @whu-pzhang,
Thanks for your contribution!
I think we might add some unit tests for the backbone and head.

Comment on lines 19 to 26
Args:
in_channels
channels:
ppm_channels
align_corners
norm_cfg
act_cfg
init_cfg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might complete the docstring.


@MODELS.register_module()
class DDRHead(BaseDecodeHead):
"""Decode head forDDRNet.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Decode head forDDRNet.
"""Decode head for DDRNet.

@xiexinch xiexinch changed the title Support DDRNet [Feature] Support DDRNet Apr 26, 2023
@xiexinch xiexinch merged commit 990063e into open-mmlab:dev-1.x Apr 27, 2023
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
Thanks for your contribution and we appreciate it a lot. The following
instructions would make your pull request more healthy and more easily
get feedback. If you do not understand some items, don't worry, just
make the pull request and seek help from maintainers.

## Motivation

Support DDRNet
Paper: [Deep Dual-resolution Networks for Real-time and Accurate
Semantic Segmentation of Road Scenes](https://arxiv.org/pdf/2101.06085)
official Code: https://github.com/ydhongHIT/DDRNet


There is already a PR
open-mmlab#1722 , but it has been
inactive for a long time.

## Current Result

### Cityscapes

#### inference with converted official weights

| Method | Backbone      | mIoU(official) | mIoU(converted weight) |
| ------ | ------------- | -------------- | ---------------------- |
| DDRNet | DDRNet23-slim | 77.8           | 77.84                  |
| DDRNet | DDRNet23 | 79.5 | 79.53 |

#### training with converted pretrained backbone

| Method | Backbone | Crop Size | Lr schd | Inf time(fps) | Device |
mIoU | mIoU(ms+flip) | config | download |
| ------ | ------------- | --------- | ------- | ------- | -------- |
----- | ------------- | ------------ | ------------ |
| DDRNet | DDRNet23-slim | 1024x1024 | 120000 | 85.85 | RTX 8000 | 77.85
| 79.80 |
[config](https://github.com/whu-pzhang/mmsegmentation/blob/ddrnet/configs/ddrnet/ddrnet_23-slim_in1k-pre_2xb6-120k_cityscapes-1024x1024.py)
| model \| log |
| DDRNet | DDRNet23 | 1024x1024 | 120000 | 33.41 | RTX 8000 | 79.53 |
80.98 |
[config](https://github.com/whu-pzhang/mmsegmentation/blob/ddrnet/configs/ddrnet/ddrnet_23_in1k-pre_2xb6-120k_cityscapes-1024x1024.py)
| model \| log |


The converted pretrained backbone weights download link:

1.
[ddrnet23s_in1k_mmseg.pth](https://drive.google.com/file/d/1Ni4F1PMGGjuld-1S9fzDTmneLfpMuPTG/view?usp=sharing)
2.
[ddrnet23_in1k_mmseg.pth](https://drive.google.com/file/d/11rsijC1xOWB6B0LgNQkAG-W6e1OdbCyJ/view?usp=sharing)

## To do

- [x] support inference with converted official weights
- [x] support training on cityscapes dataset

---------

Co-authored-by: xiexinch <xiexinch@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants