Views
No views yet
pip install diffsynthImportant: Add, pxlstlsuffix to your prompt for best pixel art style results.
1import torch
2import glob
3from diffsynth.pipelines.z_image import ZImagePipeline, ModelConfig
4
5MODEL_ID = "Tongyi-MAI/Z-Image-Turbo"
6STYLE_SUFFIX = ", pxlstl"
7
8# Load pipeline
9pipe = ZImagePipeline.from_pretrained(
10 torch_dtype=torch.bfloat16,
11 device="cuda",
12 model_configs=[
13 ModelConfig(model_id=MODEL_ID, origin_file_pattern="transformer/*.safetensors"),
14 ModelConfig(model_id=MODEL_ID, origin_file_pattern="text_encoder/*.safetensors"),
15 ModelConfig(model_id=MODEL_ID, origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
16 ],
17 tokenizer_config=ModelConfig(model_id=MODEL_ID, origin_file_pattern="tokenizer/"),
18)
19
20# Load LoRA
21from huggingface_hub import hf_hub_download
22lora_path = hf_hub_download(repo_id="mks0813/z-image-turbo-pixel-art-lora", filename="z-image-turbo-pixel-art-lora.safetensors")
23pipe.load_lora(pipe.dit, lora_path)
24
25# Generate image
26prompt = "A cute pixel art cat" + STYLE_SUFFIX
27image = pipe(prompt=prompt, seed=42, rand_device="cuda")
28image.save("output.png")| Image | Prompt |
|---|---|
![]() | A cat is driving a car in the city |
![]() | A cozy café on a rainy Paris street at night |
![]() | A dancer spinning on a rooftop under city lights |
![]() | A fox sleeping in a sunlit autumn forest |
![]() | A iconic white-sand beach lined with high-rise hotels and swaying palm trees |
![]() | A landscape of a meadow with sheep wandering at sunset |
![]() | A lighthouse standing against crashing waves under a stormy sky |
![]() | A lion is sleeping under the tree |
![]() | A lone astronaut walking on a crystal desert planet |