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

[Improve] Refactor liif for pytorch2onnx #425

Merged
merged 6 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions configs/restorers/liif/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@

| method | scale | Set5<br>PSNR / SSIM | Set14<br>PSNR / SSIM | DIV2K <br>PSNR / SSIM | Download |
| :--------------------------------------------------------------------------------------------------------------: | :---: | :-----------------: | :------------------: | :-------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| [liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k](/configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py) | x2 | 35.7148 / 0.9367 | 31.5936 / 0.8889 | 34.5896 / 0.9352 | [model](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210319-329ce255.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210319-329ce255.log.json) |
| △ | x3 | 32.3596 / 0.8914 | 28.4475 / 0.8040 | 30.9154 / 0.8720 | △ |
| △ | x4 | 30.2583 / 0.8513 | 26.7867 / 0.7377 | 29.0048 / 0.8183 | △ |
| [liif_edsr_norm_c64b16_g1_1000k_div2k](/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py) | x2 | 35.7120 / 0.9365 | 31.6106 / 0.8891 | 34.6401 / 0.9353 | [model](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210319-329ce255.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210319-329ce255.log.json) |
| △ | x3 | 32.3655 / 0.8913 | 28.4605 / 0.8039 | 30.9597 / 0.8711 | △ |
| △ | x4 | 30.2668 / 0.8511 | 26.8093 / 0.7377 | 29.0059 / 0.8183 | △ |
| △ | x6 | 27.0907 / 0.7775 | 24.7129 / 0.6438 | 26.7694 / 0.7422 | △ |
| △ | x12 | 22.9046 / 0.6255 | 21.5378 / 0.5088 | 23.7269 / 0.6373 | △ |
| △ | x18 | 20.8445 / 0.5390 | 20.0215 / 0.4521 | 22.1920 / 0.5947 | △ |
| △ | x24 | 19.7305 / 0.5033 | 19.0703 / 0.4218 | 21.2025 / 0.5714 | △ |
| △ | x30 | 18.6646 / 0.4818 | 18.0210 / 0.3905 | 20.5022 / 0.5568 | △ |
| [liif_edsr_norm_c64b16_g1_1000k_div2k](/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py) | x2 | 35.7131 / 0.9366 | 31.5579 / 0.8889 | 34.6647 / 0.9355 | [model](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210715-ab7ce3fc.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k_20210715-ab7ce3fc.log.json) |
| △ | x3 | 32.3805 / 0.8915 | 28.4605 / 0.8039 | 30.9808 / 0.8724 | △ |
| △ | x4 | 30.2748 / 0.8509 | 26.8415 / 0.7381 | 29.0245 / 0.8187 | △ |
| △ | x6 | 27.1187 / 0.7774 | 24.7461 / 0.6444 | 26.7770 / 0.7425 | △ |
| △ | x18 | 20.8516 / 0.5406 | 20.0096 / 0.4525 | 22.1987 / 0.5955 | △ |
| △ | x30 | 18.8467 / 0.5010 | 18.1321 / 0.3963 | 20.5050 / 0.5577 | △ |

Note:
* △ refers to ditto.
* The two configs only differs in _testing pipeline_. So they use the same checkpoint.
* Data is normalized according to [EDSR](/configs/restorers/edsr).
* Evaluated on RGB channels, `scale` pixels in each border are cropped before evaluation.
35 changes: 18 additions & 17 deletions configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
model = dict(
type='LIIF',
generator=dict(
type='EDSR',
in_channels=3,
out_channels=3,
mid_channels=64,
num_blocks=16),
imnet=dict(
type='MLPRefiner',
in_dim=64,
out_dim=3,
hidden_list=[256, 256, 256, 256]),
local_ensemble=True,
feat_unfold=True,
cell_decode=True,
type='LIIFEDSR',
encoder=dict(
type='EDSR',
in_channels=3,
out_channels=3,
mid_channels=64,
num_blocks=16),
imnet=dict(
type='MLPRefiner',
in_dim=64,
out_dim=3,
hidden_list=[256, 256, 256, 256]),
local_ensemble=True,
feat_unfold=True,
cell_decode=True,
eval_bsize=30000),
rgb_mean=(0.4488, 0.4371, 0.4040),
rgb_std=(1., 1., 1.),
eval_bsize=30000,
pixel_loss=dict(type='L1Loss', loss_weight=1.0, reduction='mean'))
# model training and testing settings
train_cfg = None
test_cfg = dict(metrics=['PSNR', 'SSIM'], crop_border=scale_max)

# dataset settings
scale_min, scale_max = 1, 4
# dataset settings
train_dataset_type = 'SRFolderGTDataset'
val_dataset_type = 'SRFolderGTDataset'
test_dataset_type = 'SRFolderGTDataset'
test_dataset_type = 'SRFolderDataset'
train_pipeline = [
dict(
type='LoadImageFromFile',
Expand Down Expand Up @@ -151,3 +151,4 @@
load_from = None
resume_from = None
workflow = [('train', 1)]
find_unused_parameters = True
153 changes: 0 additions & 153 deletions configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py

This file was deleted.

9 changes: 5 additions & 4 deletions mmedit/models/backbones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
ResNetEnc, ResShortcutDec, ResShortcutEnc,
SimpleEncoderDecoder)
from .generation_backbones import ResnetGenerator, UnetGenerator
from .sr_backbones import (EDSR, RDN, SRCNN, BasicVSRNet, DICNet, EDVRNet,
GLEANStyleGANv2, IconVSR, MSRResNet, RRDBNet,
TDANNet, TOFlow, TTSRNet)
from .sr_backbones import (EDSR, LIIFEDSR, RDN, SRCNN, BasicVSRNet, DICNet,
EDVRNet, GLEANStyleGANv2, IconVSR, MSRResNet,
RRDBNet, TDANNet, TOFlow, TTSRNet)

__all__ = [
'MSRResNet', 'VGG16', 'PlainDecoder', 'SimpleEncoderDecoder',
Expand All @@ -24,5 +24,6 @@
'DeepFillEncoderDecoder', 'EDVRNet', 'IndexedUpsample', 'IndexNetEncoder',
'IndexNetDecoder', 'TOFlow', 'ResGCAEncoder', 'ResGCADecoder', 'SRCNN',
'UnetGenerator', 'ResnetGenerator', 'FBAResnetDilated', 'FBADecoder',
'BasicVSRNet', 'IconVSR', 'TTSRNet', 'GLEANStyleGANv2', 'TDANNet'
'BasicVSRNet', 'IconVSR', 'TTSRNet', 'GLEANStyleGANv2', 'TDANNet',
'LIIFEDSR'
]
4 changes: 3 additions & 1 deletion mmedit/models/backbones/sr_backbones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .edvr_net import EDVRNet
from .glean_styleganv2 import GLEANStyleGANv2
from .iconvsr import IconVSR
from .liif_net import LIIFEDSR
from .rdn import RDN
from .rrdb_net import RRDBNet
from .sr_resnet import MSRResNet
Expand All @@ -14,5 +15,6 @@

__all__ = [
'MSRResNet', 'RRDBNet', 'EDSR', 'EDVRNet', 'TOFlow', 'SRCNN', 'DICNet',
'BasicVSRNet', 'IconVSR', 'RDN', 'TTSRNet', 'GLEANStyleGANv2', 'TDANNet'
'BasicVSRNet', 'IconVSR', 'RDN', 'TTSRNet', 'GLEANStyleGANv2', 'TDANNet',
'LIIFEDSR'
]
Loading