Update README
Browse files- .gitattributes +4 -0
- README.md +23 -18
- test_outputs/cn_scene_1024x1024.png +2 -2
- test_outputs/en_portrait_1024x1024.png +2 -2
- zimage_quanto_bench_results/images/baseline/landscape_01_seed123.png +3 -0
- zimage_quanto_bench_results/images/baseline/night_01_seed2026.png +2 -2
- zimage_quanto_bench_results/images/baseline/portrait_01_seed46.png +2 -2
- zimage_quanto_bench_results/images/baseline/portrait_02_seed111.png +3 -0
- zimage_quanto_bench_results/images/baseline/scene_01_seed777.png +2 -2
- zimage_quanto_bench_results/images/int8/landscape_01_seed123.png +3 -0
- zimage_quanto_bench_results/images/int8/night_01_seed2026.png +2 -2
- zimage_quanto_bench_results/images/int8/portrait_01_seed46.png +2 -2
- zimage_quanto_bench_results/images/int8/portrait_02_seed111.png +3 -0
- zimage_quanto_bench_results/images/int8/scene_01_seed777.png +2 -2
.gitattributes
CHANGED
|
@@ -44,3 +44,7 @@ zimage_quanto_bench_results/images/int8/portrait_01_seed46.png filter=lfs diff=l
|
|
| 44 |
zimage_quanto_bench_results/images/int8/portrait_02_seed123.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
zimage_quanto_bench_results/images/int8/scene_01_seed777.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
zimage_quanto_bench_results/images/int8/portrait_02_seed123.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
zimage_quanto_bench_results/images/int8/scene_01_seed777.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
zimage_quanto_bench_results/images/baseline/landscape_01_seed123.png filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
zimage_quanto_bench_results/images/baseline/portrait_02_seed111.png filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
zimage_quanto_bench_results/images/int8/landscape_01_seed123.png filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
zimage_quanto_bench_results/images/int8/portrait_02_seed111.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -33,6 +33,12 @@ This repository provides an INT8-quantized variant of [Tongyi-MAI/Z-Image](https
|
|
| 33 |
- **Pipeline**: `diffusers.ZImagePipeline`
|
| 34 |
- **Negative prompt support**: Yes (same pipeline API as the base model)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
## Files
|
| 37 |
|
| 38 |
Key files in this repository:
|
|
@@ -61,14 +67,11 @@ python -m pip install --upgrade pip
|
|
| 61 |
# PyTorch (NVIDIA CUDA, example)
|
| 62 |
pip install torch --index-url https://download.pytorch.org/whl/cu128
|
| 63 |
|
| 64 |
-
# PyTorch (macOS
|
| 65 |
# pip install torch
|
| 66 |
|
| 67 |
# Inference dependencies
|
| 68 |
pip install diffusers transformers accelerate safetensors sentencepiece optimum-quanto pillow
|
| 69 |
-
|
| 70 |
-
# Recommended minimum versions (helps avoid backend compatibility issues)
|
| 71 |
-
pip install -U "torch>=2.4" "diffusers>=0.36.0" "accelerate>=0.33"
|
| 72 |
```
|
| 73 |
|
| 74 |
## Quick Start (Diffusers)
|
|
@@ -77,6 +80,7 @@ This repo already stores quantized weights, so you do **not** need to re-run qua
|
|
| 77 |
|
| 78 |
```python
|
| 79 |
import torch
|
|
|
|
| 80 |
from diffusers import ZImagePipeline
|
| 81 |
|
| 82 |
model_id = "ixim/Z-Image-INT8"
|
|
@@ -89,7 +93,7 @@ elif torch.backends.mps.is_available():
|
|
| 89 |
device = "mps"
|
| 90 |
dtype = torch.float16
|
| 91 |
else:
|
| 92 |
-
#
|
| 93 |
device = "cpu"
|
| 94 |
dtype = torch.float32
|
| 95 |
|
|
@@ -105,7 +109,7 @@ else:
|
|
| 105 |
pipe = pipe.to(device)
|
| 106 |
|
| 107 |
prompt = "A cinematic portrait of a young woman, soft lighting, high detail"
|
| 108 |
-
negative_prompt = "blurry, low quality, distorted face, extra limbs, artifacts"
|
| 109 |
# Use CPU generator for best cross-device compatibility (cpu/mps/cuda)
|
| 110 |
generator = torch.Generator(device="cpu").manual_seed(42)
|
| 111 |
|
|
@@ -125,9 +129,8 @@ print("Saved: zimage_int8_sample.png")
|
|
| 125 |
|
| 126 |
## macOS Notes & Troubleshooting
|
| 127 |
|
| 128 |
-
-
|
| 129 |
-
-
|
| 130 |
-
- `pip install -U "torch>=2.4" "diffusers>=0.36.0" "accelerate>=0.33"`
|
| 131 |
- On Apple Silicon, warnings like `CUDA not available` and `Disabling autocast` are expected in non-CUDA execution paths.
|
| 132 |
- Slow speed on Mac is expected compared with high-end NVIDIA GPUs. To improve speed on Apple Silicon:
|
| 133 |
- Ensure the script uses `mps` (as in the example above), not `cpu`.
|
|
@@ -154,15 +157,15 @@ These two images are generated with this quantized model:
|
|
| 154 |
Test environment:
|
| 155 |
- GPU: NVIDIA GeForce RTX 5090
|
| 156 |
- Framework: PyTorch 2.10.0+cu130
|
| 157 |
-
- Inference setting: 1024×1024,
|
| 158 |
-
- Cases:
|
| 159 |
|
| 160 |
### Aggregate Comparison (Baseline vs INT8)
|
| 161 |
|
| 162 |
| Metric | Baseline | INT8 | Delta |
|
| 163 |
|---|---:|---:|---:|
|
| 164 |
-
| Avg elapsed / image (s) |
|
| 165 |
-
| Avg sec / step |
|
| 166 |
| Avg peak CUDA alloc (GB) | 12.5195 | 7.7470 | **-38.1%** |
|
| 167 |
|
| 168 |
|
|
@@ -172,10 +175,11 @@ Test environment:
|
|
| 172 |
|
| 173 |
| Case | Baseline (s) | INT8 (s) | Speedup |
|
| 174 |
|---|---:|---:|---:|
|
| 175 |
-
| portrait_01 |
|
| 176 |
-
| portrait_02 |
|
| 177 |
-
|
|
| 178 |
-
|
|
|
|
|
| 179 |
|
| 180 |
## Visual Comparison (Baseline vs INT8)
|
| 181 |
|
|
@@ -184,7 +188,8 @@ Left: Baseline. Right: INT8. (Same prompt/seed/steps.)
|
|
| 184 |
| Case | Base | INT8 |
|
| 185 |
|---|---|---|
|
| 186 |
| portrait_01 |  |  |
|
| 187 |
-
| portrait_02 |  |  |
|
| 189 |
| night_01 |  |  |
|
| 190 |
|
|
|
|
| 33 |
- **Pipeline**: `diffusers.ZImagePipeline`
|
| 34 |
- **Negative prompt support**: Yes (same pipeline API as the base model)
|
| 35 |
|
| 36 |
+
## Platform Support
|
| 37 |
+
|
| 38 |
+
- ✅ Supported: Linux/Windows with NVIDIA CUDA
|
| 39 |
+
- ⚠️ Limited support: macOS Apple Silicon (MPS, usually much slower than CUDA)
|
| 40 |
+
- ❌ Not supported: macOS Intel
|
| 41 |
+
|
| 42 |
## Files
|
| 43 |
|
| 44 |
Key files in this repository:
|
|
|
|
| 67 |
# PyTorch (NVIDIA CUDA, example)
|
| 68 |
pip install torch --index-url https://download.pytorch.org/whl/cu128
|
| 69 |
|
| 70 |
+
# PyTorch (macOS Apple Silicon, MPS)
|
| 71 |
# pip install torch
|
| 72 |
|
| 73 |
# Inference dependencies
|
| 74 |
pip install diffusers transformers accelerate safetensors sentencepiece optimum-quanto pillow
|
|
|
|
|
|
|
|
|
|
| 75 |
```
|
| 76 |
|
| 77 |
## Quick Start (Diffusers)
|
|
|
|
| 80 |
|
| 81 |
```python
|
| 82 |
import torch
|
| 83 |
+
|
| 84 |
from diffusers import ZImagePipeline
|
| 85 |
|
| 86 |
model_id = "ixim/Z-Image-INT8"
|
|
|
|
| 93 |
device = "mps"
|
| 94 |
dtype = torch.float16
|
| 95 |
else:
|
| 96 |
+
# CPU fallback (functional but very slow for this model)
|
| 97 |
device = "cpu"
|
| 98 |
dtype = torch.float32
|
| 99 |
|
|
|
|
| 109 |
pipe = pipe.to(device)
|
| 110 |
|
| 111 |
prompt = "A cinematic portrait of a young woman, soft lighting, high detail"
|
| 112 |
+
negative_prompt = "blurry, sad, low quality, distorted face, extra limbs, artifacts"
|
| 113 |
# Use CPU generator for best cross-device compatibility (cpu/mps/cuda)
|
| 114 |
generator = torch.Generator(device="cpu").manual_seed(42)
|
| 115 |
|
|
|
|
| 129 |
|
| 130 |
## macOS Notes & Troubleshooting
|
| 131 |
|
| 132 |
+
- macOS Intel is no longer supported for this model in this repository.
|
| 133 |
+
- If you need macOS inference, use Apple Silicon (`mps`) only.
|
|
|
|
| 134 |
- On Apple Silicon, warnings like `CUDA not available` and `Disabling autocast` are expected in non-CUDA execution paths.
|
| 135 |
- Slow speed on Mac is expected compared with high-end NVIDIA GPUs. To improve speed on Apple Silicon:
|
| 136 |
- Ensure the script uses `mps` (as in the example above), not `cpu`.
|
|
|
|
| 157 |
Test environment:
|
| 158 |
- GPU: NVIDIA GeForce RTX 5090
|
| 159 |
- Framework: PyTorch 2.10.0+cu130
|
| 160 |
+
- Inference setting: 1024×1024, 50 steps, guidance=4.0, CPU offload enabled
|
| 161 |
+
- Cases: 5 prompts (`portrait_01`, `portrait_02`, `landscape_01`, `scene_01`, `night_01`)
|
| 162 |
|
| 163 |
### Aggregate Comparison (Baseline vs INT8)
|
| 164 |
|
| 165 |
| Metric | Baseline | INT8 | Delta |
|
| 166 |
|---|---:|---:|---:|
|
| 167 |
+
| Avg elapsed / image (s) | 49.0282 | 46.7867 | **-4.6%** |
|
| 168 |
+
| Avg sec / step | 0.980564 | 0.935733 | **-4.6%** |
|
| 169 |
| Avg peak CUDA alloc (GB) | 12.5195 | 7.7470 | **-38.1%** |
|
| 170 |
|
| 171 |
|
|
|
|
| 175 |
|
| 176 |
| Case | Baseline (s) | INT8 (s) | Speedup |
|
| 177 |
|---|---:|---:|---:|
|
| 178 |
+
| portrait_01 | 56.9943 | 50.1124 | 1.14x |
|
| 179 |
+
| portrait_02 | 50.3810 | 46.0371 | 1.09x |
|
| 180 |
+
| landscape_01 | 46.0286 | 46.0192 | 1.00x |
|
| 181 |
+
| scene_01 | 45.9097 | 45.8291 | 1.00x |
|
| 182 |
+
| night_01 | 45.8275 | 45.9356 | 1.00x |
|
| 183 |
|
| 184 |
## Visual Comparison (Baseline vs INT8)
|
| 185 |
|
|
|
|
| 188 |
| Case | Base | INT8 |
|
| 189 |
|---|---|---|
|
| 190 |
| portrait_01 |  |  |
|
| 191 |
+
| portrait_02 |  |  |
|
| 192 |
+
| landscape_01 |  |  |
|
| 193 |
| scene_01 |  |  |
|
| 194 |
| night_01 |  |  |
|
| 195 |
|
test_outputs/cn_scene_1024x1024.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
test_outputs/en_portrait_1024x1024.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/baseline/landscape_01_seed123.png
ADDED
|
Git LFS Details
|
zimage_quanto_bench_results/images/baseline/night_01_seed2026.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/baseline/portrait_01_seed46.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/baseline/portrait_02_seed111.png
ADDED
|
Git LFS Details
|
zimage_quanto_bench_results/images/baseline/scene_01_seed777.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/int8/landscape_01_seed123.png
ADDED
|
Git LFS Details
|
zimage_quanto_bench_results/images/int8/night_01_seed2026.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/int8/portrait_01_seed46.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
zimage_quanto_bench_results/images/int8/portrait_02_seed111.png
ADDED
|
Git LFS Details
|
zimage_quanto_bench_results/images/int8/scene_01_seed777.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|