Z Image Turbo 安装
要安装 Z Image Turbo,您需要使用最新版本的 diffusers。Z Image Turbo 安装过程需要 Python 3.8+ 和 PyTorch。以下是如何启动并运行 Z Image Turbo:
pip install git+https://github.com/huggingface/diffusersZ Image Turbo 代码示例
安装 Z Image Turbo 后,您可以立即开始生成图像。此 Z Image Turbo 代码示例演示了基本用法模式。Z Image Turbo API 直观且对开发人员友好,使集成无缝。
import torch
from diffusers import ZImagePipeline
# Load Z Image Turbo
pipe = ZImagePipeline.from_pretrained(
"Tongyi-MAI/Z-Image-Turbo",
torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
# Generate with Z Image Turbo
image = pipe(
prompt="Your prompt here",
height=1024,
width=1024,
num_inference_steps=9,
guidance_scale=0.0,
).images[0]Z Image Turbo 要求
在使用 Z Image Turbo 之前,请确保您的系统满足 Z Image Turbo 要求。Z Image Turbo 在启用 CUDA 的 GPU 上效果最佳,但也支持 CPU 推理。为获得最佳 Z Image Turbo 性能,我们建议使用 bfloat16 精度并在可用时启用 Flash Attention。