Create the conda environment

May 9, 2025 · View on GitHub

ProDehaze: Prompting Diffusion Models Toward Faithful Image Dehazing

Paper|Project Page

This is the official repo of ProDehaze: Prompting Diffusion Models Toward Faithful Image Dehazing by Pytorch. show

News: Our paper has been accepted to ICME 2025!

Getting started

Dependency Installation

# git clone this repository
git clone https://github.com/TianwenZhou/ProDehaze.git
cd ProDehaze

# Create the conda environment 
conda env create --file environment.yaml
conda activate prodehaze

# Install taming & clip
pip install -e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers
pip install -e git+https://github.com/openai/CLIP.git@main#egg=clip
pip install -e .

Data Preparation

Download

Download train/eval data from the following links:

Training: RESIDE

Testing: I-Haze / O-Haze / Dense-Haze / Nh-Haze / RTTS

Training Data Synthesis

To generate the hazy-clear image pair for training, please refer to the augmentation process of FCB, and prepare the training data in the following structure:

 #Training data file structure
dataset/RESIDE/
├── HR # ground-truth clear images.
├── HR_hazy_src # hazy images.
└── HR_depth # depth images (Generated by [DepthAnything](https://github.com/DepthAnything/Depth-Anything-V2).

#Testing data (e.g. DenseHaze) file structure
dataset/{name}/
├── HR # ground-truth images.
└── HR_hazy # hazy images.

Pretrained Model

We prepared the pretrained model at:

TypeWeights
SPRBaiduNetDisk
HCRBaiduNetDisk

Inference Pipeline

Using the two pre-trained models above, we can conduct sampling conditioned with a hazy input.

python scripts/sr_val_ddpm_text_T_vqganfin_old.py --config configs/LatentDehazing/v2-finetune_text_T_512.yaml --ckpt CKPT --init-img HAZY_PATH --outdir OUT_PATH --ddpm_steps 50 --dec_w 1 --seed 42 --n_samples 1 --vqgan_ckpt VQGAN_CKPT --colorfix_type none

Training Pipeline

You should train the SPR and HCR seperately. For the SPR, the training can be conducted with the following command. Note that you have to alter the config files corresponding to your real file paths.

python main.py --train --base configs/LatentDehazing/v2-finetune_text_T_512.yaml --gpus GPU_ID, --name NAME --scale_lr False

As for the HCR, you should first generate the additional training data in its .npy format, with the following command, where the CKPT_PATH should be the SPR you have already trained in the first place.

python scripts/generate_vqgan_data.py --config configs/LatentDehazing/test_data.yaml --ckpt CKPT_PATH --outdir OUTDIR --skip_grid --ddpm_steps 50 --base_i 0 --seed 10000

The generated file structure should look like this:

CFW_trainingdata/
    └── inputs
          └── 00000001.png # Hazy input, (512, 512, 3) (resize to 512x512)
          └── ...
    └── gts
          └── 00000001.png # Groundtruth, (512, 512, 3) (512x512)
          └── ...
    └── latents
          └── 00000001.npy # Latent codes (N, 4, 64, 64) 
          └── ...
    └── samples
          └── 00000001.png # Samples decoded directly from the latent codes, just to confirm that the latent codes are correctly generated.
          └── ...

After this, you can train the HCR with the following command:

python main.py --train --base configs/autoencoder/autoencoder_kl_64x64x4_resi.yaml --gpus GPU_ID, --name NAME --scale_lr False

Result

show