Code Monkey home page Code Monkey logo

diffuir's Introduction

Selective Hourglass Mapping for Universal Image Restoration Based on Diffusion Model
Official PyTorch Implementation of DiffUIR.

Project Page | Paper | Personal HomePage

Updates

[2024.03.18] The 14 datasets link is released.
[2024.03.17] The whole training and testing codes are released!!!
[2024.03.16] The 4 versions of pretrained weights of DiffUIR are released.
[2024.02.27] ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ Our DiffUIR paper was accepted by CVPR 2024 ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

Introduction

The main challenge of universal image restoration tasks is handling different degradation images at once. In this work, we propose a selective hourglass mapping strategy based on conditional diffusion model to learn the shared information between different tasks. Specifically, we integrate a shared distribution term to the diffusion algorithm elegantly and naturally, achieving to map the different distributions to a shared one and could further guide the shared distribution to the task-specific clean image. By only modify the mapping strategy, we outperform large-scale universal methods with at least five times less computational costing.

Framework comparison

image

How to use

Environment

  • Python 3.79
  • Pytorch 1.12

Install

Create a virtual environment and activate it.

conda create -n diffuir python=3.7
conda activate diffuir

Dependencies

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch -c nvidia
pip install opencv-python
pip install scikit-image
pip install tensorboard
pip install matplotlib 
pip install tqdm

Dataset Preparation

Preparing the train and test datasets following our paper Dataset Construction section as:

Datasets/Restoration
|--syn_rain
|  |--train
      |--input
      |--target
|  |--test
|--Snow100K
|--Deblur
|--LOL
|--RESIDE
   |--OTS_ALPHA
      |--haze
      |--clear
   |--SOTS/outdoor
|--real_rain
|--real_dark
|--UDC_val_test

Then get into the data/universal_dataset.py file and modify the dataset paths.

Dataset Links

train

Degradation blurry low-light rainy snowy hazy
Datasets Gopro LOL syn_rain Snow100K RESIDE(5vss)

test

Degradation blurry low-light rainy snowy hazy
Datasets gopro+HIDE+real_R+real_J LOL combine Snow100K SOTS

real

Degradation real_dark real_rain UDC real_snow
Datasets dark rain UDC Snow100K

Train

We train the five image restoration tasks at once, you can change train.py-Line42 to change the task type.
Note that the result of our paper can be reimplemented on RTX 4090, using 3090 or other gpus may cause performance drop.

python train.py

Test and Calculate the Metric

Note that the dataset of SOTS can not calculate the metric online as the number of input and gt images is different. Please use eval/SOTS.m.
The pretrained weight of model-300.pt is used to test with timestep 3.

python test.py

For Under-Camera real-world dataset, as the resolution is high, we split the image into several pathes and merge them after model.
The pretrained weight of model-130.pt is used to test with timestep 4.

python test_udc.py

Visualize

Here you can test our model in your personal image. Note that if you want to test low-light image, please use the code src/visualization-Line1279-1281

python visual.py

Model Zoo

Model DiffUIR-T (0.89M) DiffUIR-S (3.27M) DiffUIR-B (12.41M) DiffUIR-L (36.26M)
Arch 32-1111 Tiny 32-1224 Small 64-1224 Base 64-1248 Large

If you want to run the light version of our DiffUIR, please change the U-net architecture in train.py-Line66, the detailed arch parameters are shown above.

Qualitative results on five restoration tasks

image

Qualitative results on real-world images

image

Analysis of the shared information

The distribution before and after our SDT, SDT map the different distributions to a shared one. image

The attention of the feature map, our method could focus on the degradation type (rain and fog), validating that we learn the useful shared information. image

Citation

If you find this project helpful in your research, welcome to cite the paper.

@inproceedings{zheng2024selective,
  title={Selective Hourglass Mapping for Universal Image Restoration Based on Diffusion Model},
  author={Zheng, Dian and Wu, Xiao-Ming and Yang, Shuzhou and Zhang, Jian and Hu, Jian-Fang and Zheng, Wei-shi},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year={2024}
}

Acknowledgements

Thanks to Jiawei Liu for opening source of his excellent works RDDM. Our work is inspired by these works and part of codes are migrated from RDDM.

Contact

Please contact Dian Zheng if there is any question ([email protected] or [email protected]).

diffuir's People

Contributors

zhengdian1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.