-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add GLEAN #296
Add GLEAN #296
Conversation
add GenerateFrameIndicesForRecurrent
… glean Conflicts: mmedit/models/backbones/__init__.py mmedit/models/backbones/sr_backbones/__init__.py
Codecov Report
@@ Coverage Diff @@
## master #296 +/- ##
==========================================
- Coverage 80.76% 80.28% -0.49%
==========================================
Files 171 177 +6
Lines 8526 9280 +754
Branches 1234 1352 +118
==========================================
+ Hits 6886 7450 +564
- Misses 1488 1641 +153
- Partials 152 189 +37
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
self.encoder = nn.ModuleList() | ||
self.encoder.append( | ||
nn.Sequential( | ||
RRDBFeatureExtractor(3, 64, num_blocks=23), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding mid_channels
(defaults 64) , in_channels
and out_channels
to the class (GLEANStyleGANv2) will be better.
nn.LeakyReLU(negative_slope=0.2, inplace=True), | ||
nn.Conv2d(64, 3, 3, 1, 1))) | ||
|
||
def forward(self, lr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Named LQ
in other models of MMEditing
|
||
|
||
@torch.no_grad() | ||
def get_mean_latent(generator, num_samples=4096, bs_per_repeat=1024): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nbei Could you help with that? I have copied the docstring of get_mean_latent
from mmgeneration, but there is no docstring for style_mixing
in mmgeneration.
with pytest.raises(AssertionError): # test with metric but gt is None | ||
with torch.no_grad(): | ||
data_batch.pop('gt') | ||
restorer(**data_batch, test_mode=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need unittests of the assertion errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model for GLEAN has only this assertion error. Do you mean the backbone? The unittests are in test_glean_net.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such as
mmedit/models/components/stylegan2/common.py#L16
mmedit/models/backbones/sr_backbones/glean_styleganv2.py#L271
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the unittests for glean_styleganv2.py
, it is in test_glean_net.py
. I will add unittests for common.py
.
Will add docstring for |
channels = self.generator.channels | ||
|
||
# encoder | ||
num_styles = int(math.log2(out_size)) * 2 - 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, we use np for math ops
math.log2 -> np.log2
Some notes:
And please rebase master. |
* clone from MMEditing * add GenerateFrameIndicesForRecurrent * add unit test * update format * add stylegan2 with pretrained models * add GLEAN architecture (WIP) * GLEAN architecture * Use build_component to build StyleGANv2 * add GenerateFrameIndicesForRecurrent * add stylegan2 with pretrained models * minor revision of architecture * Minor fix * Add MSELoss for perceptual loss * merge master * merge master * sort * Add GLEAN model * Add unittest * Remove pretrained in test * Replace by test_srgan for verification * Change disc to ModifiedVGG * Remove init_weights * Remove _load_pretrained_model * revert to test_srgan * Change Discriminator * Use original StyleGAN2 discriminator * Use GLEAN as generator * Change to GLEAN model * minor change * remove redundancy in test_glean.py * install * Add unittests * Revert to original StyleGAN2 discriminator * Change math.log2 to np.log2 Co-authored-by: Rui Xu <[email protected]>
This PR adds
GLEAN
for image super-resolution. It makes use ofStyleGANv2
borrowed from MMGeneration.Paper:
GLEAN: Generative Latent Bank for Large-Factor Image Super-Resolution