Download examples/qwen_image/model_training/validate_lora/Qwen-Image-Layered-Control.py from ymyy307/diffsynth: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/ymyy307/diffsynth/resolve/main/examples/qwen_image/model_training/validate_lora/Qwen-Image-Layered-Control.py
- Command line
-
hf download hf://ymyy307/diffsynth/examples/qwen_image/model_training/validate_lora/Qwen-Image-Layered-Control.py
-
curl -L -o Qwen-Image-Layered-Control.py https://huggingface.co/ymyy307/diffsynth/resolve/main/examples/qwen_image/model_training/validate_lora/Qwen-Image-Layered-Control.py
1.13 kB
| 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") | |