Skip to content

Conversation

@CalamitousFelicitousness
Copy link

@CalamitousFelicitousness CalamitousFelicitousness commented Nov 29, 2025

What does this PR do?

Adds support for LoRA for ZImagePipeline and adds a conversion script into Diffusers format. Resolves issue #12745

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@sayakpaul

@CalamitousFelicitousness
Copy link
Author

Tested using a simple script.

Testing script
#!/usr/bin/env python
"""Test script for ZImage LoRA support."""

import sys
sys.path.insert(0, '/home/ohiom/diffusers/src')

import torch
from diffusers import ZImagePipeline

# Paths
MODEL_PATH = "database/models/huggingface/models--Tongyi-MAI--Z-Image-Turbo/snapshots/78771b7e11b922c868dd766476bda1f4fc6bfc96"
LORA_PATH = "TechnicallyColorZ_V1.safetensors"

print("Loading ZImagePipeline...")
pipe = ZImagePipeline.from_pretrained(
    MODEL_PATH,
    torch_dtype=torch.bfloat16,
    local_files_only=True,
)
pipe.to("cuda")

print(f"Pipeline loaded. Has load_lora_weights: {hasattr(pipe, 'load_lora_weights')}")

print(f"\nLoading LoRA from {LORA_PATH}...")
pipe.load_lora_weights(LORA_PATH)
print("LoRA loaded successfully!")

# Generate an image
prompt = "t3chnic4lly vibrant 1960s close-up of a woman sitting under a tree in a blue skit and white blouse, she has blonde wavy short hair and a smile with green eyes lake scene by a garden with flowers in the foreground 1960s styl;e film She's holding her hand out there is a small smooth frog in her palm, she's making eye contact with the toad."
print(f"\nGenerating image with prompt: {prompt}")

image = pipe(
    prompt=prompt,
    num_inference_steps=8,
    guidance_scale=1.0,
    height=1024,
    width=1024,
    generator=torch.Generator(device="cuda").manual_seed(42),
).images[0]

output_path = "test_zimage_lora_output.png"
image.save(output_path)
print(f"\nImage saved to {output_path}")

@sayakpaul
Copy link
Member

@asomoza cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants