当前位置:   article > 正文

解决Diffuers训练LoRA,推理时LoRA权重不起作用的问题_diffusers 训练的lora效果不好

diffusers 训练的lora效果不好

原因是最新版的Diffusers更新之后,利用新训练的LoRA权重做推理时,加载模型的API更新了,需要将原来的

model_path = "预训练的LoRA权重" 
pipe = StableDiffusionPipeline.from_pretrained("stable diffusion底模路径",
                                               torch_dtype=torch.float16, safety_checker = None, requires_safety_checker = False)
pipe.unet.load_attn_procs(model_path)
  • 1
  • 2
  • 3
  • 4

替换为:

pipeline = StableDiffusionPipeline.from_pretrained("stable diffusion底模路径",
                                               torch_dtype=torch.float16, safety_checker = None, requires_safety_checker = False).to("cuda")
pipeline.load_lora_weights("预训练的LoRA权重", weight_name="pytorch_lora_weights.safetensors")
  • 1
  • 2
  • 3

pipeline = AutoPipelineForText2Image.from_pretrained("stable diffusion底模路径",
                                                     torch_dtype=torch.float16, safety_checker = None, requires_safety_checker = False).to("cuda")
pipeline.load_lora_weights("预训练的LoRA权重", weight_name="pytorch_lora_weights.safetensors")
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/680966
推荐阅读
相关标签
  

闽ICP备14008679号