Home

Awesome

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/logo_onerestore.png" width="200"> </div>

<p align=center> [ECCV 2024] OneRestore: A Universal Restoration Framework for Composite Degradation</p>

<div align="center">

ArXiv Paper Web Poster Video

Hits Hugging Face Demo Closed Issues Open Issues

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/abstract.jpg" width="720"> </div>

OneRestore: A Universal Restoration Framework for Composite Degradation<br> Yu Guo<sup></sup>, Yuan Gao<sup></sup>, Yuxu Lu, Huilin Zhu, Ryan Wen Liu<sup>* </sup>, Shengfeng He<sup>* </sup> <br> († Co-first Author, * Corresponding Author)<br> European Conference on Computer Vision

Abstract: In real-world scenarios, image impairments often manifest as composite degradations, presenting a complex interplay of elements such as low light, haze, rain, and snow. Despite this reality, existing restoration methods typically target isolated degradation types, thereby falling short in environments where multiple degrading factors coexist. To bridge this gap, our study proposes a versatile imaging model that consolidates four physical corruption paradigms to accurately represent complex, composite degradation scenarios. In this context, we propose OneRestore, a novel transformer-based framework designed for adaptive, controllable scene restoration. The proposed framework leverages a unique cross-attention mechanism, merging degraded scene descriptors with image features, allowing for nuanced restoration. Our model allows versatile input scene descriptors, ranging from manual text embeddings to automatic extractions based on visual attributes. Our methodology is further enhanced through a composite degradation restoration loss, using extra degraded images as negative samples to fortify model constraints. Comparative results on synthetic and real-world datasets demonstrate OneRestore as a superior solution, significantly advancing the state-of-the-art in addressing complex, composite degradations.


News 🚀

Network Architecture

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/pipeline.jpg" width="1080"> </div>

Quick Start

Install

# git clone this repository
git clone https://github.com/gy65896/OneRestore.git
cd OneRestore

# create new anaconda env
conda create -n onerestore python=3.7
conda activate onerestore 

# download ckpts
put embedder_model.tar and onerestore_cdd-11.tar in ckpts folder

# install pytorch (Take cuda 11.7 as an example to install torch 1.13)
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117

# install other packages
pip install -r requirements.txt
pip install genism

Pretrained Models

Please download our pre-trained models and put them in ./ckpts.

ModelDescription
embedder_model.tarText/Visual Embedder trained on our CDD-11.
onerestore_cdd-11.tarOneRestore trained on our CDD-11.
onerestore_real.tarOneRestore trained on our CDD-11 for Real Scenes.
onerestore_lol.tarOneRestore trained on LOL (low light enhancement benchmark).
onerestore_reside_ots.tarOneRestore trained on RESIDE-OTS (image dehazing benchmark).
onerestore_rain1200.tarOneRestore trained on Rain1200 (image deraining benchmark).
onerestore_snow100k.tarOneRestore trained on Snow100k-L (image desnowing benchmark).

Inference

We provide two samples in ./image for the quick inference:

python test.py --embedder-model-path ./ckpts/embedder_model.tar --restore-model-path ./ckpts/onerestore_cdd-11.tar --input ./image/ --output ./output/ --concat

You can also input the prompt to perform controllable restoration. For example:

python test.py --embedder-model-path ./ckpts/embedder_model.tar --restore-model-path ./ckpts/onerestore_cdd-11.tar --prompt low_haze --input ./image/ --output ./output/ --concat

Training

Prepare Dataset

We provide the download link of our Composite Degradation Dataset with 11 types of degradation (CDD-11).

Preparing the train and test datasets as follows:

./data/
|--train
|  |--clear
|  |  |--000001.png
|  |  |--000002.png
|  |--low
|  |--haze
|  |--rain
|  |--snow
|  |--low_haze
|  |--low_rain
|  |--low_snow
|  |--haze_rain
|  |--haze_snow
|  |--low_haze_rain
|  |--low_haze_snow
|--test

Train Model

1. Train Text/Visual Embedder by

python train_Embedder.py --train-dir ./data/CDD-11_train --test-dir ./data/CDD-11_test --check-dir ./ckpts --batch 256 --num-workers 0 --epoch 200 --lr 1e-4 --lr-decay 50

2. Remove the optimizer weights in the Embedder model file by

python remove_optim.py --type Embedder --input-file ./ckpts/embedder_model.tar --output-file ./ckpts/embedder_model.tar

3. Generate the dataset.h5 file for training OneRestore by

python makedataset.py --train-path ./data/CDD-11_train --data-name dataset.h5 --patch-size 256 --stride 200

4. Train OneRestore model by

