gy65896 commited on
Commit
4730297
·
verified ·
1 Parent(s): 8512515

Upload 8 files

Browse files
README.md ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ base_model:
5
+ - gy65896/OneRestore
6
+ pipeline_tag: image-to-image
7
+ datasets:
8
+ - gy65896/CDD-11
9
+ ---
10
+ </div>
11
+ <div align=center>
12
+ <img src="./img_file/logo_onerestore.png" width="200">
13
+ </div>
14
+
15
+ # <p align=center> [ECCV 2024] OneRestore: A Universal Restoration Framework for Composite Degradation</p>
16
+
17
+
18
+ <div align=center>
19
+ <img src="./img_file/abstract.jpg" width="720">
20
+ </div>
21
+
22
+ ---
23
+ >**OneRestore: A Universal Restoration Framework for Composite Degradation**<br> [Yu Guo](https://scholar.google.com/citations?user=klYz-acAAAAJ&hl=zh-CN)<sup>† </sup>, [Yuan Gao](https://scholar.google.com.hk/citations?user=4JpRnU4AAAAJ&hl=zh-CN)<sup>† </sup>, [Yuxu Lu](https://scholar.google.com.hk/citations?user=XXge2_0AAAAJ&hl=zh-CN), [Huilin Zhu](https://scholar.google.com.hk/citations?hl=zh-CN&user=fluPrxcAAAAJ), [Ryan Wen Liu](http://mipc.whut.edu.cn/index.html)<sup>* </sup>, [Shengfeng He](http://www.shengfenghe.com/)<sup>* </sup> <br>
24
+ († Co-first Author, * Corresponding Author)<br>
25
+ >European Conference on Computer Vision
26
+
27
+ > **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.*
28
+ ---
29
+
30
+ ## News 🚀
31
+ * **2024.09.07**: [Hugging Face Demo](https://huggingface.co/spaces/gy65896/OneRestore) is released.
32
+ * **2024.09.05**: Video and poster are released.
33
+ * **2024.09.04**: Code for data synthesis is released.
34
+ * **2024.07.27**: Code for multiple GPUs training is released.
35
+ * **2024.07.20**: [New Website](https://gy65896.github.io/projects/ECCV2024_OneRestore) has been created.
36
+ * **2024.07.10**: [Paper](https://arxiv.org/abs/2407.04621) is released on ArXiv.
37
+ * **2024.07.07**: Code and Dataset are released.
38
+ * **2024.07.02**: OneRestore is accepted by [ECCV2024](https://eccv.ecva.net/).
39
+
40
+ ## Network Architecture
41
+
42
+ </div>
43
+ <div align=center>
44
+ <img src="./img_file/pipeline.jpg" width="1080">
45
+ </div>
46
+
47
+ ## Quick Start
48
+
49
+ ### Install
50
+
51
+ - python 3.7
52
+ - cuda 11.7
53
+
54
+ ```
55
+ # git clone this repository
56
+ git clone https://github.com/gy65896/OneRestore.git
57
+ cd OneRestore
58
+
59
+ # create new anaconda env
60
+ conda create -n onerestore python=3.7
61
+ conda activate onerestore
62
+
63
+ # download ckpts
64
+ put embedder_model.tar and onerestore_cdd-11.tar in ckpts folder
65
+
66
+ # install pytorch (Take cuda 11.7 as an example to install torch 1.13)
67
+ 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
68
+
69
+ # install other packages
70
+ pip install -r requirements.txt
71
+ pip install gensim
72
+ ```
73
+
74
+ ### Pretrained Models
75
+
76
+ Please download our pre-trained models and put them in `./ckpts`.
77
+
78
+ | Model | Description
79
+ | :--- | :----------
80
+ |[embedder_model.tar](https://1drv.ms/u/s!As3rCDROnrbLgqpnhSQFIoD9msXWOA?e=aUpHOT) | Text/Visual Embedder trained on our CDD-11.
81
+ |[onerestore_cdd-11.tar](https://1drv.ms/u/s!As3rCDROnrbLgqpmWkGBku6oj33efg?e=7yUGfN) | OneRestore trained on our CDD-11.
82
+ |[onerestore_real.tar](https://1drv.ms/u/s!As3rCDROnrbLgqpi-iJOyN6OSYqiaA?e=QFfMeL) | OneRestore trained on our CDD-11 for Real Scenes.
83
+ |[onerestore_lol.tar](https://1drv.ms/u/s!As3rCDROnrbLgqpkSoVB1j-wYHFpHg?e=0gR9pn) | OneRestore trained on LOL (low light enhancement benchmark).
84
+ |[onerestore_reside_ots.tar](https://1drv.ms/u/s!As3rCDROnrbLgqpjGh8KjfM_QIJzEw?e=zabGTw) | OneRestore trained on RESIDE-OTS (image dehazing benchmark).
85
+ |[onerestore_rain1200.tar](https://1drv.ms/u/s!As3rCDROnrbLgqplAFHv6B348jarGA?e=GuduMT) | OneRestore trained on Rain1200 (image deraining benchmark).
86
+ |[onerestore_snow100k.tar](https://1drv.ms/u/s!As3rCDROnrbLgqphsWWxLZN_7JFJDQ?e=pqezzo) | OneRestore trained on Snow100k-L (image desnowing benchmark).
87
+
88
+ ### Inference
89
+
90
+ We provide two samples in `./image` for the quick inference:
91
+
92
+ ```
93
+ python test.py --embedder-model-path ./ckpts/embedder_model.tar --restore-model-path ./ckpts/onerestore_cdd-11.tar --input ./image/ --output ./output/ --concat
94
+ ```
95
+
96
+ You can also input the prompt to perform controllable restoration. For example:
97
+
98
+ ```
99
+ 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
100
+ ```
101
+
102
+ ## Training
103
+
104
+ ### Prepare Dataset
105
+
106
+ We provide the download link of our Composite Degradation Dataset with 11 types of degradation ([CDD-11](https://1drv.ms/f/s!As3rCDROnrbLgqpezG4sao-u9ddDhw?e=A0REHx)).
107
+
108
+ Preparing the train and test datasets as follows:
109
+
110
+ ```
111
+ ./data/
112
+ |--train
113
+ | |--clear
114
+ | | |--000001.png
115
+ | | |--000002.png
116
+ | |--low
117
+ | |--haze
118
+ | |--rain
119
+ | |--snow
120
+ | |--low_haze
121
+ | |--low_rain
122
+ | |--low_snow
123
+ | |--haze_rain
124
+ | |--haze_snow
125
+ | |--low_haze_rain
126
+ | |--low_haze_snow
127
+ |--test
128
+ ```
129
+ ### Train Model
130
+
131
+ **1. Train Text/Visual Embedder by**
132
+
133
+ ```
134
+ 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
135
+ ```
136
+
137
+ **2. Remove the optimizer weights in the Embedder model file by**
138
+
139
+ ```
140
+ python remove_optim.py --type Embedder --input-file ./ckpts/embedder_model.tar --output-file ./ckpts/embedder_model.tar
141
+ ```
142
+
143
+ **3. Generate the `dataset.h5` file for training OneRestore by**
144
+
145
+ ```
146
+ python makedataset.py --train-path ./data/CDD-11_train --data-name dataset.h5 --patch-size 256 --stride 200
147
+ ```
148
+
149
+ **4. Train OneRestore model by**
150
+
151
+ - **Single GPU**
152
+
153
+ ```
154
+ 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
155
+ ```
156
+
157
+ - **Multiple GPUs**
158
+
159
+ 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.
160
+
161
+ ```
162
+ 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
163
+ ```
164
+
165
+ **5. Remove the optimizer weights in the OneRestore model file by**
166
+
167
+ ```
168
+ python remove_optim.py --type OneRestore --input-file ./ckpts/onerestore_model.tar --output-file ./ckpts/onerestore_model.tar
169
+ ```
170
+
171
+ ### Customize your own composite degradation dataset
172
+
173
+ **1. Prepare raw data**
174
+
175
+ - Collect your own clear images.
176
+ - Generate the depth map based on [MegaDepth](https://github.com/zhengqili/MegaDepth).
177
+ - Generate the light map based on [LIME](https://github.com/estija/LIME).
178
+ - Generate the rain mask database based on [RainStreakGen](https://github.com/liruoteng/RainStreakGen?tab=readme-ov-file).
179
+ - Download the snow mask database from [Snow100k](https://sites.google.com/view/yunfuliu/desnownet).
180
+
181
+ A generated example is as follows:
182
+
183
+ | Clear Image | Depth Map | Light Map | Rain Mask | Snow Mask
184
+ | :--- | :---| :---| :--- | :---
185
+ | <img src="./img_file/clear_img.jpg" width="200"> | <img src="./img_file/depth_map.jpg" width="200"> | <img src="./img_file/light_map.jpg" width="200"> | <img src="./img_file/rain_mask.jpg" width="200"> | <img src="./img_file/snow_mask.png" width="200">
186
+
187
+ (Note: The rain and snow masks do not require strict alignment with the image.)
188
+
189
+ - Prepare the dataset as follows:
190
+
191
+ ```
192
+ ./syn_data/
193
+ |--data
194
+ | |--clear
195
+ | | |--000001.png
196
+ | | |--000002.png
197
+ | |--depth_map
198
+ | | |--000001.png
199
+ | | |--000002.png
200
+ | |--light_map
201
+ | | |--000001.png
202
+ | | |--000002.png
203
+ | |--rain_mask
204
+ | | |--aaaaaa.png
205
+ | | |--bbbbbb.png
206
+ | |--snow_mask
207
+ | | |--cccccc.png
208
+ | | |--dddddd.png
209
+ |--out
210
+ ```
211
+
212
+ **2. Generate composite degradation images**
213
+
214
+ - low+haze+rain
215
+
216
+ ```
217
+ 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
218
+ ```
219
+
220
+ - low+haze+snow
221
+
222
+ ```
223
+ 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
224
+ ```
225
+ (Note: The degradation types can be customized according to specific needs.)
226
+
227
+ | Clear Image | low+haze+rain | low+haze+snow
228
+ | :--- | :--- | :---
229
+ | <img src="./img_file/clear_img.jpg" width="200"> | <img src="./img_file/l+h+r.jpg" width="200"> | <img src="./img_file/l+h+s.jpg" width="200">
230
+
231
+ ## Performance
232
+
233
+ ### CDD-11
234
+
235
+ | Types | Methods | Venue & Year | PSNR ↑ | SSIM ↑ | #Params |
236
+ |-------------------|-----------------------------------------------|--------------|----------|----------|------------|
237
+ | Input | [Input](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuNlQAAAAABf9KaFodlfC8H-K_MNiriFw?e=SiOrWU) | | 16.00 | 0.6008 | - |
238
+ | One-to-One | [MIRNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuMlQAAAAABBzDLjLu69noXflImQ2V9ng?e=4wohVK) | ECCV2020 | 25.97 | 0.8474 | 31.79M |
239
+ | One-to-One | [MPRNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuLlQAAAAAB_iz3hjLHZDMi-RyxHKgDDg?e=SwSQML) | CVPR2021 | 25.47 | 0.8555 | 15.74M |
240
+ | One-to-One | [MIRNetv2](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuQlQAAAAAB2miyepdTE3qdy4z2-LM4pg?e=moXVAR) | TPAMI2022 | 25.37 | 0.8335 | 5.86M |
241
+ | One-to-One | [Restormer](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuPlQAAAAABE86t03kpAVm_TZDIBPKolw?e=vHAR7A) | CVPR2022 | 26.99 | 0.8646 | 26.13M |
242
+ | One-to-One | [DGUNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuOlQAAAAABZkHj8tMamqaGhQ0w4VwFrg?e=lfDUlx) | CVPR2022 | 26.92 | 0.8559 | 17.33M |
243
+ | One-to-One | [NAFNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/EWm9jiJiZLlLgq1trYO67EsB42LrjGpepvpS4oLqKnj8xg?e=5Efa4W) | ECCV2022 | 24.13 | 0.7964 | 17.11M |
244
+ | One-to-One | [SRUDC](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuWlQAAAAABf9RNAUZH_xL6wF4aODWKqA?e=h4EqVN) | ICCV2023 | 27.64 | 0.8600 | 6.80M |
245
+ | One-to-One | [Fourmer](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuXlQAAAAABQKrbA47G8kMD2cf7Chq5EQ?e=vOiWV0) | ICML2023 | 23.44 | 0.7885 | 0.55M |
246
+ | One-to-One | [OKNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuVlQAAAAABSMzfS1xEOxLeuvw8HsGyMw?e=jRmf9t) | AAAI2024 | 26.33 | 0.8605 | 4.72M |
247
+ | One-to-Many | [AirNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMualQAAAAABYJ96PX0fipkP93zRXN_NVw?e=sXFOl8) | CVPR2022 | 23.75 | 0.8140 | 8.93M |
248
+ | One-to-Many | [TransWeather](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuZlQAAAAABoBiLjwJ8L2kl6rGQO5PeJA?e=msprhI) | CVPR2022 | 23.13 | 0.7810 | 21.90M |
249
+ | One-to-Many | [WeatherDiff](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuYlQAAAAABxdWbznZA1CQ0Bh1JH_ze-A?e=LEkcZw) | TPAMI2023 | 22.49 | 0.7985 | 82.96M |
250
+ | One-to-Many | [PromptIR](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMublQAAAAAB9aGo3QK-WlKkL5ItITW9Hg?e=wXrJf1) | NIPS2023 | 25.90 | 0.8499 | 38.45M |
251
+ | One-to-Many | [WGWSNet](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMudlQAAAAABi3HUMldxdoLHgDcUNoWMPw?e=z0qjAH) | CVPR2023 | 26.96 | 0.8626 | 25.76M |
252
+ | One-to-Composite | [OneRestore](https://1drv.ms/u/c/cbb69e4e3408ebcd/Ec3rCDROnrYggMuclQAAAAABSmNvDBKR1u5rDtqQnZ8X7A?e=OcnrjY) | ECCV2024 | 28.47 | 0.8784 | 5.98M |
253
+ | One-to-Composite | [OneRestore<sup>† </sup>](https://1drv.ms/u/c/cbb69e4e3408ebcd/EVM43y_W_WxAjrZqZdK9sfoBk1vpSzKilG0m7T-3i3la-A?e=dbNsD3) | ECCV2024 | 28.72 | 0.8821 | 5.98M |
254
+
255
+ [Indicator calculation code](https://github.com/gy65896/OneRestore/blob/main/img_file/cal_psnr_ssim.py) and [numerical results](https://github.com/gy65896/OneRestore/blob/main/img_file/metrics_CDD-11_psnr_ssim.xlsx) can be download here.
256
+
257
+ </div>
258
+ <div align=center>
259
+ <img src="./img_file/syn.jpg" width="1080">
260
+ </div>
261
+
262
+ ### Real Scene
263
+
264
+ </div>
265
+ <div align=center>
266
+ <img src="./img_file/real.jpg" width="1080">
267
+ </div>
268
+
269
+ ### Controllability
270
+
271
+ </div>
272
+ <div align=center>
273
+ <img src="./img_file/control1.jpg" width="410"><img src="./img_file/control2.jpg" width="410">
274
+ </div>
275
+
276
+
277
+ ## Citation
278
+
279
+ ```
280
+ @inproceedings{guo2024onerestore,
281
+ title={OneRestore: A Universal Restoration Framework for Composite Degradation},
282
+ author={Guo, Yu and Gao, Yuan and Lu, Yuxu and Liu, Ryan Wen and He, Shengfeng},
283
+ booktitle={European Conference on Computer Vision},
284
+ year={2024}
285
+ }
286
+ ```
287
+
288
+ #### If you have any questions, please get in touch with me ([email protected]).
embedder_model.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01c1ed1fe4fd06a73c78a7d1fac1b4092a098f3ea08bc71bcab1e4fdad7f6ec2
3
+ size 48638120
onerestore_cdd-11.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e02e2d87ce56740a9bedb5cffe8b129d3b206590ae3b97050c9b53aa549c7c9f
3
+ size 23993607
onerestore_lol.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1db63d66611962401cd111a6d04d6629e18ed0c504e3469e04c797acdc27ffb
3
+ size 23993607
onerestore_rain1200.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47da852cef9821fdffc205f88c0b17f6dee34e7cfb331737c595d7390aa3dadf
3
+ size 23993607
onerestore_real.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3ba83020e8b4741a35ee963fa8732eccead544718da65b464dd575835509969
3
+ size 23993607
onerestore_reside_ots.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d3f1b283b35f03bd003013679201f85100e72c6d620be3fe940e25ff1502778
3
+ size 23993607
onerestore_snow100k.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2210b6830c38a38c31e9e8a851774480c9d6f7bf6540c77ceff90422f26ca463
3
+ size 23993607