Closed lavinal712 closed 4 months ago
Hi, can I ask how do you train the controlnet with lora?
Hi, can I ask how do you train the controlnet with lora?
Please refer to https://github.com/huggingface/diffusers/discussions/7107. I also open a repo called control-lora-v3.
Describe the bug
I have tried to train a controlnet with lora, but after I merge the controlnet model and lora, the weight of controlnet seems not changed. (maybe inaccurate as i did not check the tensor)
Known:
if args.use_lora: config = LoraConfig( r=args.lora_r, lora_alpha=args.lora_alpha, target_modules=CONTROLNET_TARGET_MODULE, lora_dropout=args.lora_dropout, bias=args.lora_bias, ) controlnet = get_peft_model(controlnet, config)
unet = UNet2DConditionModel.from_pretrained( base_model, subfolder="unet", torch_dtype=torch.float16 ) controlnet = ControlNetModel.from_unet(unet) control_lora = PeftModel.from_pretrained(controlnet, "controlnet") control_lora = control_lora.merge_and_unload() control_lora.save_pretrained(controlnet_save_path) control_lora = ControlNetModel().from_pretrained("save")```
control_v11p_sd15_canny
, but to train it from scratch.Reproduction
Logs
No response
System Info
diffusers
version: 0.27.2Who can help?
No response