python train_OneRestore_single-gpu.py --embedder-model-path ./ckpts/embedder_model.tar --save-model-path ./ckpts --train-input ./dataset.h5 --test-input ./data/CDD-11_test --output ./result/ --epoch 120 --bs 4 --lr 1e-4 --adjust-lr 30 --num-works 4

Assuming you train the OneRestore model using 4 GPUs (e.g., 0, 1, 2, and 3), you can use the following command. Note that the number of nproc_per_node should equal the number of GPUs.

CUDA_VISIBLE_DEVICES=0, 1, 2, 3 torchrun --nproc_per_node=4 train_OneRestore_multi-gpu.py --embedder-model-path ./ckpts/embedder_model.tar --save-model-path ./ckpts --train-input ./dataset.h5 --test-input ./data/CDD-11_test --output ./result/ --epoch 120 --bs 4 --lr 1e-4 --adjust-lr 30 --num-works 4

5. Remove the optimizer weights in the OneRestore model file by

python remove_optim.py --type OneRestore --input-file ./ckpts/onerestore_model.tar --output-file ./ckpts/onerestore_model.tar

Customize your own composite degradation dataset

1. Prepare raw data

A generated example is as follows:

Clear ImageDepth MapLight MapRain MaskSnow Mask
<img src="https://github.com/gy65896/OneRestore/blob/main/img_file/clear_img.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/depth_map.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/light_map.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/rain_mask.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/snow_mask.png" width="200">

(Note: The rain and snow masks do not require strict alignment with the image.)

./syn_data/
|--data
|  |--clear
|  |  |--000001.png
|  |  |--000002.png
|  |--depth_map
|  |  |--000001.png
|  |  |--000002.png
|  |--light_map
|  |  |--000001.png
|  |  |--000002.png
|  |--rain_mask
|  |  |--aaaaaa.png
|  |  |--bbbbbb.png
|  |--snow_mask
|  |  |--cccccc.png
|  |  |--dddddd.png
|--out

2. Generate composite degradation images

python syn_data.py --hq-file ./data/clear/ --light-file ./data/light_map/ --depth-file ./data/depth_map/ --rain-file ./data/rain_mask/ --snow-file ./data/snow_mask/ --out-file ./out/ --low --haze --rain
python syn_data.py --hq-file ./data/clear/ --light-file ./data/light_map/ --depth-file ./data/depth_map/ --rain-file ./data/rain_mask/ --snow-file ./data/snow_mask/ --out-file ./out/ --low --haze --snow

(Note: The degradation types can be customized according to specific needs.)

Clear Imagelow+haze+rainlow+haze+snow
<img src="https://github.com/gy65896/OneRestore/blob/main/img_file/clear_img.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/l+h+r.jpg" width="200"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/l+h+s.jpg" width="200">

Performance

CDD-11

TypesMethodsVenue & YearPSNR ↑SSIM ↑#Params
InputInput16.000.6008-
One-to-OneMIRNetECCV202025.970.847431.79M
One-to-OneMPRNetCVPR202125.470.855515.74M
One-to-OneMIRNetv2TPAMI202225.370.83355.86M
One-to-OneRestormerCVPR202226.990.864626.13M
One-to-OneDGUNetCVPR202226.920.855917.33M
One-to-OneNAFNetECCV202224.130.796417.11M
One-to-OneSRUDCICCV202327.640.86006.80M
One-to-OneFourmerICML202323.440.78850.55M
One-to-OneOKNetAAAI202426.330.86054.72M
One-to-ManyAirNetCVPR202223.750.81408.93M
One-to-ManyTransWeatherCVPR202223.130.781021.90M
One-to-ManyWeatherDiffTPAMI202322.490.798582.96M
One-to-ManyPromptIRNIPS202325.900.849938.45M
One-to-ManyWGWSNetCVPR202326.960.862625.76M
One-to-CompositeOneRestoreECCV202428.470.87845.98M
One-to-CompositeOneRestore<sup></sup>ECCV202428.720.88215.98M

Indicator calculation code and numerical results can be download here.

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/syn.jpg" width="1080"> </div>

Real Scene

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/real.jpg" width="1080"> </div>

Controllability

</div> <div align=center> <img src="https://github.com/gy65896/OneRestore/blob/main/img_file/control1.jpg" width="410"><img src="https://github.com/gy65896/OneRestore/blob/main/img_file/control2.jpg" width="410"> </div>

Citation

@inproceedings{guo2024onerestore,
  title={OneRestore: A Universal Restoration Framework for Composite Degradation},
  author={Guo, Yu and Gao, Yuan and Lu, Yuxu and Liu, Ryan Wen and He, Shengfeng},
  booktitle={European Conference on Computer Vision},
  year={2024}
}

If you have any questions, please get in touch with me (guoyu65896@gmail.com).