Pytorch implementation of [ShapeMoire: Channel-Wise Shape-Based Network for Image Demoireing].
-
Requirements
- Linux or macOS (Windows is not currently officially supported)
- Python 3.8
- PyTorch 1.9.0
- CUDA 11.1
- GCC 7.3.0
-
Install dependencies.
Here is a full script for setting up ShapeMoire with conda.
# build conda environment conda create -n shapemoire python=3.8 -y conda activate shapemoire # install latest PyTorch prebuilt with the default prebuilt CUDA version conda install pytorch torchvision -c pytorch # install other dependencies conda install lpips==0.1.4 numpy==1.25.2 opencv_python==4.8.0.76 Pillow==10.0.1 PyYAML==6.0.1 skimage==0.0 tensorboardX==2.6.2.2 thop==0.1.1.post2209072238 tqdm==4.66.1
-
Download Dataset
You can download four open datasets: FHDMi, TIP2018, UHDM and LCDMoire from the Internet.
Link dataset path under
$ShapeMoire/data
. -
Data Structure
Finally, the total data structure is shown like this:
Shapemoire/ |---configs/ |---data/ | |---FHDMi/ | | |---train/ | | |---test/ | |---TIP2018/ | | |---train/ | | |---test/ | |---UHDM/ | | |---train/ | | |---test/ | |---LCDMoire/ | | |---train/ | | |---test/
-
Train
For training process, we use config file in
$ShapeMoire/configs
to define model, dataset and hyber parameters.Run the following command to start a training process. You should specify the model and dataset before training.
python train_{MODEL_NAME}.py --config {DATASET_NAME}.yaml
Note:
- The default config file is defined to train Shapemoire. For training baseline model, modify config with 'TEST_BASELINE: True'.
- For ESDNet, in order to train ESDNet-L, modify config with 'SAM_NUM:2'.
-
Test
Run the following command to start a testing process.
Except for choosing model and dataset, You need to specify the checkpoint using the parameter 'LOAD_PATH' within config.
python test_{MODEL_NAME}.py --config {DATASET_NAME}.yaml
Architecture | Method | PSNR | Params. (M) | |||
---|---|---|---|---|---|---|
UHDM | FHDMi | TIP2018 | LCDMoire | |||
ESDNet | Baseline | 22.253 | 24.393 | 29.791 | 45.286 | 5.394 |
ShapeMoire | 22.597 | 24.629 | 29.862 | 45.537 | 5.394 | |
+ | 0.344 | 0.236 | 0.071 | 0.251 | 0 | |
ESDNet-L | Baseline | 22.554 | 24.808 | 30.096 | 45.544 | 10.623 |
ShapeMoire | 22.948 | 25.064 | 30.161 | 46.558 | 10.623 | |
+ | 0.394 | 0.256 | 0.065 | 1.014 | 0 | |
WDNet | Baseline | 19.182 | 21.161 | 27.812 | 37.324 | 3.360 |
ShapeMoire | 19.882 | 22.182 | 28.312 | 38.408 | 3.360 | |
+ | 0.500 | 1.021 | 0.500 | 1.084 | 0 | |
DMCNN | Baseline | 17.812 | 19.313 | 24.519 | 29.321 | 1.426 |
ShapeMoire | 18.036 | 19.615 | 25.381 | 29.649 | 1.426 | |
+ | 0.223 | 0.302 | 0.862 | 0.329 | 0 |