Update README.md
Browse files
README.md
CHANGED
|
@@ -1,4 +1,41 @@
|
|
| 1 |
---
|
| 2 |
base_model:
|
| 3 |
- Tongyi-MAI/Z-Image-Turbo
|
| 4 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
base_model:
|
| 3 |
- Tongyi-MAI/Z-Image-Turbo
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Usage
|
| 7 |
+
|
| 8 |
+
```python
|
| 9 |
+
from diffusers import ZImagePipeline, ZImageTransformer2DModel, GGUFQuantizationConfig
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
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."
|
| 13 |
+
height = 1024
|
| 14 |
+
width = 1024
|
| 15 |
+
seed = 42
|
| 16 |
+
|
| 17 |
+
local_path = "path to gguf file you can use shanpshot_dowload to dowload the file"
|
| 18 |
+
|
| 19 |
+
transformer = ZImageTransformer2DModel.from_single_file(
|
| 20 |
+
local_path,
|
| 21 |
+
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
|
| 22 |
+
dtype=torch.bfloat16,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
pipeline = ZImagePipeline.from_pretrained(
|
| 26 |
+
"Tongyi-MAI/Z-Image-Turbo",
|
| 27 |
+
transformer=transformer,
|
| 28 |
+
dtype=torch.bfloat16,
|
| 29 |
+
).to("cuda")
|
| 30 |
+
|
| 31 |
+
images = pipeline(
|
| 32 |
+
prompt=prompt,
|
| 33 |
+
num_inference_steps=9, # This actually results in 8 DiT forwards
|
| 34 |
+
guidance_scale=0.0, # Guidance should be 0 for the Turbo models
|
| 35 |
+
height=height,
|
| 36 |
+
width=width,
|
| 37 |
+
generator=torch.Generator("cuda").manual_seed(seed)
|
| 38 |
+
).images[0]
|
| 39 |
+
|
| 40 |
+
images.save("output.png")
|
| 41 |
+
```
|