README.md
15.3 KB · 239 lines · markdown Raw
1 ---
2 base_model: Tongyi-MAI/Z-Image-Turbo
3 license: apache-2.0
4 language:
5 - en
6 pipeline_tag: text-to-image
7 library_name: ggml
8 tags:
9 - gguf
10 - quantized
11 - unsloth
12 widget:
13 - text: cute sloth in starry night style
14 output:
15 url: assets/sloth_gogh.png
16 ---
17
18 > [!NOTE]
19 > This is a GGUF quantized version of [Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo).
20 > unsloth/Z-Image-Turbo-GGUF uses [Unsloth Dynamic 2.0](https://docs.unsloth.ai/basics/unsloth-dynamic-2.0-ggufs) methodology for SOTA performance. Important layers are upcasted to higher precision.
21
22
23 <div>
24 <div style="display: flex; gap: 5px; align-items: center; ">
25 <a href="https://github.com/unslothai/unsloth/">
26 <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
27 </a>
28 <a href="https://discord.gg/unsloth">
29 <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
30 </a>
31 <a href="https://docs.unsloth.ai/basics/unsloth-dynamic-2.0-ggufs">
32 <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
33 </a>
34 </div>
35 </div>
36
37 ### Samples
38
39 <table>
40 <tr>
41 <td><img src="assets/sloth_gogh.png" width="200"></td>
42 <td><img src="assets/sloth_mall.png" width="200"></td>
43 </tr>
44 <tr>
45 <td><img src="assets/sloth_sign.png" width="200"></td>
46 <td><img src="assets/sloth_wes.png" width="200"></td>
47 </tr>
48 </table>
49
50
51 ---
52 <h1 align="center">⚡️- Image<br><sub><sup>An Efficient Image Generation Foundation Model with Single-Stream Diffusion Transformer</sup></sub></h1>
53
54 <div align="center">
55
56 [![Official Site](https://img.shields.io/badge/Official%20Site-333399.svg?logo=homepage)](https://tongyi-mai.github.io/Z-Image-blog/)&#160;
57 [![GitHub](https://img.shields.io/badge/GitHub-Z--Image-181717?logo=github&logoColor=white)](https://github.com/Tongyi-MAI/Z-Image)&#160;
58 [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Checkpoint-Z--Image--Turbo-yellow)](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo)&#160;
59 [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Online_Demo-Z--Image--Turbo-blue)](https://huggingface.co/spaces/Tongyi-MAI/Z-Image-Turbo)&#160;
60 [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Mobile_Demo-Z--Image--Turbo-red)](https://huggingface.co/spaces/akhaliq/Z-Image-Turbo)&#160;
61 [![ModelScope Model](https://img.shields.io/badge/🤖%20Checkpoint-Z--Image--Turbo-624aff)](https://www.modelscope.cn/models/Tongyi-MAI/Z-Image-Turbo)&#160;
62 [![ModelScope Space](https://img.shields.io/badge/🤖%20Online_Demo-Z--Image--Turbo-17c7a7)](https://www.modelscope.cn/aigc/imageGeneration?tab=advanced&versionId=469191&modelType=Checkpoint&sdVersion=Z_IMAGE_TURBO&modelUrl=modelscope%253A%252F%252FTongyi-MAI%252FZ-Image-Turbo%253Frevision%253Dmaster%7D%7BOnline)&#160;
63 [![Art Gallery PDF](https://img.shields.io/badge/%F0%9F%96%BC%20Art_Gallery-PDF-ff69b4)](assets/Z-Image-Gallery.pdf)&#160;
64 [![Web Art Gallery](https://img.shields.io/badge/%F0%9F%8C%90%20Web_Art_Gallery-online-00bfff)](https://modelscope.cn/studios/Tongyi-MAI/Z-Image-Gallery/summary)&#160;
65 <a href="https://arxiv.org/abs/2511.22699" target="_blank"><img src="https://img.shields.io/badge/Report-b5212f.svg?logo=arxiv" height="21px"></a>
66
67
68 Welcome to the official repository for the Z-Image(造相)project!
69
70 </div>
71
72
73
74 ## ✨ Z-Image
75
76 Z-Image is a powerful and highly efficient image generation model with **6B** parameters. Currently there are three variants:
77
78 - 🚀 **Z-Image-Turbo** – A distilled version of Z-Image that matches or exceeds leading competitors with only **8 NFEs** (Number of Function Evaluations). It offers **⚡️sub-second inference latency⚡️** on enterprise-grade H800 GPUs and fits comfortably within **16G VRAM consumer devices**. It excels in photorealistic image generation, bilingual text rendering (English & Chinese), and robust instruction adherence.
79
80 - 🧱 **Z-Image-Base** – The non-distilled foundation model. By releasing this checkpoint, we aim to unlock the full potential for community-driven fine-tuning and custom development.
81
82 - ✍️ **Z-Image-Edit** – A variant fine-tuned on Z-Image specifically for image editing tasks. It supports creative image-to-image generation with impressive instruction-following capabilities, allowing for precise edits based on natural language prompts.
83
84 ### 📥 Model Zoo
85
86 | Model | Hugging Face | ModelScope |
87 | :--- |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
88 | **Z-Image-Turbo** | [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Checkpoint%20-Z--Image--Turbo-yellow)](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo) <br> [![Hugging Face Space](https://img.shields.io/badge/%F0%9F%A4%97%20Online%20Demo-Z--Image--Turbo-blue)](https://huggingface.co/spaces/Tongyi-MAI/Z-Image-Turbo) | [![ModelScope Model](https://img.shields.io/badge/🤖%20%20Checkpoint-Z--Image--Turbo-624aff)](https://www.modelscope.cn/models/Tongyi-MAI/Z-Image-Turbo) <br> [![ModelScope Space](https://img.shields.io/badge/%F0%9F%A4%96%20Online%20Demo-Z--Image--Turbo-17c7a7)](https://www.modelscope.cn/aigc/imageGeneration?tab=advanced&versionId=469191&modelType=Checkpoint&sdVersion=Z_IMAGE_TURBO&modelUrl=modelscope%3A%2F%2FTongyi-MAI%2FZ-Image-Turbo%3Frevision%3Dmaster) |
89 | **Z-Image-Base** | *To be released* | *To be released* |
90 | **Z-Image-Edit** | *To be released* | *To be released* |
91
92 ### 🖼️ Showcase
93
94 📸 **Photorealistic Quality**: **Z-Image-Turbo** delivers strong photorealistic image generation while maintaining excellent aesthetic quality.
95
96 ![Showcase of Z-Image on Photo-realistic image Generation](assets/showcase_realistic.png)
97
98 📖 **Accurate Bilingual Text Rendering**: **Z-Image-Turbo** excels at accurately rendering complex Chinese and English text.
99
100 ![Showcase of Z-Image on Bilingual Text Rendering](assets/showcase_rendering.png)
101
102 💡 **Prompt Enhancing & Reasoning**: Prompt Enhancer empowers the model with reasoning capabilities, enabling it to transcend surface-level descriptions and tap into underlying world knowledge.
103
104 ![reasoning.jpg](assets/reasoning.png)
105
106 🧠 **Creative Image Editing**: **Z-Image-Edit** shows a strong understanding of bilingual editing instructions, enabling imaginative and flexible image transformations.
107
108 ![Showcase of Z-Image-Edit on Image Editing](assets/showcase_editing.png)
109
110 ### 🏗️ Model Architecture
111 We adopt a **Scalable Single-Stream DiT** (S3-DiT) architecture. In this setup, text, visual semantic tokens, and image VAE tokens are concatenated at the sequence level to serve as a unified input stream, maximizing parameter efficiency compared to dual-stream approaches.
112
113 ![Architecture of Z-Image and Z-Image-Edit](assets/architecture.webp)
114
115 ### 📈 Performance
116 According to the Elo-based Human Preference Evaluation (on [*Alibaba AI Arena*](https://aiarena.alibaba-inc.com/corpora/arena/leaderboard?arenaType=T2I)), Z-Image-Turbo shows highly competitive performance against other leading models, while achieving state-of-the-art results among open-source models.
117
118 <p align="center">
119 <a href="https://aiarena.alibaba-inc.com/corpora/arena/leaderboard?arenaType=T2I">
120 <img src="assets/leaderboard.png" alt="Z-Image Elo Rating on AI Arena"/><br />
121 <span style="font-size:1.05em; cursor:pointer; text-decoration:underline;"> Click to view the full leaderboard</span>
122 </a>
123 </p>
124
125 ### 🚀 Quick Start
126 Install the latest version of diffusers, use the following command:
127 <details>
128 <summary><sup>Click here for details for why you need to install diffusers from source</sup></summary>
129
130 We have submitted two pull requests ([#12703](https://github.com/huggingface/diffusers/pull/12703) and [#12715](https://github.com/huggingface/diffusers/pull/12715)) to the 🤗 diffusers repository to add support for Z-Image. Both PRs have been merged into the latest official diffusers release.
131 Therefore, you need to install diffusers from source for the latest features and Z-Image support.
132
133 </details>
134
135 ```bash
136 pip install git+https://github.com/huggingface/diffusers
137 ```
138
139 ```python
140 import torch
141 from diffusers import ZImagePipeline
142
143 # 1. Load the pipeline
144 # Use bfloat16 for optimal performance on supported GPUs
145 pipe = ZImagePipeline.from_pretrained(
146 "Tongyi-MAI/Z-Image-Turbo",
147 torch_dtype=torch.bfloat16,
148 low_cpu_mem_usage=False,
149 )
150 pipe.to("cuda")
151
152 # [Optional] Attention Backend
153 # Diffusers uses SDPA by default. Switch to Flash Attention for better efficiency if supported:
154 # pipe.transformer.set_attention_backend("flash") # Enable Flash-Attention-2
155 # pipe.transformer.set_attention_backend("_flash_3") # Enable Flash-Attention-3
156
157 # [Optional] Model Compilation
158 # Compiling the DiT model accelerates inference, but the first run will take longer to compile.
159 # pipe.transformer.compile()
160
161 # [Optional] CPU Offloading
162 # Enable CPU offloading for memory-constrained devices.
163 # pipe.enable_model_cpu_offload()
164
165 prompt = "Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Neon lightning-bolt lamp (⚡️), bright yellow glow, above extended left palm. Soft-lit outdoor night background, silhouetted tiered pagoda (西安大雁塔), blurred colorful distant lights."
166
167 # 2. Generate Image
168 image = pipe(
169 prompt=prompt,
170 height=1024,
171 width=1024,
172 num_inference_steps=9, # This actually results in 8 DiT forwards
173 guidance_scale=0.0, # Guidance should be 0 for the Turbo models
174 generator=torch.Generator("cuda").manual_seed(42),
175 ).images[0]
176
177 image.save("example.png")
178 ```
179
180 ## 🔬 Decoupled-DMD: The Acceleration Magic Behind Z-Image
181
182 [![arXiv](https://img.shields.io/badge/arXiv-2511.22677-b31b1b.svg)](https://arxiv.org/abs/2511.22677)
183
184 Decoupled-DMD is the core few-step distillation algorithm that empowers the 8-step Z-Image model.
185
186 Our core insight in Decoupled-DMD is that the success of existing DMD (Distributaion Matching Distillation) methods is the result of two independent, collaborating mechanisms:
187
188 - **CFG Augmentation (CA)**: The primary **engine** 🚀 driving the distillation process, a factor largely overlooked in previous work.
189 - **Distribution Matching (DM)**: Acts more as a **regularizer** ⚖️, ensuring the stability and quality of the generated output.
190
191 By recognizing and decoupling these two mechanisms, we were able to study and optimize them in isolation. This ultimately motivated us to develop an improved distillation process that significantly enhances the performance of few-step generation.
192
193 ![Diagram of Decoupled-DMD](assets/decoupled-dmd.webp)
194
195 ## 🤖 DMDR: Fusing DMD with Reinforcement Learning
196
197 [![arXiv](https://img.shields.io/badge/arXiv-2511.13649-b31b1b.svg)](https://arxiv.org/abs/2511.13649)
198
199 Building upon the strong foundation of Decoupled-DMD, our 8-step Z-Image model has already demonstrated exceptional capabilities. To achieve further improvements in terms of semantic alignment, aesthetic quality, and structural coherence—while producing images with richer high-frequency details—we present **DMDR**.
200
201 Our core insight behind DMDR is that Reinforcement Learning (RL) and Distribution Matching Distillation (DMD) can be synergistically integrated during the post-training of few-step models. We demonstrate that:
202
203 - **RL Unlocks the Performance of DMD** 🚀
204 - **DMD Effectively Regularizes RL** ⚖️
205
206 ![Diagram of DMDR](assets/DMDR.webp)
207
208 ## ⏬ Download
209 ```bash
210 pip install -U huggingface_hub
211 HF_XET_HIGH_PERFORMANCE=1 hf download Tongyi-MAI/Z-Image-Turbo
212 ```
213
214 ## 📜 Citation
215
216 If you find our work useful in your research, please consider citing:
217
218 ```bibtex
219 @article{team2025zimage,
220 title={Z-Image: An Efficient Image Generation Foundation Model with Single-Stream Diffusion Transformer},
221 author={Z-Image Team},
222 journal={arXiv preprint arXiv:2511.22699},
223 year={2025}
224 }
225
226 @article{liu2025decoupled,
227 title={Decoupled DMD: CFG Augmentation as the Spear, Distribution Matching as the Shield},
228 author={Dongyang Liu and Peng Gao and David Liu and Ruoyi Du and Zhen Li and Qilong Wu and Xin Jin and Sihan Cao and Shifeng Zhang and Hongsheng Li and Steven Hoi},
229 journal={arXiv preprint arXiv:2511.22677},
230 year={2025}
231 }
232
233 @article{jiang2025distribution,
234 title={Distribution Matching Distillation Meets Reinforcement Learning},
235 author={Jiang, Dengyang and Liu, Dongyang and Wang, Zanyi and Wu, Qilong and Jin, Xin and Liu, David and Li, Zhen and Wang, Mengmeng and Gao, Peng and Yang, Harry},
236 journal={arXiv preprint arXiv:2511.13649},
237 year={2025}
238 }
239 ```