Skip to content

Yuan-Yutao/ECDP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

ECDP

Code for paper "Effcient Conditional Diffusion Model with Probability Flow Sampling for Image Super-resolution".

Required packages

pip install torch torchvision
pip install click lpips pillow piq pyyaml torchdiffeq tqdm

Prepare datasets

Put datasets into data/..., for example, DIV2K dataset should be put in data/div2k/{DIV2K_train_HR,DIV2K_valid_HR,DIV2K_valid_LR_bicubic}. For more details, see code in lib/datasets.

Training ECDP

First, train the RRDB encoder:

./main.py train --config conf/rrdbnet-df2k.yaml experiment-name

Then, extract the parameters of RRDB encoder from the checkpoint:

s = torch.load('results/.../checkpoint.pt', map_location=torch.device('cpu'))
t = {}
for k, v in s['model'].items():
    if k.startswith('model.'):
        t[k[6:]] = v
torch.save(t, 'pretrained-rrdbnet-df2k.pt')

Train the ECDP model:

./main.py train --config conf/ecdp-df2k-train.yaml experiment-name

Finetune the ECDP model using image quality loss:

# You need to modify finetune_pretrained_model in the config file
./main.py train --config conf/ecdp-df2k-finetune.yaml experiment-name

Testing ECDP

# Experiment name here should be those in results directory
./main.py test experiment-name --save-images

The images are now in the results directory.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages