alexanz commited on
Commit
beb956c
·
verified ·
1 Parent(s): caa5a3e

fix lora scale

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -61,10 +61,10 @@ def load_model(model_id, lora_strength, use_controlnet=False, control_mode="edge
61
  controlnet=controlnet,
62
  torch_dtype=torch_dtype
63
  )
64
- pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, scaling=lora_strength, torch_dtype=torch_dtype)
65
  else:
66
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch_dtype)
67
- pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, scaling=lora_strength)
68
 
69
  elif model_id == "alexanz/SD15_lora_pusheen":
70
  if use_controlnet:
@@ -74,11 +74,11 @@ def load_model(model_id, lora_strength, use_controlnet=False, control_mode="edge
74
  controlnet=controlnet,
75
  torch_dtype=torch_dtype
76
  )
77
- pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, scaling=lora_strength, torch_dtype=torch_dtype)
78
  else:
79
  if acceleration_mode is None:
80
  pipe = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch_dtype)
81
- pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, scaling=lora_strength)
82
  elif acceleration_mode == "distilled":
83
  pipe = StableDiffusionPipeline.from_pretrained(
84
  "nota-ai/bk-sdm-small", torch_dtype=torch.float16, use_safetensors=True,
@@ -167,7 +167,8 @@ def infer(
167
  generator=generator,
168
  image=control_image_cont if use_controlnet else None,
169
  controlnet_conditioning_scale=control_strength_cont if use_controlnet else None,
170
- ip_adapter_image=control_image_ip if use_ip_adapter else None
 
171
  ).images[0]
172
 
173
  if use_rmbg:
 
61
  controlnet=controlnet,
62
  torch_dtype=torch_dtype
63
  )
64
+ pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, torch_dtype=torch_dtype)
65
  else:
66
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch_dtype)
67
+ pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id)
68
 
69
  elif model_id == "alexanz/SD15_lora_pusheen":
70
  if use_controlnet:
 
74
  controlnet=controlnet,
75
  torch_dtype=torch_dtype
76
  )
77
+ pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id, torch_dtype=torch_dtype)
78
  else:
79
  if acceleration_mode is None:
80
  pipe = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch_dtype)
81
+ pipe.unet = PeftModel.from_pretrained(pipe.unet, model_id)
82
  elif acceleration_mode == "distilled":
83
  pipe = StableDiffusionPipeline.from_pretrained(
84
  "nota-ai/bk-sdm-small", torch_dtype=torch.float16, use_safetensors=True,
 
167
  generator=generator,
168
  image=control_image_cont if use_controlnet else None,
169
  controlnet_conditioning_scale=control_strength_cont if use_controlnet else None,
170
+ ip_adapter_image=control_image_ip if use_ip_adapter else None,
171
+ cross_attention_kwargs={"scale": lora_strength}
172
  ).images[0]
173
 
174
  if use_rmbg: