Skip to content

Commit 5856835

Browse files
committed
first initial
0 parents  commit 5856835

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2202
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Towards Efficient and Scale-Robust Ultra-High-Definition Image Demoireing
2+
3+
**Towards Efficient and Scale-Robust Ultra-High-Definition Image Demoireing** (ECCV 2022)
4+
Xin Yu, Peng Dai, Wenbo Li, Lan Ma, Jiajun Shen, Jia Li, [Xiaojuan Qi](https://scholar.google.com/citations?user=bGn0uacAAAAJ&hl=en).
5+
<br>[Paper(Coming soon)](---), [Project_page](https://xinyu-andy.github.io/uhdm-page/), [Dataset](https://drive.google.com/drive/folders/1DyA84UqM7zf3CeoEBNmTi_dJ649x2e7e?usp=sharing)
6+
7+
![Example 1](./figures/result.png)
8+
9+
## Introduction
10+
When photographing the contents displayed on the digital screen, an inevitable frequency aliasing between the camera’s
11+
color filter array (CFA) and the screen’s LCD subpixel widely exists. The captured images are thus mixed with colorful
12+
stripes, named moire patterns, which severely degrade images’ perceptual qualities. Although a plethora of dedicated
13+
demoire methods have been proposed in the research community recently, yet is still far from achieving promising results
14+
in the real-world scenes. The key limitation of these methods is that they all only conduct research on low-resolution or
15+
synthetic images. However, with the rapid development of mobile devices, modern widely-used mobile phones typically allow
16+
users to capture 4K resolution (i.e.,ultra-high-definition) images, and thus the effectiveness of these methods on this
17+
practical scenes is not promised. In this work, we explore moire pattern removal for ultra-high-definition images.
18+
First, we propose the first ultra-high-definition demoireing dataset (UHDM), which contains 5,000 real-world 4K
19+
resolution image pair, and conduct a benchmark study on the current state of the art. Then, we analyze limitations
20+
of the state of the art and summarize the key issue of them, i.e., not scale-robust. To address their deficiencies,
21+
we deliver a plug-and-play semantic-aligned scale-aware module which helps us to build a frustratingly simple baseline
22+
model for tackling 4K moire images. Our framework is easy to implement and fast for inference, achieving state-of-the-art
23+
results on four demoireing datasets while being much more lightweight.
24+
We hope our investigation could inspire more future research in this more practical setting in image demoireing.
25+
![Example 1](./figures/cost.png)
26+
27+
## Environments
28+
29+
First you have to make sure that you have installed all dependencies. To do so, you can create an anaconda environment called `esdnet` using
30+
31+
```
32+
conda env create -f environment.yaml
33+
conda activate esdnet
34+
```
35+
36+
Our implementation has been tested on one NVIDIA 3090 GPU with cuda 11.2.
37+
38+
## Dataset
39+
![Example 1](./figures/dataset.png)
40+
We provide the 4K dataset UHDM for you to evaluate a pretrained model or train a new model.
41+
To this end, you can download them [here](https://drive.google.com/drive/folders/1DyA84UqM7zf3CeoEBNmTi_dJ649x2e7e?usp=sharing),
42+
or you can simply run the following command for automatic data downloading:
43+
```
44+
bash scripts/download_data.sh
45+
```
46+
Then the dataset will be available in the folder `uhdm_data/`.
47+
48+
## Train
49+
To train a model from scratch, simply run:
50+
51+
```
52+
python train.py --config CONFIG.yaml
53+
```
54+
where you replace `CONFIG.yaml` with the name of the configuration file you want to use.
55+
We have included configuration files for each dataset under the folder `config/`.
56+
57+
For example, if you want to train our lightweight model ESDNet on UHDM dataset, run:
58+
```
59+
python train.py --config ./config/uhdm_config.yaml
60+
```
61+
62+
63+
## Test
64+
To test a model, you can also simply run:
65+
66+
```
67+
python test.py --config CONFIG.yaml
68+
```
69+
70+
where you need to specify the value of `TEST_EPOCH` in the `CONFIG.yaml` to evaluate a model trained after specific epochs,
71+
or you can also specify the value of `LOAD_PATH` to directly load a pre-trained checkpoint.
72+
73+
We provide pre-trained models [here](https://drive.google.com/drive/folders/12buOOBKDBdQ65gM8U1rRNpSHppQ_u9Lr?usp=sharing).
74+
To download the checkpoints, you can also simply run:
75+
76+
```
77+
bash scripts/download_model.sh
78+
```
79+
80+
Then the checkpoints will be included in the folder `pretrain_model/`.
81+
82+
83+
## Contact
84+
If you have any questions, you can email me ([email protected]).
85+
86+
739 Bytes
Binary file not shown.

config/aim_config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/aim'
6+
EXP_NAME: 'exp_light'
7+
8+
DATA:
9+
DATA_TYPE: AIM # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 1 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
CROP_SIZE: 512 # Set the crop size if LOADER==crop
24+
RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 200 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 300 # The total training epochs
40+
T_0: 50 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle
44+

config/aim_large_config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/aim'
6+
EXP_NAME: 'exp_large'
7+
8+
DATA:
9+
DATA_TYPE: AIM # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 2 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
CROP_SIZE: 512 # Set the crop size if LOADER==crop
24+
RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 200 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 300 # The total training epochs
40+
T_0: 50 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle

config/config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import argparse
2+
import yaml
3+
import os
4+
5+
def get_parser():
6+
parser = argparse.ArgumentParser(description='IMAGE_DEMOIREING')
7+
parser.add_argument('--config', type=str, default='config/uhdm_config.yaml', help='path to config file')
8+
args_cfg = parser.parse_args()
9+
assert args_cfg.config is not None
10+
with open(args_cfg.config, 'r') as f:
11+
config = yaml.load(f, Loader=yaml.FullLoader)
12+
for key in config:
13+
for k, v in config[key].items():
14+
setattr(args_cfg, k, v)
15+
16+
return args_cfg
17+
18+
19+
args = get_parser()

config/fhdmi_config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/fhdmi'
6+
EXP_NAME: 'exp_light'
7+
8+
DATA:
9+
DATA_TYPE: FHDMi # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 1 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
CROP_SIZE: 512 # Set the crop size if LOADER==crop
24+
RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 150 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 150 # The total training epochs
40+
T_0: 50 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle
44+

config/fhdmi_large_config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/fhdmi'
6+
EXP_NAME: 'exp_large'
7+
8+
DATA:
9+
DATA_TYPE: FHDMi # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 2 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
CROP_SIZE: 512 # Set the crop size if LOADER==crop
24+
RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 150 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 150 # The total training epochs
40+
T_0: 50 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle
44+

config/tip_config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/tip'
6+
EXP_NAME: 'exp_light'
7+
8+
DATA:
9+
DATA_TYPE: TIP # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 1 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
#LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
#CROP_SIZE: 768 # Set the crop size if LOADER==crop
24+
#RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 70 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 70 # The total training epochs
40+
T_0: 10 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle
44+

config/tip_large_config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GENERAL:
2+
GPU_ID: 3
3+
SEED: 123
4+
WORKER: 8
5+
SAVE_PREFIX: './out_dir/tip'
6+
EXP_NAME: 'exp_large'
7+
8+
DATA:
9+
DATA_TYPE: TIP # Please specify the type of the dataset (select from AIM/UHDM/FHDMi/TIP)
10+
TRAIN_DATASET: # The training data path, e.g., ./uhdm_data/Train
11+
TEST_DATASET: # The test data path, e.g., ./uhdm_data/Test
12+
13+
MODEL:
14+
EN_FEATURE_NUM: 48 # The initial channel number of dense blocks of encoder
15+
EN_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of encoder
16+
DE_FEATURE_NUM: 64 # The initial channel number of dense blocks of decoder
17+
DE_INTER_NUM: 32 # The growth rate (intermediate channel number) of dense blocks of decoder
18+
SAM_NUMBER: 2 # The number of SAM for each encoder or decoder level; set 1 for our ESDNet, and 2 for ESDNet-L
19+
20+
TRAIN:
21+
BATCH_SIZE: 2
22+
#LOADER: crop # The loading way for training data, e.g., crop, resize, default; see ./dataset/load_data.py
23+
#CROP_SIZE: 768 # Set the crop size if LOADER==crop
24+
#RESIZE_SIZE: 384 # Set the resizing size if LOADER==crop
25+
SAVE_ITER: 500 # Save training images/results at each SAVE_ITER*n iter
26+
LOAD_EPOCH: False # If specify it, loading the corresponding model for resuming training
27+
LAM: 1 # The loss weight for L1 loss
28+
LAM_P: 1 # The loss weight for perceptual loss
29+
30+
TEST:
31+
TEST_EPOCH: 70 # Input 'auto' for loading the latest model
32+
SAVE_IMG: False # The file type (e.g., jpg, png) for saving the output image; set False to avoid saving
33+
LOAD_PATH: False # If specify a load path for a checkpoint, TEST_EPOCH will be deprecated
34+
EVALUATION_METRIC: True # If True, calculate metrics
35+
EVALUATION_TIME: False # If True, calculate processing time per image; EVALUATION_METRIC will be deprecated for accurate statistics
36+
EVALUATION_COST: False #If True, calculate MACs and Parameters number
37+
38+
SOLVER:
39+
EPOCHS: 70 # The total training epochs
40+
T_0: 10 # The total epochs for the first learning cycle (learning rate warms up then)
41+
T_MULT: 1 # The learning cycle would be (T_0, T_0*T_MULT, T_0*T_MULT^2, T_0*T_MULT^3, ...)
42+
ETA_MIN: 0.000001 # Initial learning rate in each learning cycle
43+
BASE_LR: 0.0002 # Learning rate in the end of each learning cycle
44+

0 commit comments

Comments
 (0)