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 random degradations during training #504

Merged
merged 10 commits into from
Sep 15, 2021

Conversation

ckkelvinchan
Copy link
Member

Motivation

Recent works on face restoration or real-world super-resolution rely heavily on applying random degradations during training.

Modification

This PR adds support to generate random degradations in the data processing pipeline. It currently supports

  1. Random resize
  2. Gaussian blur
  3. Sinc filter
  4. Gaussian noise
  5. Poisson noise
  6. JPEG compression
  7. Random shuffling of degradations

This is a generic class. Supporting other degradations can be done by adding corresponding operations in this class.

@ckkelvinchan ckkelvinchan added the status/WIP work in progress normally label Aug 26, 2021
@codecov
Copy link

codecov bot commented Aug 26, 2021

Codecov Report

Merging #504 (8246d99) into master (84d2eeb) will increase coverage by 0.13%.
The diff coverage is 84.29%.

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

@@            Coverage Diff             @@
##           master     #504      +/-   ##
==========================================
+ Coverage   80.41%   80.54%   +0.13%     
==========================================
  Files         191      193       +2     
  Lines       10378    10759     +381     
  Branches     1553     1631      +78     
==========================================
+ Hits         8345     8666     +321     
- Misses       1796     1835      +39     
- Partials      237      258      +21     
Flag Coverage Δ
unittests 80.54% <84.29%> (+0.13%) ⬆️

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

Impacted Files Coverage Δ
mmedit/datasets/pipelines/augmentation.py 91.22% <27.77%> (-5.76%) ⬇️
mmedit/datasets/pipelines/blur_kernels.py 84.55% <84.55%> (ø)
mmedit/datasets/pipelines/random_degradations.py 93.75% <93.75%> (ø)
mmedit/datasets/pipelines/__init__.py 100.00% <100.00%> (ø)
...ls/components/stylegan2/generator_discriminator.py 84.93% <0.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 84d2eeb...c68f54c. Read the comment docs.

@innerlee
Copy link
Contributor

innerlee commented Sep 2, 2021

A general note: for augmentations, please add the added/modified keys in docstring.

self.keys = keys
self.params = params

def _apply_gaussian_noise(self, input_):
Copy link
Contributor

Choose a reason for hiding this comment

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

How about input_ -> input?

@ckkelvinchan ckkelvinchan removed the status/WIP work in progress normally label Sep 10, 2021
@ckkelvinchan ckkelvinchan changed the title [Feature] AddRandomDegradations [Feature] Support random degradations during training Sep 15, 2021
@innerlee innerlee merged commit b2eae47 into open-mmlab:master Sep 15, 2021
Yshuo-Li pushed a commit to Yshuo-Li/mmediting that referenced this pull request Jul 15, 2022
* AddRandomDegradations

* Add blur_kernels.py

* Refactor random degradations

* Minor fix and add unittest

* update, pull from master

* Update

* Add license

* minor fix
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