naonauno commited on
Commit
b8fecf5
·
verified ·
1 Parent(s): ceba152

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  from diffusers import StableDiffusionPipeline
4
  import os
5
  from huggingface_hub import login
 
6
 
7
  # Login using the token
8
  login(token=os.environ.get("HF_TOKEN"))
@@ -15,16 +16,10 @@ pipe = StableDiffusionPipeline.from_pretrained(
15
  use_auth_token=os.environ.get("HF_TOKEN")
16
  )
17
 
18
- # Load your LoRA weights
19
- lora_path = "naonauno/40k-half-sd15"
20
- pipe.load_lora_weights(
21
- lora_path,
22
- weight_name="40kHalf.safetensors",
23
- use_auth_token=os.environ.get("HF_TOKEN")
24
- )
25
-
26
- # Set the cross attention processor scale
27
- pipe.fuse_lora(scale=1.0)
28
 
29
  def generate_image(prompt, negative_prompt, guidance_scale, steps):
30
  with torch.no_grad():
 
3
  from diffusers import StableDiffusionPipeline
4
  import os
5
  from huggingface_hub import login
6
+ from safetensors.torch import load_file
7
 
8
  # Login using the token
9
  login(token=os.environ.get("HF_TOKEN"))
 
16
  use_auth_token=os.environ.get("HF_TOKEN")
17
  )
18
 
19
+ # Load your LoRA weights from local file
20
+ lora_path = "models/40kHalf.safetensors" # Update this path to where you upload the file in your Space
21
+ state_dict = load_file(lora_path)
22
+ pipe.unet.load_attn_procs(state_dict)
 
 
 
 
 
 
23
 
24
  def generate_image(prompt, negative_prompt, guidance_scale, steps):
25
  with torch.no_grad():