Text-to-Image
Diffusers
OpenVINO
ZImagePipeline
int4
optimum
optimum-intel
nncf
z-image
transformer
cpu
Instructions to use HelloSun/Z-Image-Turbo-OpenVINO-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use HelloSun/Z-Image-Turbo-OpenVINO-INT4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("HelloSun/Z-Image-Turbo-OpenVINO-INT4", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download inference_int4.py from HelloSun/Z-Image-Turbo-OpenVINO-INT4: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/HelloSun/Z-Image-Turbo-OpenVINO-INT4/resolve/main/inference_int4.py
- Command line
-
hf download hf://HelloSun/Z-Image-Turbo-OpenVINO-INT4/inference_int4.py
-
curl -L -o inference_int4.py https://huggingface.co/HelloSun/Z-Image-Turbo-OpenVINO-INT4/resolve/main/inference_int4.py
1.11 kB
| """Z-Image-Turbo OpenVINO INT4 inference example (optimum-intel). | |
| Requires: diffusers==0.37.1, transformers==4.57.6, optimum-intel, openvino, nncf | |
| Export: optimum-cli export openvino -m Tongyi-MAI/Z-Image-Turbo --task text-to-image --weight-format fp16 ./fp16 | |
| Quantize: see quantize_int4.py (OVWeightQuantizationConfig bits=4, group 128, fallback adjust) | |
| """ | |
| import time | |
| import torch | |
| from optimum.intel import OVDiffusionPipeline | |
| MODEL_ID = "HelloSun/Z-Image-Turbo-OpenVINO-INT4" # or local path ./z-image-turbo-ov-int4 | |
| def main(): | |
| pipe = OVDiffusionPipeline.from_pretrained(MODEL_ID, compile=True) | |
| prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" | |
| # Turbo: num_inference_steps=9 => 8 DiT forwards (official README), guidance_scale=0.0 | |
| image = pipe( | |
| prompt=prompt, | |
| height=1024, width=1024, | |
| num_inference_steps=9, | |
| guidance_scale=0.0, | |
| generator=torch.Generator().manual_seed(42), | |
| ).images[0] | |
| image.save("z_image_turbo_ov_int4.png") | |
| print("saved z_image_turbo_ov_int4.png") | |
| if __name__ == "__main__": | |
| main() | |