This is a int8-wo pre-quantized version of Tongyi-MAI/Z-Image-Turbo.
How to use
Install the latest version of diffusers, transformers, torchao and accelerate:
pip install -U diffusers transformers torchao accelerate
The following contains a code snippet illustrating how to use the model to generate images based on text prompts:
import torch
from diffusers import ZImagePipeline
from diffusers.models.transformers.transformer_z_image import ZImageTransformer2DModel
# 1. Load the pipeline
# Use bfloat16 for optimal performance on supported GPUs
transformer = ZImageTransformer2DModel.from_pretrained(
"dimitribarbot/Z-Image-Turbo-int8wo",
torch_dtype=torch.bfloat16,
use_safetensors=False
)
pipe = DiffusionPipeline.from_pretrained(
"Tongyi-MAI/Z-Image-Turbo",
transformer=transformer,
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=False,
)
pipe.to("cuda")
# [Optional] CPU Offloading
# Enable CPU offloading for memory-constrained devices.
# pipe.enable_model_cpu_offload()
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."
# 2. Generate Image
image = pipe(
prompt=prompt,
height=1024,
width=1024,
num_inference_steps=9, # 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_torchao.png")
- Downloads last month
- 23
Model tree for dimitribarbot/Z-Image-Turbo-int8wo
Base model
Tongyi-MAI/Z-Image-Turbo