Skip to content

diffusion components have no 'add_weighted_adapter' #2592

@garychan22

Description

@garychan22

Hi, I have followed the guidance https://huggingface.co/docs/diffusers/using-diffusers/merge_loras here,

pipeline = AutoPipelineForText2Image.from_pretrained(
        source_pipeline_path,
        vae=vae,
        # variant="fp16",
        torch_dtype=torch.float16
    ).to("cuda")
pipeline.to(device, torch.float16)

print("Load unet lora")
pipeline.unet = PeftModel.from_pretrained(pipeline.unet, os.path.join(lora_path, "unet"), adapter_name="unet")
print(type(pipeline.unet))  # output: PeftModel
pipeline.unet.add_weighted_adapter(["unet"], weights=[lora_scale]) 
pipeline.unet.merge_and_unload()
pipeline.unet.to(device, dtype=torch.float16)

When calling pipeline.unet.add_weighted_adapter(["unet"], weights=[lora_scale]) , the following error was encountered

UNet2DConditionModel has no 'add_weighted_adapter'

Not only the unet but also the two text_encoders.

My expectation is to set the lora scale of these components. Thanks!


diffusers 0.32.2
peft 0.15.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions