From 29cf572cccf0a2c8a70ea3294076bae2f09525c6 Mon Sep 17 00:00:00 2001 From: liyinshuo Date: Tue, 20 Jul 2021 08:27:28 +0800 Subject: [PATCH] Add checkpoints --- configs/restorers/liif/README.md | 19 +-- .../liif_edsr_norm_c64b16_g1_1000k_div2k.py | 48 +++--- ...if_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py | 156 ------------------ mmedit/models/restorers/liif.py | 2 +- 4 files changed, 34 insertions(+), 191 deletions(-) delete mode 100644 configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py diff --git a/configs/restorers/liif/README.md b/configs/restorers/liif/README.md index e983ba12ad..b613638ec7 100644 --- a/configs/restorers/liif/README.md +++ b/configs/restorers/liif/README.md @@ -21,20 +21,13 @@ | method | scale | Set5
PSNR / SSIM | Set14
PSNR / SSIM | DIV2K
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. diff --git a/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py b/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py index 860228b75f..8a3672be55 100644 --- a/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py +++ b/configs/restorers/liif/liif_edsr_norm_c64b16_g1_1000k_div2k.py @@ -5,29 +5,29 @@ 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' @@ -113,13 +113,18 @@ gt_folder='data/val_set5/Set5', pipeline=valid_pipeline, scale=scale_max), + # test=dict( + # type=test_dataset_type, + # lq_folder=f'data/val_set5/Set5_bicLRx{scale_max:d}', + # gt_folder='data/val_set5/Set5', + # pipeline=test_pipeline, + # scale=scale_max, + # filename_tmpl='{}'), test=dict( - type=test_dataset_type, - lq_folder=f'data/val_set5/Set5_bicLRx{scale_max:d}', + type=val_dataset_type, gt_folder='data/val_set5/Set5', - pipeline=test_pipeline, - scale=scale_max, - filename_tmpl='{}')) + pipeline=valid_pipeline, + scale=scale_max)) # optimizer optimizers = dict(type='Adam', lr=1.e-4) @@ -151,3 +156,4 @@ load_from = None resume_from = None workflow = [('train', 1)] +find_unused_parameters = True diff --git a/configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py b/configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py deleted file mode 100644 index ec441fc088..0000000000 --- a/configs/restorers/liif/liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k.py +++ /dev/null @@ -1,156 +0,0 @@ -exp_name = 'liif_edsr_norm_x2-4_c64b16_g1_1000k_div2k' -scale_min, scale_max = 1, 4 - -# model settings -model = dict( - type='LIIF', - generator=dict( - 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.), - 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 = 'SRFolderDataset' -train_pipeline = [ - dict( - type='LoadImageFromFile', - io_backend='disk', - key='gt', - flag='color', - channel_order='rgb'), - dict( - type='RandomDownSampling', - scale_min=scale_min, - scale_max=scale_max, - patch_size=48), - dict(type='RescaleToZeroOne', keys=['lq', 'gt']), - dict( - type='Flip', keys=['lq', 'gt'], flip_ratio=0.5, - direction='horizontal'), - dict(type='Flip', keys=['lq', 'gt'], flip_ratio=0.5, direction='vertical'), - dict(type='RandomTransposeHW', keys=['lq', 'gt'], transpose_ratio=0.5), - dict(type='ImageToTensor', keys=['lq', 'gt']), - dict(type='GenerateCoordinateAndCell', sample_quantity=2304), - dict( - type='Collect', - keys=['lq', 'gt', 'coord', 'cell'], - meta_keys=['gt_path']) -] -valid_pipeline = [ - dict( - type='LoadImageFromFile', - io_backend='disk', - key='gt', - flag='color', - channel_order='rgb'), - dict(type='RandomDownSampling', scale_min=scale_max, scale_max=scale_max), - dict(type='RescaleToZeroOne', keys=['lq', 'gt']), - dict(type='ImageToTensor', keys=['lq', 'gt']), - dict(type='GenerateCoordinateAndCell'), - dict( - type='Collect', - keys=['lq', 'gt', 'coord', 'cell'], - meta_keys=['gt_path']) -] -test_pipeline = [ - dict( - type='LoadImageFromFile', - io_backend='disk', - key='gt', - flag='color', - channel_order='rgb'), - dict( - type='LoadImageFromFile', - io_backend='disk', - key='lq', - flag='color', - channel_order='rgb'), - dict(type='RescaleToZeroOne', keys=['lq', 'gt']), - dict(type='ImageToTensor', keys=['lq', 'gt']), - dict(type='GenerateCoordinateAndCell', scale=scale_max), - dict( - type='Collect', - keys=['lq', 'gt', 'coord', 'cell'], - meta_keys=['gt_path']) -] - -data = dict( - workers_per_gpu=8, - train_dataloader=dict(samples_per_gpu=16, drop_last=True), - val_dataloader=dict(samples_per_gpu=1), - test_dataloader=dict(samples_per_gpu=1), - train=dict( - type='RepeatDataset', - times=20, - dataset=dict( - type=train_dataset_type, - gt_folder='data/DIV2K/DIV2K_train_HR', - pipeline=train_pipeline, - scale=scale_max)), - val=dict( - type=val_dataset_type, - gt_folder='data/val_set5/Set5', - pipeline=valid_pipeline, - scale=scale_max), - test=dict( - type=test_dataset_type, - lq_folder=f'data/val_set5/Set5_bicLRx{scale_max:d}', - gt_folder='data/val_set5/Set5', - pipeline=test_pipeline, - scale=scale_max, - filename_tmpl='{}')) - -# optimizer -optimizers = dict(type='Adam', lr=1.e-4) - -# learning policy -iter_per_epoch = 1000 -total_iters = 1000 * iter_per_epoch -lr_config = dict( - policy='Step', - by_epoch=False, - step=[200000, 400000, 600000, 800000], - gamma=0.5) - -checkpoint_config = dict( - interval=iter_per_epoch, save_optimizer=True, by_epoch=False) -evaluation = dict(interval=iter_per_epoch, save_image=True, gpu_collect=True) -log_config = dict( - interval=100, - hooks=[ - dict(type='TextLoggerHook', by_epoch=False), - dict(type='TensorboardLoggerHook') - ]) -visual_config = None - -# runtime settings -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = f'./work_dirs/{exp_name}' -load_from = None -resume_from = None -workflow = [('train', 1)] -find_unused_parameters = True diff --git a/mmedit/models/restorers/liif.py b/mmedit/models/restorers/liif.py index 1c4035988b..0ca88dd241 100644 --- a/mmedit/models/restorers/liif.py +++ b/mmedit/models/restorers/liif.py @@ -140,7 +140,7 @@ def forward_test(self, # generator with torch.no_grad(): - pred = self.generator(lq, coord, cell, test_mode=False) + pred = self.generator(lq, coord, cell, test_mode=True) self.gt_mean = self.gt_mean.to(pred) self.gt_std = self.gt_std.to(pred) pred = pred * self.gt_std + self.gt_mean