Git Product home page Git Product logo

diwa's Introduction

Waving Goodbye to Low-Res: A Diffusion-Wavelet Approach for Image Super-Resolution

This work presents a novel Diffusion-Wavelet (DiWa) approach for Single-Image Super-Resolution (SISR). It leverages the strengths of Denoising Diffusion Probabilistic Models (DDPMs) and Discrete Wavelet Transformation (DWT). By enabling DDPMs to operate in the DWT domain, our DDPM models effectively hallucinate high-frequency information for super-resolved images on the wavelet spectrum, resulting in high-quality and detailed reconstructions in image space.

Brief

This is the official implementation of Waving Goodbye to Low-Res: A Diffusion-Wavelet Approach for Image Super-Resolution (arXiv paper) in PyTorch. The repo was cleaned before uploading. Please report any bug. It complements the inofficial implementation of SR3 (GitHub).

Usage

Environment

pip install -r requirement.txt

Continue Training

# Download the pretrained model and edit [sr|sample]_[ddpm|sr3]_[resolution option].json about "resume_state":
"resume_state": [your pretrained model's path]

Data Preparation

If you don't have the data, you can prepare it by following steps:

Download the dataset and prepare it in LMDB (not DIV2K) or PNG format using script. For DIV2K, remove the "-l" parameter and also use the preprocessing step described last in this section (to extract sub-images).

# Resize to get 16×16 LR_IMGS and 128×128 HR_IMGS, then prepare 128×128 Fake SR_IMGS by bicubic interpolation
python data/prepare_data.py  --path [dataset root]  --out [output root] --size 16,128 -l

then you need to change the datasets config to your data path and image resolution:

"datasets": {
    "train": {
        "dataroot": "dataset/ffhq_16_128", // [output root] in prepare.py script
        "l_resolution": 16, // low resolution need to super_resolution
        "r_resolution": 128, // high resolution
        "datatype": "lmdb", //lmdb or img, path of img files
    },
    "val": {
        "dataroot": "dataset/celebahq_16_128", // [output root] in prepare.py script
    }
},

For DIV2K, you will need to extract the sub-images beforehand:

python data/prepare_div2k.py  --path [dataset root]  --out [output root]

Note: LMDB does not work for DIV2K.

For the test datasets:

you need to put the files into the dataset folder and run

python data/prepare_natural_tests.py

Training/Resume Training

# Use sr.py and sample.py to train the super resolution task and unconditional generation task, respectively.
# Edit json files to adjust network structure and hyperparameters
python sr.py -p train -c config/sr_sr3.json

Configurations for Training

Tasks Config File
16×16 -> 128×128 on FFHQ-CelebaHQ config/sr_wave_16_128.json
64×64 -> 512×512 on FFHQ-CelebaHQ config/sr_wave_64_512.json
48×48 -> 192×192 on DIV2K config/sr_wave_48_192.json
Ablation - baseline config/sr_wave_48_192_abl_baseline.json
Ablation - Init. Pred. only config/sr_wave_48_192_abl_pred_only.json
Ablation - DWT only config/sr_wave_48_192_abl_wave_only.json
Ablation - DiWa config/sr_wave_48_192_abl_wave+pred.json

Test/Evaluation

# Edit json to add pretrain model path and run the evaluation 
python sr.py -p val -c config/sr_sr3.json

# Quantitative evaluation alone using SSIM/PSNR/LPIPS metrics on given result root
python eval.py -p [result root]

Inference Alone

Set the image path, then run the script:

# run the script
python infer.py -c [config file]

diwa's People

Contributors

brian-moser avatar

Stargazers

 avatar  avatar Aithusa avatar  avatar Hanjia Wei avatar Buster Yeck avatar Jhin avatar MinBLi avatar  avatar Lorenzo Aloisi avatar Mohamed Ramzy Ibrahim avatar Tang avatar 卡布叻_小安 avatar thomasyyu avatar Jeff Carpenter avatar 한승우(Seungu Han) avatar makex1n avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Onur KELEŞ avatar  avatar

Watchers

Xingchen avatar  avatar Onur KELEŞ avatar  avatar Jhin avatar sudo avatar  avatar

diwa's Issues

Strange dot artefacts in results

Hey, thanks for publishing the code!

I've been training your model on Celeba-HQ and the following are some of the results I got at 25k iterations steps:
0_1_sr
0_3_sr
0_4_sr
I was wondering if something similar happened to you too and if you could help me out in figuring out why the images have those strange dot artefacts in it.
Everything in the "sr_wave_16_128.json" config file is the same as published in this repo, expect for the "n_iter" which I set to 25000.

Thank you in advance :)

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.