File size: 2,025 Bytes
6645ad3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d973bd
 
 
 
6645ad3
5d973bd
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
license: apache-2.0
base_model: Tongyi-MAI/Z-Image-Turbo
tags:
- diffusers
- text-to-image
- z-image
library_name: diffusers
pipeline_tag: text-to-image
---

# beyond-reality-z-image-diffusers

This is a converted version of the Beyond Reality Z-Image transformer, converted to diffusers format for use with the `ZImagePipeline`.

## Model Description

This transformer is based on [Beyond Reality Z-Image](https://huggingface.co/Nurburgring/BEYOND_REALITY_Z_IMAGE), converted from ComfyUI format to diffusers format.

## Usage

```python
import torch
from diffusers import ZImagePipeline, ZImageTransformer2DModel

# Load the custom transformer
transformer = ZImageTransformer2DModel.from_pretrained(
    "linoyts/beyond-reality-z-image-diffusers",
    torch_dtype=torch.bfloat16
)

# Load the pipeline with custom transformer
pipe = ZImagePipeline.from_pretrained(
    "Tongyi-MAI/Z-Image-Turbo",
    transformer=transformer,
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")

# Generate an image
prompt = "A beautiful landscape with mountains and a lake, photorealistic, 8k"
image = pipe(
    prompt=prompt,
    num_inference_steps=8,
    guidance_scale=0.0,  # Z-Image-Turbo uses guidance_scale=0
    width=1024,
    height=1024,
).images[0]

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

## Original Model

- **Source**: [Nurburgring/BEYOND_REALITY_Z_IMAGE](https://huggingface.co/Nurburgring/BEYOND_REALITY_Z_IMAGE)
- **Base Architecture**: [Tongyi-MAI/Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo)

## Conversion Details

The model was converted from ComfyUI format to diffusers format with the following key transformations:
- Removed `model.diffusion_model.` prefix from all keys
- Renamed `x_embedder` to `all_x_embedder.2-1`
- Renamed `final_layer` to `all_final_layer.2-1`
- Split `attention.qkv` into `attention.to_q`, `attention.to_k`, `attention.to_v`
- Renamed `attention.out` to `attention.to_out.0`
- Renamed `attention.q_norm` to `attention.norm_q`
- Renamed `attention.k_norm` to `attention.norm_k`