Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div align="center">
|
| 2 |
+
|
| 3 |
+
<h1>MGVQ: Could VQ-VAE Beat VAE? A Generalizable Tokenizer with Multi-group Quantization</h1>
|
| 4 |
+
|
| 5 |
+
[](https://arxiv.org/abs/2507.07997)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
[Mingkai Jia](https://scholar.google.com/citations?user=fcpTdvcAAAAJ&hl=zh-CN)<sup>1,2</sup>, [Wei Yin](https://yvanyin.net/)<sup>2*§</sup>, [Xiaotao Hu](https://huxiaotaostasy.github.io/)<sup>1,2</sup>, [Jiaxin Guo](https://wrld.github.io/)<sup>3</sup>, [Xiaoyang Guo](https://xy-guo.github.io/)<sup>2</sup><br>
|
| 9 |
+
[Qian Zhang](https://scholar.google.com.hk/citations?hl=zh-CN&user=pCY-bikAAAAJ)<sup>2</sup>, [Xiao-Xiao Long](https://www.xxlong.site/)<sup>4</sup>, [Ping Tan](https://scholar.google.com/citations?user=XhyKVFMAAAAJ&hl=en)<sup>1</sup><br>
|
| 10 |
+
|
| 11 |
+
[HKUST](https://hkust.edu.hk/)<sup>1</sup>, [Horizon Robotics](https://en.horizon.auto/)<sup>2</sup>, [CUHK](https://cuhk.edu.hk/)<sup>3</sup>, [NJU](https://www.nju.edu.cn/)<sup>4</sup><br>
|
| 12 |
+
<sup>*</sup> Corresponding Author, <sup>§</sup> Project Leader
|
| 13 |
+
<br><br><image src="./assets/teaser.png"/>
|
| 14 |
+
</div>
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
## 🚀News
|
| 18 |
+
- ```[August 2025]``` Achieve SOTA at paperwithcode leaderboards: Image Reconstruction on ImageNet and UHDBench. <image src="./assets/SOTA_recon_fid_imagenet_badge.jpg"/> <image src="./assets/SOTA_recon_PSNR_UHD_badge.jpg"/>
|
| 19 |
+
- ```[August 2025]``` Released Inference Code
|
| 20 |
+
- ```[August 2025]``` Released [model zoo](https://huggingface.co/mkjia/MGVQ/tree/main).
|
| 21 |
+
- ```[August 2025]``` Released dataset for ultra-high-definition image reconstruction evaluation. Our proposed super-resolution image reconstruction [UHDBench dataset](https://huggingface.co/datasets/mkjia/UHDBench/tree/main) is released.
|
| 22 |
+
- ```[July 2025]``` Released [paper](https://arxiv.org/abs/2507.07997).
|
| 23 |
+
|
| 24 |
+
## 🔨TO DO LIST
|
| 25 |
+
- [ ] Training code.
|
| 26 |
+
- [ ] More demos.
|
| 27 |
+
- [x] Models & Evaluation code.
|
| 28 |
+
- [x] Huggingface models.
|
| 29 |
+
- [x] Release zero-shot reconstruction benchmarks.
|
| 30 |
+
|
| 31 |
+
## 🙈 Model Zoo
|
| 32 |
+
| Model | Downsample | Groups | Codebook Size | Training Data | Link |
|
| 33 |
+
|---|---|---|---|---|---|
|
| 34 |
+
|mgvq-f8c32-g4|8|4|32768|imagenet| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f8c32_g4.pt) |
|
| 35 |
+
|mgvq-f8c32-g8|8|8|16384|imagenet| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f8c32_g8.pt) |
|
| 36 |
+
|mgvq-f16c32-g4|16|4|32768|imagenet| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f16c32_g4.pt) |
|
| 37 |
+
|mgvq-f16c32-g8|16|8|16384|imagenet| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f16c32_g8.pt) |
|
| 38 |
+
|mgvq-f16c32-g4-mix|16|4|32768|mix| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f16c32_g4_mix.pt) |
|
| 39 |
+
|mgvq-f32c32-g8-mix|32|8|16384|mix| [link](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f32c32_g8_mix.pt) |
|
| 40 |
+
|
| 41 |
+
## 🔑 Quick Start
|
| 42 |
+
<a id="quick start"></a>
|
| 43 |
+
|
| 44 |
+
### Installation
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
git clone https://github.com/MKJia/MGVQ.git
|
| 48 |
+
cd MGVQ
|
| 49 |
+
pip3 install requirements.txt
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Download models
|
| 53 |
+
Download the pretrained models from our [model zoo](https://huggingface.co/mkjia/MGVQ/tree/main) to your `/path/to/your/ckpt`.
|
| 54 |
+
|
| 55 |
+
### Data Preparation
|
| 56 |
+
Try our UHDBench dataset on [huggingface](https://huggingface.co/datasets/mkjia/UHDBench/tree/main) and download to your `/path/to/your/dataset`.
|
| 57 |
+
|
| 58 |
+
### Evaluation on Reconstruction
|
| 59 |
+
Remember to change the paths of `ckpt` and `dataset_root`, and make sure you are evaluating the expected `model` on `dataset`.
|
| 60 |
+
```bash
|
| 61 |
+
cd evaluation
|
| 62 |
+
python3 eval_recon.sh
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### Generation Demo&Evaluation
|
| 66 |
+
You can download the pretrained GPT model for generation on [huggingface](https://huggingface.co/datasets/mkjia/MGVQ/blob/main/MGVQ_GPT_XXL.pt), and test it with our `mgvq-f16c32-g4` [tokenizer model](https://huggingface.co/mkjia/MGVQ/blob/main/mgvq_f16c32_g4.pt) for demo image sampling. Remember to change the paths of `gpt_ckpt` and `vq_ckpt`.
|
| 67 |
+
```
|
| 68 |
+
cd evaluation
|
| 69 |
+
python3 demo_gen.sh
|
| 70 |
+
```
|
| 71 |
+
We also provide our .npz file on [huggingface](https://huggingface.co/datasets/mkjia/MGVQ/blob/main/GPT_XXL_300ep_topk_12.npz) sampled by `sample_c2i_ddp.py` for evaluation.
|
| 72 |
+
```
|
| 73 |
+
cd evaluation
|
| 74 |
+
python3 evaluator.py /path/to/your/VIRTUAL_imagenet256_labeled.npz /path/to/your/GPT_XXL_300ep_topk_12.npz
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
## 🗄️Demos
|
| 79 |
+
- 🔥 Qualitative reconstruction images with $16$ x downsampling on $2560$ x $1440$ UHDBench dataset.
|
| 80 |
+
|
| 81 |
+
<image src="./assets/qual_recon.png"/>
|
| 82 |
+
|
| 83 |
+
- 🔥 Qualitative class-to-image generation of Imagenet. The classes are dog(Golden Retriever and Husky), cliff, and bald eagle.
|
| 84 |
+
|
| 85 |
+
<image src="./assets/qual_gen.png"/>
|
| 86 |
+
|
| 87 |
+
- 🔥 Reconstruction evaluation on 256×256 ImageNet benchmark.
|
| 88 |
+
|
| 89 |
+
<image src="./assets/recon_tab_1.jpg"/>
|
| 90 |
+
|
| 91 |
+
- 🔥 Zero-shot reconstruction evaluation with a downsample ratio of 16 on 512×512 datasets.
|
| 92 |
+
|
| 93 |
+
<image src="./assets/recon_tab_2.jpg"/>
|
| 94 |
+
|
| 95 |
+
- 🔥 Zero-shot reconstruction evaluation with a downsample ratio of 16 on 2560×1440 datasets.
|
| 96 |
+
|
| 97 |
+
<div align="center"><image src="./assets/recon_tab_3.jpg"/></image></div>
|
| 98 |
+
|
| 99 |
+
## 🗄️Demos
|
| 100 |
+
|
| 101 |
+
## 📌 Citation
|
| 102 |
+
|
| 103 |
+
If the paper and code from `MGVQ` help your research, we kindly ask you to give a citation to our paper ❤️. Additionally, if you appreciate our work and find this repository useful, giving it a star ⭐️ would be a wonderful way to support our work. Thank you very much.
|
| 104 |
+
|
| 105 |
+
```bibtex
|
| 106 |
+
@article{jia2025mgvq,
|
| 107 |
+
title={MGVQ: Could VQ-VAE Beat VAE? A Generalizable Tokenizer with Multi-group Quantization},
|
| 108 |
+
author={Jia, Mingkai and Yin, Wei and Hu, Xiaotao and Guo, Jiaxin and Guo, Xiaoyang and Zhang, Qian and Long, Xiao-Xiao and Tan, Ping},
|
| 109 |
+
journal={arXiv preprint arXiv:2507.07997},
|
| 110 |
+
year={2025}
|
| 111 |
+
}
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
## License
|
| 115 |
+
|
| 116 |
+
This repository is under the MIT License. For more license questions, please contact Mingkai Jia (mjiaab@connect.ust.hk) and Wei Yin (yvanwy@outlook.com).
|
| 117 |
+
|