Skip to content

Commit

Permalink
[CodeCamp #83] Support Restormer model (#1503)
Browse files Browse the repository at this point in the history
* Merge branch 'cndocs' of https://github.com/AlexZou14/mmediting into cndocs

* Add Restormer

* Add einops

* Create test_restormer_net.py

* Refactor deraining config

* Update restormer_net.py

* Refactor config

* Update restormer_official_rain13k.py

* Update deraining_test_config.py

* Fix Restormer Readme

* Fix runtime.txt

* refactor configs

* rename deblurring config

* rename deblurring config

* Fix config and Fix docstring

* Update runtime.txt

* fix typo

* remove edit_dual_data_preprocessor

* Fix test_restormer_net.py typo

* Add denoising_real and fix config typo

* Fix Some typo

* Fix Typo

* fix configs

* fix dpdd dataset

* fix readme

* Fix Readme

* Fix README_zh-CN

* Fix Typo

* support dual deblur and fix pad

* fix ut

* update metrics

* Fix test_dual_restormer

* fix ut

* fix typo

Co-authored-by: Z-Fran <1396925302@qq.com>
Co-authored-by: Z-Fran <49083766+Z-Fran@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 21, 2022
1 parent 61ca30e commit b13cd06
Show file tree
Hide file tree
Showing 27 changed files with 2,497 additions and 1 deletion.
98 changes: 98 additions & 0 deletions configs/_base_/datasets/deblurring-defocus_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
test_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='imgL',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='imgR',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(type='PackEditInputs')
]

dpdd_data_root = 'data/DPDD'

dpdd_indoor_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='DPDD-Indoor', task_name='deblurring'),
data_root=dpdd_data_root,
data_prefix=dict(
img='inputC', imgL='inputL', imgR='inputR', gt='target'),
ann_file='indoor_labels.txt',
pipeline=test_pipeline))
dpdd_indoor_evaluator = [
dict(type='MAE', prefix='DPDD-Indoor'),
dict(type='PSNR', prefix='DPDD-Indoor'),
dict(type='SSIM', prefix='DPDD-Indoor'),
]

dpdd_outdoor_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='DPDD-Outdoor', task_name='deblurring'),
data_root=dpdd_data_root,
data_prefix=dict(
img='inputC', imgL='inputL', imgR='inputR', gt='target'),
ann_file='outdoor_labels.txt',
pipeline=test_pipeline))
dpdd_outdoor_evaluator = [
dict(type='MAE', prefix='DPDD-Outdoor'),
dict(type='PSNR', prefix='DPDD-Outdoor'),
dict(type='SSIM', prefix='DPDD-Outdoor'),
]

dpdd_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='DPDD-Combined', task_name='deblurring'),
data_root=dpdd_data_root,
data_prefix=dict(
img='inputC', imgL='inputL', imgR='inputR', gt='target'),
pipeline=test_pipeline))
dpdd_evaluator = [
dict(type='MAE', prefix='DPDD-Combined'),
dict(type='PSNR', prefix='DPDD-Combined'),
dict(type='SSIM', prefix='DPDD-Combined'),
]

# test config
test_cfg = dict(type='MultiTestLoop')
test_dataloader = [
dpdd_indoor_dataloader,
dpdd_outdoor_dataloader,
dpdd_dataloader,
]
test_evaluator = [
dpdd_indoor_evaluator,
dpdd_outdoor_evaluator,
dpdd_evaluator,
]
98 changes: 98 additions & 0 deletions configs/_base_/datasets/deblurring-motion_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
test_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(type='PackEditInputs')
]

gopro_data_root = 'data/GoPro'
gopro_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='GoPro', task_name='deblurring'),
data_root=gopro_data_root,
data_prefix=dict(img='input', gt='target'),
pipeline=test_pipeline))
gopro_evaluator = [
dict(type='PSNR', prefix='GoPro'),
dict(type='SSIM', prefix='GoPro'),
]

hide_data_root = 'data/HIDE'
hide_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='HIDE', task_name='deblurring'),
data_root=hide_data_root,
data_prefix=dict(img='input', gt='target'),
pipeline=test_pipeline))
hide_evaluator = [
dict(type='PSNR', prefix='HIDE'),
dict(type='SSIM', prefix='HIDE'),
]

realblurj_data_root = 'data/RealBlur_J'
realblurj_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='RealBlur_J', task_name='deblurring'),
data_root=realblurj_data_root,
data_prefix=dict(img='input', gt='target'),
pipeline=test_pipeline))
realblurj_evaluator = [
dict(type='PSNR', convert_to='Y', prefix='RealBlurJ'),
dict(type='SSIM', convert_to='Y', prefix='RealBlurJ'),
]

