mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-18 13:58:15 +00:00
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
|
|
from diffsynth import load_state_dict
|
|
from PIL import Image
|
|
import torch
|
|
|
|
|
|
pipe = QwenImagePipeline.from_pretrained(
|
|
torch_dtype=torch.bfloat16,
|
|
device="cuda",
|
|
model_configs=[
|
|
ModelConfig(model_id="DiffSynth-Studio/Qwen-Image-Layered-Control", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors"),
|
|
ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors"),
|
|
ModelConfig(model_id="Qwen/Qwen-Image-Layered", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
|
|
],
|
|
tokenizer_config=ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="tokenizer/"),
|
|
)
|
|
pipe.load_lora(pipe.dit, "models/train/Qwen-Image-Layered-Control_lora/epoch-4.safetensors")
|
|
prompt = "Text 'HELLO' and 'Have a great day'"
|
|
input_image = Image.open("data/example_image_dataset/layer/image.png").convert("RGBA").resize((864, 480))
|
|
images = pipe(
|
|
prompt, seed=0,
|
|
height=480, width=864,
|
|
layer_input_image=input_image, layer_num=0,
|
|
)
|
|
images[0].save("image.png")
|