zenafey commited on
Commit
08e6691
1 Parent(s): 0e59796

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -98,8 +98,12 @@ def remove_id_and_ext(text):
98
  text = text[:-4]
99
  return text
100
 
101
- def place_lora(lorabtn):
102
- return lorabtn
 
 
 
 
103
 
104
  def create_grid(image_urls):
105
  # Download first image to get size
@@ -334,9 +338,10 @@ with gr.Blocks(css=css) as demo:
334
 
335
  with gr.Tab("Lora"):
336
  loralist = prodia_client.list_loras()
337
- for lora in loralist:
338
- lora_btn = gr.Button(lora)
339
- lora_btn.click(place_lora, inputs=[lora_btn], outputs=prompt)
 
340
 
341
  with gr.Column(scale=2):
342
  image_output = gr.Gallery(value=["https://images.prodia.xyz/8ede1a7c-c0ee-4ded-987d-6ffed35fc477.png"], preview=True)
 
98
  text = text[:-4]
99
  return text
100
 
101
+ def place_lora(current_prompt, lorabtn):
102
+ if f"<lora:{lorabtn}:1.0>" in current_prompt:
103
+ result = current_prompt.replace(f"<lora:{lorabtn}:1.0>", "")
104
+ else:
105
+ result = f"{current_prompt}, <lora:{lorabtn}:1.0>"
106
+ return result
107
 
108
  def create_grid(image_urls):
109
  # Download first image to get size
 
338
 
339
  with gr.Tab("Lora"):
340
  loralist = prodia_client.list_loras()
341
+ with gr.Row():
342
+ for lora in loralist:
343
+ lora_btn = gr.Button(lora)
344
+ lora_btn.click(place_lora, inputs=[lora_btn], outputs=prompt)
345
 
346
  with gr.Column(scale=2):
347
  image_output = gr.Gallery(value=["https://images.prodia.xyz/8ede1a7c-c0ee-4ded-987d-6ffed35fc477.png"], preview=True)