realblurr_data_root = 'data/RealBlur_R'
realblurr_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='RealBlur_R', task_name='deblurring'),
data_root=realblurr_data_root,
data_prefix=dict(img='input', gt='target'),
pipeline=test_pipeline))
realblurr_evaluator = [
dict(type='PSNR', convert_to='Y', prefix='RealBlurR'),
dict(type='SSIM', convert_to='Y', prefix='RealBlurR'),
]

# test config
test_cfg = dict(type='MultiTestLoop')
test_dataloader = [
gopro_dataloader,
hide_dataloader,
realblurj_dataloader,
realblurr_dataloader,
]
test_evaluator = [
gopro_evaluator,
hide_evaluator,
realblurj_evaluator,
realblurr_evaluator,
]
104 changes: 104 additions & 0 deletions configs/_base_/datasets/denoising-gaussian_color_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
sigma = 15
test_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb',
imdecode_backend='cv2'),
dict(
type='RandomNoise',
params=dict(
noise_type=['gaussian'],
noise_prob=[1],
gaussian_sigma=[sigma * 255, sigma * 255],
gaussian_gray_noise_prob=0),
keys=['img']),
dict(type='PackEditInputs')
]

data_root = 'data/denoising_gaussian_test'
cbsd68_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='CBSD68', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='CBSD68', gt='CBSD68'),
pipeline=test_pipeline))
cbsd68_evaluator = [
dict(type='PSNR', prefix='CBSD68'),
dict(type='SSIM', prefix='CBSD68'),
]

kodak24_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='Kodak24', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='Kodak24', gt='Kodak24'),
pipeline=test_pipeline))
kodak24_evaluator = [
dict(type='PSNR', prefix='Kodak24'),
dict(type='SSIM', prefix='Kodak24'),
]

mcmaster_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='McMaster', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='McMaster', gt='McMaster'),
pipeline=test_pipeline))
mcmaster_evaluator = [
dict(type='PSNR', prefix='McMaster'),
dict(type='SSIM', prefix='McMaster'),
]

urban100_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='Urban100', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='Urban100', gt='Urban100'),
pipeline=test_pipeline))
urban100_evaluator = [
dict(type='PSNR', prefix='Urban100'),
dict(type='SSIM', prefix='Urban100'),
]

# test config
test_cfg = dict(type='MultiTestLoop')
test_dataloader = [
cbsd68_dataloader,
kodak24_dataloader,
mcmaster_dataloader,
urban100_dataloader,
]
test_evaluator = [
cbsd68_evaluator,
kodak24_evaluator,
mcmaster_evaluator,
urban100_evaluator,
]
88 changes: 88 additions & 0 deletions configs/_base_/datasets/denoising-gaussian_gray_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
sigma = 15
test_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb',
to_y_channel=True,
imdecode_backend='cv2'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb',
to_y_channel=True,
imdecode_backend='cv2'),
dict(
type='RandomNoise',
params=dict(
noise_type=['gaussian'],
noise_prob=[1],
gaussian_sigma=[sigma * 255, sigma * 255],
gaussian_gray_noise_prob=1),
keys=['img']),
dict(type='PackEditInputs')
]

data_root = 'data/denoising_gaussian_test'
set12_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='Set12', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='Set12', gt='Set12'),
pipeline=test_pipeline))
set12_evaluator = [
dict(type='PSNR', prefix='Set12'),
dict(type='SSIM', prefix='Set12'),
]

bsd68_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='BSD68', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='BSD68', gt='BSD68'),
pipeline=test_pipeline))
bsd68_evaluator = [
dict(type='PSNR', prefix='BSD68'),
dict(type='SSIM', prefix='BSD68'),
]

urban100_dataloader = dict(
num_workers=4,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicImageDataset',
metainfo=dict(dataset_type='Urban100', task_name='denoising'),
data_root=data_root,
data_prefix=dict(img='Urban100', gt='Urban100'),
pipeline=test_pipeline))
urban100_evaluator = [
dict(type='PSNR', prefix='Urban100'),
dict(type='SSIM', prefix='Urban100'),
]

# test config
test_cfg = dict(type='MultiTestLoop')
test_dataloader = [
set12_dataloader,
bsd68_dataloader,
urban100_dataloader,
]
test_evaluator = [
set12_evaluator,
bsd68_evaluator,
urban100_evaluator,
]
Loading

0 comments on commit b13cd06

Please # to comment.