multimodalart HF staff commited on
Commit
d41c21d
1 Parent(s): 02e03d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -35,14 +35,11 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
35
  "stabilityai/stable-diffusion-xl-base-1.0",
36
  vae=vae,
37
  torch_dtype=torch.float16,
38
- ).to("cpu")
39
- original_pipe = copy.deepcopy(pipe)
40
- pipe.to(device)
41
 
42
  last_lora = ""
43
  last_merged = False
44
 
45
-
46
  def update_selection(selected_state: gr.SelectData):
47
  lora_repo = sdxl_loras[selected_state.index]["repo"]
48
  instance_prompt = sdxl_loras[selected_state.index]["trigger_word"]
@@ -132,9 +129,11 @@ def run_lora(prompt, negative, lora_scale, selected_state):
132
  cross_attention_kwargs = None
133
  if last_lora != repo_name:
134
  if last_merged:
135
- del pipe
136
- pipe = copy.deepcopy(original_pipe)
137
- pipe.to(device)
 
 
138
  else:
139
  pipe.unload_lora_weights()
140
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
 
35
  "stabilityai/stable-diffusion-xl-base-1.0",
36
  vae=vae,
37
  torch_dtype=torch.float16,
38
+ ).to(device)
 
 
39
 
40
  last_lora = ""
41
  last_merged = False
42
 
 
43
  def update_selection(selected_state: gr.SelectData):
44
  lora_repo = sdxl_loras[selected_state.index]["repo"]
45
  instance_prompt = sdxl_loras[selected_state.index]["trigger_word"]
 
129
  cross_attention_kwargs = None
130
  if last_lora != repo_name:
131
  if last_merged:
132
+ pipe = StableDiffusionXLPipeline.from_pretrained(
133
+ "stabilityai/stable-diffusion-xl-base-1.0",
134
+ vae=vae,
135
+ torch_dtype=torch.float16,
136
+ ).to(device)
137
  else:
138
  pipe.unload_lora_weights()
139
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]