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

[Fix] Fix the bug in binary_cross_entropy #1527

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

Dawn-bin
Copy link
Contributor

Motivation

Fix the bug in binary_cross_entropy
' label.max() <= 1' should mask out ignore_index, since the ignore_index often set as 255.
Related Issuse #1525

Modification

Add a mask.

if pred.size(1) == 1:
        # For binary class segmentation, the shape of pred is
        # [N, 1, H, W] and that of label is [N, H, W].
        assert label[label != ignore_index].max() <= 1, \
            'For pred with shape [N, 1, H, W], its label must have at ' \
            'most 2 classes'
        pred = pred.squeeze()

 Fix the bug in binary_cross_entropy
'label.max() <= 1' should mask out ignore_index, since the ignore_index often set as 255.
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #1527 (d9497c8) into master (44b9c6f) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1527   +/-   ##
=======================================
  Coverage   90.40%   90.40%           
=======================================
  Files         141      141           
  Lines        8443     8443           
  Branches     1423     1423           
=======================================
  Hits         7633     7633           
  Misses        572      572           
  Partials      238      238           
Flag Coverage Δ
unittests 90.40% <100.00%> (ø)

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

Impacted Files Coverage Δ
mmseg/models/losses/cross_entropy_loss.py 86.90% <100.00%> (ø)

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 44b9c6f...d9497c8. Read the comment docs.

Dawn-bin and others added 2 commits April 29, 2022 10:12
As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.
@Junjun2016
Copy link
Collaborator

LGTM, but the CI failed.

@MeowZheng
Copy link
Collaborator

LGTM, but the CI failed.

I have fix ci in #1532

@MeowZheng MeowZheng merged commit 061b5b4 into open-mmlab:master Apr 29, 2022
ZhimingNJ pushed a commit to AetrexTechnology/mmsegmentation that referenced this pull request Jun 29, 2022
* [Fix] Fix the bug in binary_cross_entropy

 Fix the bug in binary_cross_entropy
'label.max() <= 1' should mask out ignore_index, since the ignore_index often set as 255.

* [Fix] Fix the bug in binary_cross_entropy, add comments

As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>

* [Fix] Fix the bug in binary_cross_entropy

As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
Co-authored-by: MeowZheng <meowzheng@outlook.com>
aravind-h-v pushed a commit to aravind-h-v/mmsegmentation that referenced this pull request Mar 27, 2023
@jason102811
Copy link

dawn-bin,您好!您在MMSeg项目中给我们提的PR非常重要,感谢您付出私人时间帮助改进开源项目,相信很多开发者会从你的PR中受益。
我们非常期待与您继续合作,OpenMMLab专门成立了贡献者组织MMSIG,为贡献者们提供开源证书、荣誉体系和专享好礼,可通过添加微信:openmmlabwx 联系我们(请备注mmsig+GitHub id),由衷希望您能加入!
Dear dawn-bin,
First of all, we want to express our gratitude for your significant PR in the MMSeg project. Your contribution is highly appreciated, and we are grateful for your efforts in helping improve this open-source project during your personal time. We believe that many developers will benefit from your PR.
We are looking forward to continuing our collaboration with you. OpenMMLab has established a special contributors' organization called MMSIG, which provides contributors with open-source certificates, a recognition system, and exclusive rewards. You can contact us by adding our WeChat(if you have WeChat): openmmlabwx, or join in our discord: https://discord.gg/qH9fysxPDW. We sincerely hope you will join us!
Best regards @Dawn-bin

wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
…1527)

* refactor init_model and unit test

* add topdown inference and minor modification to data pipelines

* add topdown image demo

* change bbox format from xywh to xyxy

* resolve comments
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.

6 participants