1yuech5@mail2.sysu.edu.cn, Sun Yat-sen University
Official PyTorch implementation of GOUB, a diffusion bridge model that applies the Doob's h-transform to the generalized Ornstein-Uhlenbeck process. This model can address general image restoration tasks without requiring task-specific prior knowledge.
This code is developed with Python 3. We recommend Python >= 3.8 and PyTorch == 1.13.0. Install the dependencies with Anaconda and activate the environment with:
conda create --name GOUB python=3.8
conda activate GOUB
pip install -r requirements.txt
- Prepare the datasets.
- Download the pretrained checkpoints here. The datasets are also provided.
- Modify the options, including
dataroot_GT,dataroot_LQ, andpretrain_model_G. - Choose a model to sample. The default model is GOUB. See the test function in
codes/models/denoising_model.py. - Run
python test.py -opt=options/test.yml.
The test results will be saved in \results.
- Prepare the datasets.
- Modify the options, including
dataroot_GTanddataroot_LQ. - Run
python train.py -opt=options/train.ymlfor single-GPU training.
Runpython -m torch.distributed.launch --nproc_per_node=2 --master_port=1111 train.py -opt=options/train.yml --launcher pytorchfor multi-GPU training. Note: see Important Option Details.
The training logs will be saved in \experiments.
We provide interface.py for deraining, which can generate high-quality images from low-quality inputs:
- Prepare
options/test.ymland fill in the LQ path. - Run
python interface.py. - The interface will be launched on a local server at 127.0.0.1.
Other tasks can also be implemented similarly.
dataroot_GT: Ground-truth high-quality data path.dataroot_LQ: Low-quality data path.pretrain_model_G: Pretrained model path.GT_size, LQ_size: Crop size of the data during training.niter: Total number of training iterations.val_freq: Validation frequency during training.save_checkpoint_freq: Checkpoint saving frequency during training.gpu_ids: In multi-GPU training, GPU IDs should be separated by commas.batch_size: In multi-GPU training, the following relation must be satisfied: batch_size / num_gpu > 1.
We provide brief guidelines for computing the FID between two sets of images:
- Install the FID library:
pip install pytorch-fid. - Compute FID:
python -m pytorch_fid GT_images_file_path generated_images_file_path --batch-size 1.
If all images have the same size, you can remove--batch-size 1to accelerate computation.

