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 BiSeNetV2 #804

Merged
merged 39 commits into from
Sep 26, 2021
Merged

Conversation

MengzhangLI
Copy link
Contributor

@MengzhangLI MengzhangLI commented Aug 20, 2021

Implementation of BiSeNet V2: Bilateral Network with Guided Aggregation for Real-time Semantic Segmentation.
Modified from the BiSeNetV2 PyTorch repository.

Done:

  • unittest
  • align inference metric (74.98)
  • align training metric (from about 73.0 to 74.0).
  • Totally using FCNHead than changing its middle channels.
  • align training metric (paper with OHEM is 73.36)
  • FP16 training results

Todo:

  • More datasets such as cocostuff
  • (STOPPED) Changing slightly (remove BN or ReLU in certain layers in BiSeNetV2 backbone) and test its performance.
  • (STOPPED) Try to use pretrained model from CoinCheung

Notice:
(1) This version of implementation is a little bit different from original version. Here is comparison.

@MengzhangLI
Copy link
Contributor Author

MengzhangLI commented Aug 20, 2021

The inference metric is correct of this version.

Just ignore FCNHead1 in this version PR please.

image

@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #804 (b2ee8df) into master (4e6f2eb) will increase coverage by 0.49%.
The diff coverage is 98.88%.

❗ Current head b2ee8df differs from pull request most recent head 9c227d7. Consider uploading reports for the commit 9c227d7 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #804      +/-   ##
==========================================
+ Coverage   89.05%   89.55%   +0.49%     
==========================================
  Files         111      113       +2     
  Lines        6051     6224     +173     
  Branches      969      989      +20     
==========================================
+ Hits         5389     5574     +185     
+ Misses        467      452      -15     
- Partials      195      198       +3     
Flag Coverage Δ
unittests 89.55% <98.88%> (+0.49%) ⬆️

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

Impacted Files Coverage Δ
mmseg/models/backbones/swin.py 87.41% <ø> (ø)
mmseg/datasets/coco_stuff.py 87.50% <87.50%> (ø)
mmseg/models/backbones/bisenetv2.py 99.28% <99.28%> (ø)
mmseg/core/seg/sampler/ohem_pixel_sampler.py 94.87% <100.00%> (+0.27%) ⬆️
mmseg/datasets/__init__.py 100.00% <100.00%> (ø)
mmseg/models/backbones/__init__.py 100.00% <100.00%> (ø)
mmseg/models/decode_heads/decode_head.py 92.22% <100.00%> (+0.86%) ⬆️
mmseg/models/decode_heads/point_head.py 96.55% <100.00%> (+0.02%) ⬆️
mmseg/models/losses/cross_entropy_loss.py 79.10% <100.00%> (+0.97%) ⬆️
mmseg/models/losses/dice_loss.py 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e6f2eb...9c227d7. Read the comment docs.

@MengzhangLI
Copy link
Contributor Author

I tried a lot Unittest commit, the reason why I always failed is test Process completed with exit code 137., which means the CPU memory is limited. The solution is making input smaller: from [4, 3, 1024, 2048] to [2, 3, 512, 1024].

@Junjun2016
Copy link
Collaborator

I tried a lot Unittest commit, the reason why I always failed is test Process completed with exit code 137., which means the CPU memory is limited. The solution is making input smaller: from [4, 3, 1024, 2048] to [2, 3, 512, 1024].

The input can be smaller for unittests.

@MengzhangLI
Copy link
Contributor Author

The training metric is here:

image

Note: It is not stable when training from scratch.

Here is its training log:
20210821_060603.log

@MengzhangLI MengzhangLI added the WIP Work in process label Aug 26, 2021
@MengzhangLI
Copy link
Contributor Author

MengzhangLI commented Aug 30, 2021

First time code refactoring done. Here is inference result whose model is above:

python tools/test.py ./configs/bisenet/bisenet_4x4_1024x1024_160k_cityscapes.py ./checkpoints/exp3_fcn/latest_full.pth --eval mIoU

image

@MengzhangLI
Copy link
Contributor Author

The training metric is here:

image

Note: It is not stable when training from scratch.

Here is its training log:
20210821_060603.log

Just check this log, the cross entropy loss of auxiliary heads all use_sigmoid=True

截屏2021-08-31 上午3 21 26

Copy link
Collaborator

@Junjun2016 Junjun2016 left a comment

Choose a reason for hiding this comment

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

Please refine docstring.

mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
mmseg/models/backbones/bisenet.py Outdated Show resolved Hide resolved
@Junjun2016
Copy link
Collaborator

The training metric is here:
image
Note: It is not stable when training from scratch.
Here is its training log:
20210821_060603.log

Just check this log, the cross entropy loss of auxiliary heads all use_sigmoid=True

截屏2021-08-31 上午3 21 26

Which repository or paper did you refer to?

@Junjun2016 Junjun2016 changed the title [Feature] add BiSeNetV2 [Feature] Support BiSeNetV2 Aug 30, 2021
@MengzhangLI
Copy link
Contributor Author

The training metric is here:
image
Note: It is not stable when training from scratch.
Here is its training log:
20210821_060603.log

Just check this log, the cross entropy loss of auxiliary heads all use_sigmoid=True
截屏2021-08-31 上午3 21 26

Which repository or paper did you refer to?

None of them. I did not care too much about loss in auxiliary head.

Actually paper did not say too much about loss and other repository did not adopt use_sigmoid=True.

Copy link
Collaborator

@xvjiarui xvjiarui left a comment

Choose a reason for hiding this comment

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

LGTM except one comment

Copy link
Collaborator

@Junjun2016 Junjun2016 left a comment

Choose a reason for hiding this comment

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

Please resolve some comments.

@MengzhangLI MengzhangLI removed the WIP Work in process label Sep 26, 2021
@Junjun2016 Junjun2016 merged commit 4003b8f into open-mmlab:master Sep 26, 2021
@MengzhangLI MengzhangLI deleted the BiSeNetV2 branch February 1, 2022 03:15
bowenroom pushed a commit to bowenroom/mmsegmentation that referenced this pull request Feb 25, 2022
* BiSeNetV2 first commit

* BiSeNetV2 unittest

* remove pytest

* add pytest module

* fix ConvModule input name

* fix pytest error

* fix unittest

* refactor

* BiSeNetV2 Refactory

* fix docstrings and add some small changes

* use_sigmoid=False

* fix potential bugs about upsampling

* Use ConvModule instead

* Use ConvModule instead

* fix typos

* fix typos

* fix typos

* discard nn.conv2d

* discard nn.conv2d

* discard nn.conv2d

* delete **kwargs

* uploading markdown and model

* final commit

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* BiSeNetV2 adding Unittest for its modules

* Fix README conflict

* Fix unittest problem

* Fix unittest problem

* BiSeNetV2

* Fixing fps

* Fixing typpos

* bisenetv2
aravind-h-v pushed a commit to aravind-h-v/mmsegmentation that referenced this pull request Mar 27, 2023
wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
* add chinese tutorial for new_module.

* change some words.
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.

4 participants