diffusers-load adapters

一、DreamBooth(待补充)

二、Textual inversion(待补充)

三、Lora

diffusers-load adapters_第1张图片

from diffusers import AutoPipelineForText2Image
import torch

pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16).to("cuda")

在这里插入图片描述
diffusers-load adapters_第2张图片

pipeline.load_lora_weights("ostris/super-cereal-sdxl-lora", weight_name="cereal_box_sdxl_v1.safetensors")
prompt = "bears, pizza bites"
image = pipeline(prompt).images[0]
image

diffusers-load adapters_第3张图片
diffusers-load adapters_第4张图片
diffusers-load adapters_第5张图片

from diffusers import AutoPipelineForText2Image
import torch

pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16).to("cuda")
pipeline.unet.load_attn_procs("jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors")

# use cnmt in the prompt to trigger the LoRA
prompt = "A cute cnmt eating a slice of pizza, stunning color scheme, masterpiece, illustration"
image = pipeline(prompt).images[0]
image

注意区分load_lora_weights和unet.load_attn_procs的区别,这里我觉得还是推荐用load_lora_weights

diffusers-load adapters_第6张图片
diffusers-load adapters_第7张图片
diffusers-load adapters_第8张图片
diffusers-load adapters_第9张图片
diffusers-load adapters_第10张图片
这里说的无法取消多个lora权重的融合,不是很理解,还需要继续去看diffuser的底层代码
diffusers-load adapters_第11张图片
diffusers-load adapters_第12张图片

from diffusers import DiffusionPipeline
import torch

pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16).to("cuda")
pipeline.load_lora_weights("ostris/ikea-instructions-lora-sdxl", weight_name="ikea_instructions_xl_v1_5.safetensors", adapter_name="ikea")
pipeline.load_lora_weights("ostris/super-cereal-sdxl-lora", weight_name="cereal_box_sdxl_v1.safetensors", adapter_name="cereal")

diffusers-load adapters_第13张图片

prompt = "A cute brown bear eating a slice of pizza, stunning color scheme, masterpiece, illustration"
image = pipeline(prompt, num_inference_steps=30, cross_attention_kwargs={"scale": 1.0}).images[0]
image

四、IP-Adapter(待补充)

你可能感兴趣的:(diffuser)