Instructions to use mingyi456/Z-Image-Turbo-Art-DF11 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use mingyi456/Z-Image-Turbo-Art-DF11 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("mingyi456/Z-Image-Turbo-Art-DF11", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Diffusion Single File
How to use mingyi456/Z-Image-Turbo-Art-DF11 with Diffusion Single File:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
- DiffusionBee
For more information (including how to compress models yourself), check out https://huggingface.co/DFloat11 and https://github.com/LeanModels/DFloat11
Feel free to request for other models for compression as well (for either the diffusers library, ComfyUI, or any other model), although models that use architectures which are unfamiliar to me might be more difficult.
How to Use
diffusers
import torch
from diffusers import ZImagePipeline, ZImageTransformer2DModel
from dfloat11 import DFloat11Model
from transformers.modeling_utils import no_init_weights
text_encoder = DFloat11Model.from_pretrained("DFloat11/Qwen3-4B-DF11", device="cpu")
with no_init_weights():
transformer = ZImageTransformer2DModel.from_config(
ZImageTransformer2DModel.load_config(
"Tongyi-MAI/Z-Image-Turbo", subfolder="transformer"
),
torch_dtype=torch.bfloat16
).to(torch.bfloat16)
DFloat11Model.from_pretrained("mingyi456/Z-Image-Turbo-Art-DF11", device="cpu", bfloat16_model=transformer)
pipe = ZImagePipeline.from_pretrained(
"Tongyi-MAI/Z-Image-Turbo",
text_encoder=text_encoder,
transformer=transformer,
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=False,
)
pipe.to("cuda")
prompt = "一张肖像照片,展示一位身着传统服饰的年轻亚裔女性站在木质室内空间(可能是寺庙或文化厅)中,她位于画面中央,面带微笑望向镜头,深色长发微微飘动。女子穿着奶油色绣金刺绣上衣,袖子蓬松,外搭一件透明刺绣衣物,左袖有星形图案。腰部系着一条红金相间的几何花纹腰带,右手胸前拿着一个红色鼓身、饰有多彩珠饰的小圆鼓。头上戴着金色叶子皇冠,点缀小珠子,佩戴彩色珠子垂坠耳环。背景左侧是雕刻精美的木质镶板,带有复杂格子设计;右侧是纹理清晰的素色木门。地面为深色木材,阳光投下斜向阴影。无可见文字。肖像摄影,温暖的黄金时刻光线,主体柔焦,浅景深,以奶油色、金色、红色和木色调为主的鲜艳色彩,高对比度,文化遗产主题,精细纺织品纹理,自然光,宁静表情,传统服饰,木质建筑,垂直构图。"
image = pipe(
prompt=prompt,
height=1024,
width=1024,
num_inference_steps=11, # This actually results in 8 DiT forwards
guidance_scale=0.0, # Guidance should be 0 for the Turbo models
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("example.png")
ComfyUI
Refer to this model instead.
Compression details
This is the pattern_dict for compression:
pattern_dict = {
r"noise_refiner\.\d+": (
"attention.to_q",
"attention.to_k",
"attention.to_v",
"attention.to_out.0",
"feed_forward.w1",
"feed_forward.w2",
"feed_forward.w3",
"adaLN_modulation.0"
),
r"context_refiner\.\d+": (
"attention.to_q",
"attention.to_k",
"attention.to_v",
"attention.to_out.0",
"feed_forward.w1",
"feed_forward.w2",
"feed_forward.w3",
),
r"layers\.\d+": (
"attention.to_q",
"attention.to_k",
"attention.to_v",
"attention.to_out.0",
"feed_forward.w1",
"feed_forward.w2",
"feed_forward.w3",
"adaLN_modulation.0"
),
r"cap_embedder": (
"1",
)
}
- Downloads last month
- 19