| import torch | |
| from diffsynth.pipelines.z_image_L2P import ZImagePipeline, ModelConfig | |
| main_model_path = "/path/model-1k-merge.safetensors" | |
| text_encoder_paths = [ | |
| "/path/Z-Image-Turbo/text_encoder/model-00001-of-00003.safetensors", | |
| "/path/Z-Image-Turbo/text_encoder/model-00002-of-00003.safetensors", | |
| "/path/Z-Image-Turbo/text_encoder/model-00003-of-00003.safetensors", | |
| ] | |
| tokenizer_path = "/path/Z-Image-Turbo/tokenizer" | |
| pipe = ZImagePipeline.from_pretrained( | |
| torch_dtype=torch.bfloat16, | |
| device="cuda", | |
| model_configs=[ | |
| ModelConfig(path=[main_model_path]), | |
| ModelConfig(path=text_encoder_paths), | |
| ], | |
| tokenizer_config=ModelConfig(path=tokenizer_path), | |
| ) | |
| prompt = "an origami pig on fire in the middle of a dark room with a pentagram on the floor" | |
| image = pipe( | |
| prompt=prompt, | |
| seed=42, | |
| rand_device="cuda", | |
| num_inference_steps=30, | |
| cfg_scale=2.0, | |
| height=1024, | |
| width=1024, | |
| ) | |
| image.save("example.png") | |