Awesome
Table of contents
- Overview
- Installation
- Data
- Pretrained weights
- Train
- Evaluation
- Implementation details
- Acknowledgments
- Contacts
Overview
<div align="center"> <img src="assets/dim_arch.png" /> </div>We propose DiMSUM, a hybrid Mamba-Transformer diffusion model that synergistically leverages both spatial and frequency information for high-quality image synthesis. Through extensive experiments on standard benchmarks, our method achieves state-of-the-art results, with a FID of 4.62 on CelebHQ 256, 3.76 on LSUN Church, and 2.11 on ImageNet1k 256. Additionally, our approach attains faster training convergence compared to Zigma and other diffusion methods. In detail, our method outperforms both DiT and SiT while requiring less than a third of the training iterations, achieving the best FID score of 2.11.
Details of the model architecture and experimental results can be found in our following paper:
@inproceedings{phung2024dimsum,
title={DiMSUM: Diffusion Mamba - A Scalable and Unified Spatial-Frequency Method for Image Generation},
author={Hao Phung and Quan Dao and Trung Dao and Hoang Phan and Dimitris Metaxas and Anh Tran},
booktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},
year= {2024},
}
Please CITE our paper and give us a :star: whenever this repository is used to help produce published results or incorporated into other software.
Installation
-
Python 3.10.13
conda create -n dimsum python=3.10.13
-
torch 2.1.1 + cu118
pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu118
-
Requirements:
pip install -r requirements.txt
-
Install
causal_conv1d
andmamba
conda install conda-forge::cudatoolkit-dev
cd causal_conv1d && pip install -e . && cd ..
cd mamba && pip install -e . && cd ..
-
Add python path for DiMSUM:
export PYTHONPATH=$PYTHONPATH:$(pwd)
Data
Training
For CelebA HQ (256) and LSUN, please follow this repo for dataset preparation.
Evaluation
For evaluation, please resize and extract "jpeg" images from dataset first.
For LMDB data (like celeba_256
and lsun_church
), run this command:
python eval_toolbox/resize_lmdb.py --dataset celeba_256 --datadir ./data/celeba_256/celeba-lmdb/ --image_size 256 --save_dir real_samples/
For image folder of jpeg/png images, run this command instead:
python eval_toolbox/resize.py main input_data_dir real_samples/dataname
Pretrained Weights
<!-- We provide pretrained checkpoints of CelebA 256 & LSUN Church for quick testing at [here](https://drive.google.com/drive/folders/1SAE3uSrXv1FNoC92KhFefy24ZSkxjRY5?usp=sharing). --> <table> <tr> <th>Exp</th> <th>#Params</th> <th>FID</th> <th>Checkpoints</th> </tr> <tr> <td> Celeba 256 </td> <td> 460M </td> <td> 4.62 </td> <td><a href="https://drive.google.com/file/d/1FTSBJ7YMQWYa0ydFfdgKfUsPdqKXous9/view?usp=drive_link">celeb256_225ep.pt</a></td> </tr> <tr> <td> Church 256 </td> <td> 460M </td> <td> 3.76 </td> <td><a href="https://drive.google.com/file/d/1I1ghI8H_DPurnaLXDEBzEiDRptveSab1/view?usp=drive_link">church_395ep.pt</a></td> </tr> <tr> <td> ImageNet-1K 256 (CFG) </td> <td> 460M </td> <td> 2.11 </td> <td><a href="https://drive.google.com/file/d/18ZBM3zFD8Va55UZe8S2yUXmXhVzWfFV3/view?usp=drive_link">imnet256_510ep.pt</a></td> </tr> <!-- <tr> <td> Celeba 512 </td> <td> 461M </td> <td> 6.09 </td> <td><a href="">celeb512_165ep.pth</a></td> </tr> --> </table>Train
Comment/Uncomment command lines for desired dataset, then run:
bash scripts/train.sh
Evaluation
To sampe images from pretrained checkpoints, run:
bash scripts/sample.sh
To evaluate, select a relevant command and run:
bash scripts/eval.sh
Implementation details
- DiMSUM architecture is put in dimsum/models_dim.py.
- Conditional Mamba can be found in mamba/mamba_ssm/ops/selective_scan_interface.py and causal-conv1d/csrc/causal_conv1d.cpp.
- Frequency transformations: dimsum/wavelet_layer.py and dimsum/dct_layer.py.
- Mamba Scanning strategies (e.g. sweep8, jpeg8): dimsum/scanning_orders.py.
Acknowledgments
This project is based on Vim, LFM, SiT, DiT, ZigMa. Thanks for publishing their wonderful works with codes.
Contacts
If you have any problems, please open an issue in this repository or ping an email to tienhaophung@gmail.com and kevinquandao10@gmail.com.