John6666 commited on
Commit
b397bfd
1 Parent(s): 64f7574

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -78,8 +78,8 @@ def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height,
78
 
79
  def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, width, height,
80
  lora_scale, lora_repo, lora_weights, lora_trigger, progress=gr.Progress(track_tqdm=True)):
81
- if selected_index is None and not lora_repo:
82
- raise gr.Error("You must select a LoRA before proceeding.")
83
 
84
  if selected_index is not None and not lora_repo:
85
  selected_lora = loras[selected_index]
@@ -92,7 +92,9 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
92
 
93
  # Load LoRA weights
94
  with calculateDuration(f"Loading LoRA weights for {selected_lora['title']}"):
95
- if lora_weights: # override
 
 
96
  pipe.load_lora_weights(lora_path, weight_name=lora_weights)
97
  elif "weights" in selected_lora:
98
  pipe.load_lora_weights(lora_path, weight_name=selected_lora["weights"])
@@ -106,7 +108,7 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
106
 
107
  image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress)
108
  pipe.to("cpu")
109
- pipe.unload_lora_weights()
110
  return image, seed
111
 
112
  run_lora.zerogpu = True
 
78
 
79
  def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, width, height,
80
  lora_scale, lora_repo, lora_weights, lora_trigger, progress=gr.Progress(track_tqdm=True)):
81
+ #if selected_index is None and not lora_repo:
82
+ # raise gr.Error("You must select a LoRA before proceeding.")
83
 
84
  if selected_index is not None and not lora_repo:
85
  selected_lora = loras[selected_index]
 
92
 
93
  # Load LoRA weights
94
  with calculateDuration(f"Loading LoRA weights for {selected_lora['title']}"):
95
+ if selected_index is None and not lora_repo: # override
96
+ pass
97
+ elif lora_weights: # override
98
  pipe.load_lora_weights(lora_path, weight_name=lora_weights)
99
  elif "weights" in selected_lora:
100
  pipe.load_lora_weights(lora_path, weight_name=selected_lora["weights"])
 
108
 
109
  image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress)
110
  pipe.to("cpu")
111
+ if selected_index is not None or lora_repo: pipe.unload_lora_weights()
112
  return image, seed
113
 
114
  run_lora.zerogpu = True