Abdullah-Habib commited on
Commit
6e754cf
·
1 Parent(s): 117fdd4

testing with 2 loras

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -28,14 +28,14 @@ pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
28
  pipe.to("cuda")
29
 
30
  def update_selection(evt: gr.SelectData):
31
- # selected_lora = loras[evt.index]
32
- new_placeholder = f"Type a prompt"
33
- # lora_repo = selected_lora["repo"]
34
- # updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
35
  return (
36
  gr.update(placeholder=new_placeholder),
37
  updated_text,
38
- # evt.index
39
  )
40
 
41
  @spaces.GPU
@@ -43,8 +43,8 @@ def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index, schedule
43
  if selected_index is None:
44
  raise gr.Error("You must select a LoRA before proceeding.")
45
 
46
- # selected_lora = loras[selected_index]
47
- # # lora_path = selected_lora["repo"]
48
  # trigger_word = selected_lora["trigger_word"]
49
 
50
  # Load LoRA weights
@@ -155,7 +155,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
155
  value="DPM++ 2M SDE Karras"
156
  )
157
 
158
- gallery.select(update_selection, outputs=[prompt, selected_info])
159
 
160
  generate_button.click(
161
  fn=run_lora,
 
28
  pipe.to("cuda")
29
 
30
  def update_selection(evt: gr.SelectData):
31
+ selected_lora = loras[evt.index]
32
+ new_placeholder = f"Type a prompt for {selected_lora['title']}"
33
+ lora_repo = selected_lora["repo"]
34
+ updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
35
  return (
36
  gr.update(placeholder=new_placeholder),
37
  updated_text,
38
+ evt.index
39
  )
40
 
41
  @spaces.GPU
 
43
  if selected_index is None:
44
  raise gr.Error("You must select a LoRA before proceeding.")
45
 
46
+ selected_lora = loras[selected_index]
47
+ # lora_path = selected_lora["repo"]
48
  # trigger_word = selected_lora["trigger_word"]
49
 
50
  # Load LoRA weights
 
155
  value="DPM++ 2M SDE Karras"
156
  )
157
 
158
+ gallery.select(update_selection, outputs=[prompt, selected_info, selected_index])
159
 
160
  generate_button.click(
161
  fn=run_lora,