brightpay commited on
Commit
92ef194
Β·
verified Β·
1 Parent(s): 74577f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from diffusers import StableDiffusionPipeline
2
  from safetensors.torch import load_file
3
  import torch
@@ -6,18 +7,22 @@ def load_pipeline(base_model_path, lora_path):
6
  # Load base SD-v1.5 pipeline
7
  pipeline = StableDiffusionPipeline.from_pretrained(base_model_path)
8
 
 
 
 
9
  # Load LoRA weights
10
  lora_state_dict = load_file(lora_path)
11
  pipeline.unet.load_attn_procs(lora_state_dict)
12
 
13
  return pipeline
14
 
15
- # Correct paths
16
- base_model_path = "runwayml/stable-diffusion-v1-5" # Use a valid Hugging Face repo ID
17
- lora_path = "https://huggingface.co/maria26/Floor_Plan_LoRA/blob/main/model.safetensors" # Ensure LoRA file is available locally
 
18
 
19
  # Load the pipeline
20
- pipeline = load_pipeline(base_model_path, lora_path)
21
 
22
  def predict(prompt):
23
  result = pipeline(prompt).images[0]
 
1
+ from huggingface_hub import hf_hub_download
2
  from diffusers import StableDiffusionPipeline
3
  from safetensors.torch import load_file
4
  import torch
 
7
  # Load base SD-v1.5 pipeline
8
  pipeline = StableDiffusionPipeline.from_pretrained(base_model_path)
9
 
10
+ # Download the LoRA file
11
+ lora_path = hf_hub_download(repo_id=lora_repo_id, filename=lora_filename)
12
+
13
  # Load LoRA weights
14
  lora_state_dict = load_file(lora_path)
15
  pipeline.unet.load_attn_procs(lora_state_dict)
16
 
17
  return pipeline
18
 
19
+ # Define parameters
20
+ base_model_path = "runwayml/stable-diffusion-v1-5"
21
+ lora_repo_id = "maria26/Floor_Plan_LoRA"
22
+ lora_filename = "model.safetensors"
23
 
24
  # Load the pipeline
25
+ pipeline = load_pipeline(base_model_path, lora_repo_id, lora_filename)
26
 
27
  def predict(prompt):
28
  result = pipeline(prompt).images[0]