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

[Enhance] Support reading class_weight from file in loss functions to help MMDet3D #513

Merged
merged 4 commits into from
Apr 29, 2021
Merged

[Enhance] Support reading class_weight from file in loss functions to help MMDet3D #513

merged 4 commits into from
Apr 29, 2021

Conversation

Wuziyi616
Copy link
Contributor

Hi, I am Ziyi, a developer from MMDet3D. Currently we are implementing 3D segmentation models, which require using loss functions from MMSeg (e.g. CrossEntropy). It's very common to use class_weight in 3D Seg, and in some scenarios we need to load class_weight from files. So I modify the code and support this feature. Hope you can approve it. Thanks.

@Wuziyi616 Wuziyi616 changed the title [Enhance] Support reading class_weight from file in loss functions [Enhance] Support reading class_weight from file in loss functions to help MMDet3D Apr 25, 2021
@codecov
Copy link

codecov bot commented Apr 25, 2021

Codecov Report

Merging #513 (23a713f) into master (98ef5ac) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
+ Coverage   86.56%   86.58%   +0.02%     
==========================================
  Files          99       99              
  Lines        5164     5172       +8     
  Branches      836      838       +2     
==========================================
+ Hits         4470     4478       +8     
  Misses        535      535              
  Partials      159      159              
Flag Coverage Δ
unittests 86.58% <100.00%> (+0.02%) ⬆️

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 78.12% <100.00%> (ø)
mmseg/models/losses/dice_loss.py 100.00% <100.00%> (ø)
mmseg/models/losses/lovasz_loss.py 89.09% <100.00%> (ø)
mmseg/models/losses/utils.py 81.57% <100.00%> (+4.91%) ⬆️

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 98ef5ac...23a713f. Read the comment docs.

@Wuziyi616 Wuziyi616 requested a review from xvjiarui April 26, 2021 07:59
@Wuziyi616
Copy link
Contributor Author

This PR is ready for review @xvjiarui. Thanks!

@Wuziyi616 Wuziyi616 closed this Apr 27, 2021
@Wuziyi616 Wuziyi616 reopened this Apr 27, 2021
@xvjiarui xvjiarui merged commit cef8a4f into open-mmlab:master Apr 29, 2021
@Wuziyi616 Wuziyi616 deleted the class_weight_file branch April 29, 2021 08:12
bowenroom pushed a commit to bowenroom/mmsegmentation that referenced this pull request Feb 25, 2022
… help MMDet3D (open-mmlab#513)

* support reading class_weight from file in loss function

* add unit test of loss with class_weight from file

* minor fix

* move get_class_weight to utils
aravind-h-v pushed a commit to aravind-h-v/mmsegmentation that referenced this pull request Mar 27, 2023
* Add `init_weights` method to `FlaxMixin`

* Rn `random_state` -> `shape_state`

* `PRNGKey(0)` for `jax.eval_shape`

* No allow mismatched sizes

* Update src/diffusers/modeling_flax_utils.py

Co-authored-by: Suraj Patil <surajp815@gmail.com>

* Update src/diffusers/modeling_flax_utils.py

Co-authored-by: Suraj Patil <surajp815@gmail.com>

* docstring diffusers

Co-authored-by: Suraj Patil <surajp815@gmail.com>
aravind-h-v pushed a commit to aravind-h-v/mmsegmentation that referenced this pull request Mar 27, 2023
* First UNet Flax modeling blocks.

Mimic the structure of the PyTorch files.
The model classes themselves need work, depending on what we do about
configuration and initialization.

* Remove FlaxUNet2DConfig class.

* ignore_for_config non-config args.

* Implement `FlaxModelMixin`

* Use new mixins for Flax UNet.

For some reason the configuration is not correctly applied; the
signature of the `__init__` method does not contain all the parameters
by the time it's inspected in `extract_init_dict`.

* Import `FlaxUNet2DConditionModel` if flax is available.

* Rm unused method `framework`

* Update src/diffusers/modeling_flax_utils.py

Co-authored-by: Suraj Patil <surajp815@gmail.com>

* Indicate types in flax.struct.dataclass as pointed out by @mishig25

Co-authored-by: Mishig Davaadorj <mishig.davaadorj@coloradocollege.edu>

* Fix typo in transformer block.

* make style

* some more changes

* make style

* Add comment

* Update src/diffusers/modeling_flax_utils.py

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>

* Rm unneeded comment

* Update docstrings

* correct ignore kwargs

* make style

* Update docstring examples

* Make style

* Style: remove empty line.

* Apply style (after upgrading black from pinned version)

* Remove some commented code and unused imports.

* Add init_weights (not yet in use until open-mmlab#513).

* Trickle down deterministic to blocks.

* Rename q, k, v according to the latest PyTorch version.

Note that weights were exported with the old names, so we need to be
careful.

* Flax UNet docstrings, default props as in PyTorch.

* Fix minor typos in PyTorch docstrings.

* Use FlaxUNet2DConditionOutput as output from UNet.

* make style

Co-authored-by: Mishig Davaadorj <dmishig@gmail.com>
Co-authored-by: Mishig Davaadorj <mishig.davaadorj@coloradocollege.edu>
Co-authored-by: Suraj Patil <surajp815@gmail.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
sibozhang pushed a commit to sibozhang/mmsegmentation that referenced this pull request Mar 22, 2024
* resolve comments

* update changelog

* update changelog

* add master

* fix changelog

* remove FAQ
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.

2 participants