LituRout / PSLD

Posterior Sampling using Latent Diffusion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solving Linear Inverse Problems Provably via Posterior Sampling with Latent Diffusion Models

The repository contains reproducible PyTorch source code of our paper Solving Linear Inverse Problems Provably via Posterior Sampling with Latent Diffusion Models. We present the first framework to solve general inverse problems leveraging pre-trained latent diffusion models. Previously proposed algorithms (such as DPS and DDRM) only apply to pixel-space diffusion models. We theoretically analyze our algorithm showing provable sample recovery in a linear model setting. The algorithmic insight obtained from our analysis extends to more general settings often considered in practice. Experimentally, we outperform previously proposed posterior sampling algorithms in a wide variety of problems including random inpainting, block inpainting, denoising, deblurring, destriping, and super-resolution.

Overall pipeline of our proposed framework from left to right. A web application is hosted at gradio space.

Comparison with state-of-the-art commercial services leveraging Stable Diffusion

This experiment was performed on commercial platforms that use (to the best of our knowledge) Stable diffusion and additional proprietary models. This evaluation was performed on models deployed in May 2023 and may change as commercial providers improve their platforms.

Prerequisites

The implementation is GPU-based. A single GPU (A100) is sufficient to run all experiments. Tested with torch==1.12.0 torchvision==0.13.1a0. To reproduce the reported results, consider using the exact version of PyTorch and its required dependencies as other versions might be incompatible. Make sure to install all the required packages for /diffusion-posterior-sampling/ and /stable-diffusion/. Check if the DPS sampler and Stable Diffusion sampler are working before proceeding to the next steps. Use the latest version of generative foundation model (Stable Diffusion v1-5 Model Card is used in this repo) to get better performance.

Repository structure

All the experiments are issued in the form of pretty self-explanatory python codes. To execute each code, we provide shell scripts inside stable-diffusion/run/ folder.

Main Experiments

Execute the following commands inside the stable-diffusion folder. We recommend tuning gamma and omega for better performance and for solving general (linear) inverse problems on various datasets.

Posterior Sampling using Stable Diffusion

  • sh run/inverse.sh for super-resolution task.
  • sh run/inverse_rip.sh for random inpainting task.
  • sh run/inverse_gb.sh for Gaussian deblur task.
  • sh run/inverse_mb.sh for motion deblur task.
  • sh run/inverse_bip.sh for box inpainting task.

Posterior Sampling using Latent Diffusion

  • sh run/inverse_rip_ldm.sh for random inpainting task.
  • sh run/inverse_bip_ldm.sh for box inpainting task.

Evaluation

Results on Super-resolution

Results on Random and Box Inpainting

Results on Gaussian Deblur

Results on Motion Deblur

Credits

Citation

If you find our work interesting, please consider citing

@inproceedings{
rout2023solving,
title={Solving Linear Inverse Problems Provably via Posterior Sampling with Latent Diffusion Models},
author={Litu Rout and Negin Raoof and Giannis Daras and Constantine Caramanis and Alex Dimakis and Sanjay Shakkottai},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=XKBFdYwfRo}
}

About

Posterior Sampling using Latent Diffusion


Languages

Language:Jupyter Notebook 83.1%Language:Python 16.8%Language:Shell 0.1%Language:Dockerfile 0.0%Language:HTML 0.0%