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 output dtype of RandomNoise #1585

Merged
merged 3 commits into from
Jan 18, 2023
Merged

[Fix] Fix output dtype of RandomNoise #1585

merged 3 commits into from
Jan 18, 2023

Conversation

dienachtderwelt
Copy link
Contributor

@dienachtderwelt dienachtderwelt commented Jan 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

_apply_poisson_noise() will change image dtype to np.float64. When other RandomNoise exists in degradations it can cause cv2.cvtColor(noise[..., [2, 1, 0]], cv2.COLOR_BGR2GRAY) to collapse.

Modification

  1. Cast dtype of np.random.poisson(noise * unique_val) to np.float32.
  2. Add corresponding unit tests.

Who can help? @ them here!

@liuwenran Thanks for invitation. Here comes my first tech PR 😃

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with some of those projects.
  • CLA has been signed and all committers have signed the CLA in this PR.

@Z-Fran Z-Fran self-requested a review January 9, 2023 07:30
@dienachtderwelt dienachtderwelt changed the title [Fix] Fix output dtype of RandomNoise [Feature] Add PairedRandomResize Jan 9, 2023
@dienachtderwelt
Copy link
Contributor Author

Sorry this branch is aimed to add new features to random_degradations. But used to fix a bug first. Really should do that in another branch LOL

@Z-Fran
Copy link
Collaborator

Z-Fran commented Jan 10, 2023

This bug you mentioned is exactly existing. Thanks for your contribution. Does PairedRandomResize be used in any model or some cases? @dienachtderwelt

@dienachtderwelt
Copy link
Contributor Author

Can refer to this paper in section 3.2 where it talks about resizing as part of the data synthesis pipeline: https://arxiv.org/pdf/2203.13278.pdf
In SR tasks it's natural to have gt and lq with different resolution. But if you want generate synthetic data for denoising models gt and lq have to match.
Hope this gives you a use case example. @Z-Fran

@Z-Fran
Copy link
Collaborator

Z-Fran commented Jan 10, 2023

So are you supporting SCUNet based on MMEditing? I think you can create a pull request to commit SCUNet with this PairedRandomResize pipeline together in another PR. And this PR only fixs the bug.

@dienachtderwelt
Copy link
Contributor Author

Actually I’m only using mmediting for training lol
Of course can make this branch only fix the bug @Z-Fran

@Z-Fran
Copy link
Collaborator

Z-Fran commented Jan 11, 2023

Merging PairedRandomResize in MMEditing when it's used in some models would be better. Now you can just fix this bug.

@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Base: 87.93% // Head: 87.93% // No change to project coverage 👍

Coverage data is based on head (5a236bd) compared to base (e18a11d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           dev-1.x    #1585   +/-   ##
========================================
  Coverage    87.93%   87.93%           
========================================
  Files          399      399           
  Lines        26059    26059           
  Branches      4051     4051           
========================================
  Hits         22914    22914           
  Misses        2240     2240           
  Partials       905      905           
Flag Coverage Δ
unittests 87.93% <100.00%> (ø)

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

Impacted Files Coverage Δ
mmedit/datasets/transforms/random_degradations.py 92.25% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@dienachtderwelt dienachtderwelt changed the title [Feature] Add PairedRandomResize [Fix] Fix output dtype of RandomNoise Jan 11, 2023
@dienachtderwelt
Copy link
Contributor Author

Sure. Branch rebased. @Z-Fran

@Z-Fran Z-Fran merged commit cce77da into open-mmlab:dev-1.x Jan 18, 2023
@Z-Fran Z-Fran mentioned this pull request Mar 2, 2023
7 tasks
@dienachtderwelt dienachtderwelt deleted the blake/feature-random-degradation branch March 31, 2023 07:13
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