gbcfchc commited on
Commit
35dc66c
·
verified ·
1 Parent(s): e5af2eb

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +92 -0
  2. config.json +21 -0
  3. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: ncslv1
4
+ pipeline_tag: text-to-image
5
+ tags:
6
+ - nvidia
7
+ - pytorch
8
+ language:
9
+ - en
10
+ ---
11
+
12
+ # DC-HT: Tokenizer for DC-AR
13
+
14
+ <div align="left">
15
+ <a href="https://hanlab.mit.edu/projects/dc-ar"><img src="https://img.shields.io/static/v1?label=Website&message=DC-AR&color=darkred&logo=github-pages"></a> &ensp;
16
+ <a href="https://github.com/dc-ai-projects/DC-AR"><img src="https://img.shields.io/static/v1?label=Github&message=DC-AR&color=blue&logo=github"></a> &ensp;
17
+ <a href="https://arxiv.org/abs/2507.04947"><img src="https://img.shields.io/static/v1?label=arXiv&message=DC-AR&color=red&logo=arxiv"></a> &ensp;
18
+ <a href="https://dc-ar.hanlab.ai"><img src="https://img.shields.io/static/v1?label=Demo&message=DC-AR&color=yellow"></a> &ensp;
19
+ </div>
20
+
21
+ ![image/png](https://cdn.prod.website-files.com/64f4e81394e25710d22d042e/686d5d2ed70e97330f4baa25_teaser.png)
22
+
23
+ ## Overview
24
+
25
+ We introduce DC-AR, a novel masked autoregressive (AR) text-to-image generation framework that delivers superior image generation quality with exceptional computational efficiency. Due to the tokenizers' limitations, prior masked AR models have lagged behind diffusion models in terms of quality or efficiency. We overcome this limitation by introducing DC-HT - a deep compression hybrid tokenizer for AR models that achieves a 32× spatial compression ratio while maintaining high reconstruction fidelity and cross-resolution generalization ability. Building upon DC-HT, we extend MaskGIT and create a new hybrid masked autoregressive image generation framework that first produces the structural elements through discrete tokens and then applies refinements via residual tokens. DC-AR achieves state-of-the-art results with a gFID of **5.49** on MJHQ-30K and an overall score of **0.69** on GenEval, while offering **1.5-7.9×** higher throughput and **2.0-3.5×** lower latency compared to prior leading diffusion and autoregressive models.
26
+
27
+ ## Setup
28
+
29
+ Download the github repo and install the environment:
30
+
31
+ ```bash
32
+ git clone https://github.com/mit-han-lab/dc-ar
33
+ cd dc-ar
34
+ conda create -n dcar python=3.10
35
+ conda activate dcar
36
+ pip install -e .
37
+ ```
38
+
39
+ Download DC-HT and DC-AR
40
+
41
+ ```bash
42
+ git clone https://huggingface.co/mit-han-lab/dc-ar-512
43
+ git clone https://huggingface.co/mit-han-lab/dc-ht
44
+ ```
45
+
46
+ Download the safety check model:
47
+
48
+ ```bash
49
+ git clone https://huggingface.co/google/shieldgemma-2b
50
+ ```
51
+
52
+ Note: We use ShieldGemma-2B from Google DeepMind to filter out unsafe prompts in our demo. We strongly recommend using it if you are distributing our demo publicly.
53
+
54
+ ## Usage
55
+
56
+ ### Gradio demo
57
+
58
+ You may launch the Gradio demo using the following script:
59
+
60
+ ```bash
61
+ python app.py --shield_model_path /path/to/ShieldGemma2B
62
+ ```
63
+
64
+ ### Command Line Inference
65
+
66
+ 1. Sampling with single prompt:
67
+
68
+ ```bash
69
+ python sample.py --prompt "YOUR_PROMPT" \
70
+ --sample_folder_dir /path/to/save_dir \
71
+ --shield_model_path /path/to/ShieldGemma2B
72
+ ```
73
+
74
+ 2. Sampling with multiple prompts:
75
+
76
+ ```bash
77
+ # You can add --store_seperately to store each image individually, otherwise images will be stored in one grid.
78
+ python sample.py --prompt_list [Prompt1, Prompt2, ..., PromptN] \
79
+ --sample_folder_dir /path/to/save_dir \
80
+ --shield_model_path /path/to/ShieldGemma2B
81
+ ```
82
+
83
+ ## Citation
84
+
85
+ ```bibtex
86
+ @article{wu2025dcar,
87
+ title={DC-AR: Efficient Masked Autoregressive Image Generation with Deep Compression Hybrid Tokenizer},
88
+ author={Wu, Yecheng and Chen, Junyu and Zhang, Zhuoyang and Xie, Enze and Yu, Jincheng and Chen, Junsong and Hu, Jinyi and Lu, Yao and Han, Song and Cai, Han},
89
+ journal={arXiv preprint arXiv:2410.10733},
90
+ year={2025}
91
+ }
92
+ ```
config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "",
3
+ "architectures": [
4
+ "DCHT"
5
+ ],
6
+ "codebook_embed_dim": 32,
7
+ "codebook_l2_norm": true,
8
+ "codebook_pretrained_path": null,
9
+ "codebook_show_usage": true,
10
+ "codebook_size": 16384,
11
+ "commit_loss_beta": 0.25,
12
+ "disc_updated": true,
13
+ "entropy_loss_ratio": 0.0,
14
+ "model_name": "dc-ae-f32-in-1.0",
15
+ "model_type": "dc_ht",
16
+ "pretrained_path": null,
17
+ "quantizer_type": "hybrid_vq",
18
+ "torch_dtype": "float32",
19
+ "transformers_version": "4.42.2",
20
+ "with_quant_conv": true
21
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1e722338e582f3e9e2b5f574bd5a710bea5211aa0d286450ee010c0d01d84fd
3
+ size 1303603630