# Z-Image

> Alibaba Tongyi's 6B open image model that renders photoreal pictures on one consumer GPU

- Category: Multimodal Generation / Image Generation
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/Tongyi-MAI/Z-Image
- Website: https://huggingface.co/Tongyi-MAI/Z-Image-Turbo
- Canonical page: https://ai-tldr.dev/tools/z-image/

## In short

Z-Image is an open-source text-to-image model family from Alibaba's Tongyi lab, built on a single-stream diffusion transformer (S3-DiT). At 6 billion parameters, it is small enough to run on a single GPU while still producing photorealistic images and rendering both English and Chinese text in the picture. It sits in the Image Generation category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Z-Image is an open-source text-to-image model family from Alibaba's Tongyi lab, built on a single-stream diffusion transformer (S3-DiT). At 6 billion parameters, it is small enough to run on a single GPU while still producing photorealistic images and rendering both English and Chinese text in the picture.

The family has several variants. Z-Image-Turbo is a distilled version that generates an image in only 8 sampling steps (8 NFEs) and fits within 16GB of VRAM, so it works on many consumer cards. The base Z-Image model focuses on higher-quality and more diverse output and is meant for fine-tuning, while Z-Image-Edit and the Omni-Base checkpoint target image editing.

It sits in the image-generation space alongside other open diffusion models, and is aimed at developers who want a self-hostable model they can run locally, integrate into a pipeline, or fine-tune for their own use rather than calling a hosted API.

## What it does

- 6B-parameter single-stream diffusion transformer (S3-DiT) that runs on one GPU
- Z-Image-Turbo generates images in 8 steps (8 NFEs) and fits in 16GB VRAM
- Photorealistic image generation with strong aesthetic quality
- Bilingual text rendering for English and Chinese inside images
- Multiple variants: a base model for fine-tuning, plus Turbo, Edit, and Omni-Base checkpoints
- Works through the diffusers library via a ZImagePipeline

## Getting started

Z-Image runs through Hugging Face diffusers. Install diffusers from source (Z-Image support landed recently), then load the Turbo checkpoint and generate an image.

1. Install diffusers from source

   Z-Image support is in the latest diffusers, so install it directly from the GitHub main branch.

```bash
pip install git+https://github.com/huggingface/diffusers
```

2. Generate an image with Z-Image-Turbo

   Load the ZImagePipeline, move it to CUDA, and run a prompt. Turbo uses few steps and guidance_scale 0.0.

```python
import torch
from diffusers import ZImagePipeline

pipe = ZImagePipeline.from_pretrained(
    "Tongyi-MAI/Z-Image-Turbo",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=False,
)
pipe.to("cuda")

image = pipe(
    prompt="Young Chinese woman in red Hanfu, intricate embroidery",
    height=1024,
    width=1024,
    num_inference_steps=9,
    guidance_scale=0.0,
    generator=torch.Generator("cuda").manual_seed(42),
).images[0]

image.save("example.png")
```

3. Or install the repo for native inference

   To run the repo's own PyTorch inference code, clone Z-Image and install it in editable mode inside your virtual environment.

```bash
git clone https://github.com/Tongyi-MAI/Z-Image.git
cd Z-Image
pip install -e .
```

## When to use it

- Generate photorealistic images locally on a single 16GB consumer GPU instead of calling a paid hosted API
- Create graphics that need correct English or Chinese text rendered inside the image
- Fine-tune the base Z-Image model on your own dataset for a custom style or domain
- Add text-to-image generation to an app or pipeline through the diffusers ZImagePipeline
