Charbel Malo commited on
Commit
df0828c
·
verified ·
1 Parent(s): 9a9918c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +181 -151
app.py CHANGED
@@ -15,7 +15,7 @@ import time
15
  import requests
16
  import pandas as pd
17
 
18
- # Load prompts for randomization
19
  df = pd.read_csv('prompts.csv', header=None)
20
  prompt_values = df.values.flatten()
21
 
@@ -88,19 +88,26 @@ def update_selection(evt: gr.SelectData, selected_indices, loras_state, width, h
88
  if selected_index in selected_indices:
89
  selected_indices.remove(selected_index)
90
  else:
91
- selected_indices.append(selected_index)
92
-
93
- selected_infos = []
94
- lora_scales = []
95
- lora_images = []
96
- for idx, sel_idx in enumerate(selected_indices):
97
- lora = loras_state[sel_idx]
98
- selected_info = f"### LoRA {idx+1} Selected: [{lora['title']}](https://huggingface.co/{lora['repo']}) ✨"
99
- lora_scale = 1.15 # Default value
100
- lora_image = lora['image']
101
- selected_infos.append(selected_info)
102
- lora_scales.append(lora_scale)
103
- lora_images.append(lora_image)
 
 
 
 
 
 
 
104
 
105
  if selected_indices:
106
  last_selected_lora = loras_state[selected_indices[-1]]
@@ -108,81 +115,60 @@ def update_selection(evt: gr.SelectData, selected_indices, loras_state, width, h
108
  else:
109
  new_placeholder = "Type a prompt after selecting a LoRA"
110
 
111
- # Update the number of visible LoRA slots based on the number of selected indices
112
- num_selected = len(selected_indices)
113
- lora_slot_updates = []
114
- for i in range(num_selected):
115
- lora_slot_updates.append(gr.update(visible=True))
116
- for i in range(num_selected, 5): # Assuming max 5 LoRAs
117
- lora_slot_updates.append(gr.update(visible=False))
118
-
119
- return (
120
- gr.update(placeholder=new_placeholder),
121
- selected_infos,
122
- selected_indices,
123
- lora_scales,
124
- width,
125
- height,
126
- lora_images,
127
- lora_slot_updates
128
- )
129
-
130
- def add_lora_slot(num_loras_visible):
131
- if num_loras_visible < 5: # Assuming max 5 LoRAs
132
- num_loras_visible += 1
133
- else:
134
- gr.Warning("Maximum number of LoRAs reached.")
135
- lora_slot_updates = []
136
- for i in range(num_loras_visible):
137
- lora_slot_updates.append(gr.update(visible=True))
138
- for i in range(num_loras_visible, 5):
139
- lora_slot_updates.append(gr.update(visible=False))
140
- return num_loras_visible, lora_slot_updates
141
-
142
- def remove_lora_slot(idx_to_remove, selected_indices):
143
- if idx_to_remove < len(selected_indices):
144
- selected_indices.pop(idx_to_remove)
145
- selected_infos = []
146
- lora_scales = []
147
- lora_images = []
148
- for idx, sel_idx in enumerate(selected_indices):
149
- lora = loras_state[sel_idx]
150
- selected_info = f"### LoRA {idx+1} Selected: [{lora['title']}]({lora['repo']}) ✨"
151
- lora_scale = 1.15 # Default value
152
- lora_image = lora['image']
153
- selected_infos.append(selected_info)
154
- lora_scales.append(lora_scale)
155
- lora_images.append(lora_image)
156
- num_loras_visible = len(selected_indices)
157
- lora_slot_updates = []
158
- for i in range(num_loras_visible):
159
- lora_slot_updates.append(gr.update(visible=True))
160
- for i in range(num_loras_visible, 5):
161
- lora_slot_updates.append(gr.update(visible=False))
162
- return selected_infos, selected_indices, lora_scales, lora_images, num_loras_visible, lora_slot_updates
163
 
164
  def randomize_loras(selected_indices, loras_state):
165
- num_to_select = random.randint(1, 5)
166
- selected_indices = random.sample(range(len(loras_state)), num_to_select)
167
- selected_infos = []
168
- lora_scales = []
169
- lora_images = []
170
- for idx, sel_idx in enumerate(selected_indices):
171
- lora = loras_state[sel_idx]
172
- selected_info = f"### LoRA {idx+1} Selected: [{lora['title']}](https://huggingface.co/{lora['repo']}) ✨"
173
- lora_scale = 1.15 # Default value
174
- lora_image = lora['image']
175
- selected_infos.append(selected_info)
176
- lora_scales.append(lora_scale)
177
- lora_images.append(lora_image)
178
  random_prompt = random.choice(prompt_values)
179
- num_loras_visible = len(selected_indices)
180
- lora_slot_updates = []
181
- for i in range(num_loras_visible):
182
- lora_slot_updates.append(gr.update(visible=True))
183
- for i in range(num_loras_visible, 5):
184
- lora_slot_updates.append(gr.update(visible=False))
185
- return selected_infos, selected_indices, lora_scales, lora_images, random_prompt, num_loras_visible, lora_slot_updates
186
 
187
  def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
188
  if custom_lora:
@@ -206,44 +192,83 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
206
 
207
  # Update gallery
208
  gallery_items = [(item["image"], item["title"]) for item in current_loras]
209
- # Update selected_indices
210
- selected_indices.append(existing_item_index)
 
 
 
211
 
212
  # Update selected_info and images
213
- selected_infos = []
214
- lora_scales = []
215
- lora_images = []
216
- for idx, sel_idx in enumerate(selected_indices):
217
- lora = current_loras[sel_idx]
218
- selected_info = f"### LoRA {idx+1} Selected: {lora['title']} ✨"
219
- lora_scale = 1.15 # Default value
220
- lora_image = lora['image'] if lora['image'] else None
221
- selected_infos.append(selected_info)
222
- lora_scales.append(lora_scale)
223
- lora_images.append(lora_image)
224
- num_loras_visible = len(selected_indices)
225
- lora_slot_updates = []
226
- for i in range(num_loras_visible):
227
- lora_slot_updates.append(gr.update(visible=True))
228
- for i in range(num_loras_visible, 5):
229
- lora_slot_updates.append(gr.update(visible=False))
230
  print("Finished adding custom LoRA")
231
  return (
232
  current_loras,
233
  gr.update(value=gallery_items),
234
- selected_infos,
 
235
  selected_indices,
236
- lora_scales,
237
- lora_images,
238
- num_loras_visible,
239
- lora_slot_updates
240
  )
241
  except Exception as e:
242
  print(e)
243
  gr.Warning(str(e))
244
- return current_loras, gr.update(), selected_infos, selected_indices, lora_scales, lora_images, 0, []
245
  else:
246
- return current_loras, gr.update(), [], selected_indices, [], [], 0, []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
  def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
249
  print("Generating image...")
@@ -283,7 +308,7 @@ def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps
283
  return final_image
284
 
285
  @spaces.GPU(duration=75)
286
- def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_indices, lora_scales, randomize_seed, seed, width, height, loras_state, progress=gr.Progress(track_tqdm=True)):
287
  if not selected_indices:
288
  raise gr.Error("You must select at least one LoRA before proceeding.")
289
 
@@ -315,7 +340,7 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
315
  lora_name = f"lora_{idx}"
316
  lora_names.append(lora_name)
317
  print(f"Lora Name: {lora_name}")
318
- lora_weights.append(lora_scales[idx] if idx < len(lora_scales) else 1.15)
319
  lora_path = lora['repo']
320
  weight_name = lora.get("weights")
321
  print(f"Lora Path: {lora_path}")
@@ -326,6 +351,8 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
326
  low_cpu_mem_usage=True,
327
  adapter_name=lora_name
328
  )
 
 
329
  print("Loaded LoRAs:", lora_names)
330
  print("Adapter weights:", lora_weights)
331
  if image_input is not None:
@@ -446,34 +473,34 @@ with gr.Blocks(css=css, delete_cache=(60, 60)) as app:
446
  )
447
  loras_state = gr.State(loras)
448
  selected_indices = gr.State([])
449
- num_loras_visible = gr.State(2)
450
  with gr.Row():
451
  with gr.Column(scale=3):
452
  prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
453
  with gr.Column(scale=1):
454
  generate_button = gr.Button("Generate", variant="primary", elem_classes=["button_total"])
455
  with gr.Row(elem_id="loaded_loras"):
456
- add_lora_button = gr.Button("Add LoRA", variant="primary")
457
- randomize_button = gr.Button("🎲", variant="secondary", scale=1, elem_id="random_btn")
458
- lora_slots = []
459
- for i in range(5): # Assuming max 5 LoRAs
460
- with gr.Column(visible=(i < 2), elem_id=f"lora_slot_{i}"):
461
- with gr.Row():
462
- with gr.Column(scale=0, min_width=50):
463
- lora_image = gr.Image(label=f"LoRA {i+1} Image", interactive=False, min_width=50, width=50, show_label=False, show_share_button=False, show_download_button=False, show_fullscreen_button=False, height=50)
464
- with gr.Column(scale=3, min_width=100):
465
- selected_info = gr.Markdown(f"Select a LoRA {i+1}")
466
- with gr.Column(scale=5, min_width=50):
467
- lora_scale = gr.Slider(label=f"LoRA {i+1} Scale", minimum=0, maximum=3, step=0.01, value=1.15)
468
- with gr.Row():
469
- remove_button = gr.Button("Remove", size="sm")
470
- lora_slots.append({
471
- 'lora_image': lora_image,
472
- 'selected_info': selected_info,
473
- 'lora_scale': lora_scale,
474
- 'remove_button': remove_button,
475
- 'visible': (i < 2),
476
- })
 
477
  with gr.Row():
478
  with gr.Column():
479
  with gr.Group():
@@ -518,33 +545,36 @@ with gr.Blocks(css=css, delete_cache=(60, 60)) as app:
518
  gallery.select(
519
  update_selection,
520
  inputs=[selected_indices, loras_state, width, height],
521
- outputs=[prompt, [slot['selected_info'] for slot in lora_slots], selected_indices, [slot['lora_scale'] for slot in lora_slots], width, height, [slot['lora_image'] for slot in lora_slots], [slot['lora_image'] for slot in lora_slots]]
 
 
 
 
522
  )
523
- add_lora_button.click(
524
- add_lora_slot,
525
- inputs=[num_loras_visible],
526
- outputs=[num_loras_visible, [gr.update(visible=True) for slot in lora_slots]]
527
  )
528
- for idx, slot in enumerate(lora_slots):
529
- slot['remove_button'].click(
530
- remove_lora_slot,
531
- inputs=[idx, selected_indices],
532
- outputs=[[s['selected_info'] for s in lora_slots], selected_indices, [s['lora_scale'] for s in lora_slots], [s['lora_image'] for s in lora_slots], num_loras_visible, [gr.update(visible=s['visible']) for s in lora_slots]]
533
- )
534
  randomize_button.click(
535
  randomize_loras,
536
  inputs=[selected_indices, loras_state],
537
- outputs=[[slot['selected_info'] for slot in lora_slots], selected_indices, [slot['lora_scale'] for slot in lora_slots], [slot['lora_image'] for slot in lora_slots], prompt, num_loras_visible, [gr.update(visible=slot['visible']) for slot in lora_slots]]
538
  )
539
  add_custom_lora_button.click(
540
  add_custom_lora,
541
  inputs=[custom_lora, selected_indices, loras_state, gallery],
542
- outputs=[loras_state, gallery, [slot['selected_info'] for slot in lora_slots], selected_indices, [slot['lora_scale'] for slot in lora_slots], [slot['lora_image'] for slot in lora_slots], num_loras_visible, [gr.update(visible=slot['visible']) for slot in lora_slots]]
 
 
 
 
 
543
  )
544
  gr.on(
545
  triggers=[generate_button.click, prompt.submit],
546
  fn=run_lora,
547
- inputs=[prompt, input_image, image_strength, cfg_scale, steps, selected_indices, [slot['lora_scale'] for slot in lora_slots], randomize_seed, seed, width, height, loras_state],
548
  outputs=[result, seed, progress_bar]
549
  ).then(
550
  fn=lambda x, history: update_history(x, history),
@@ -553,4 +583,4 @@ with gr.Blocks(css=css, delete_cache=(60, 60)) as app:
553
  )
554
 
555
  app.queue()
556
- app.launch()
 
15
  import requests
16
  import pandas as pd
17
 
18
+ #Load prompts for randomization
19
  df = pd.read_csv('prompts.csv', header=None)
20
  prompt_values = df.values.flatten()
21
 
 
88
  if selected_index in selected_indices:
89
  selected_indices.remove(selected_index)
90
  else:
91
+ if len(selected_indices) < 2:
92
+ selected_indices.append(selected_index)
93
+ else:
94
+ gr.Warning("You can select up to 2 LoRAs, remove one to select a new one.")
95
+ return gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), width, height, gr.update(), gr.update()
96
+
97
+ selected_info_1 = "Select a LoRA 1"
98
+ selected_info_2 = "Select a LoRA 2"
99
+ lora_scale_1 = 1.15
100
+ lora_scale_2 = 1.15
101
+ lora_image_1 = None
102
+ lora_image_2 = None
103
+ if len(selected_indices) >= 1:
104
+ lora1 = loras_state[selected_indices[0]]
105
+ selected_info_1 = f"### LoRA 1 Selected: [{lora1['title']}](https://huggingface.co/{lora1['repo']}) ✨"
106
+ lora_image_1 = lora1['image']
107
+ if len(selected_indices) >= 2:
108
+ lora2 = loras_state[selected_indices[1]]
109
+ selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}](https://huggingface.co/{lora2['repo']}) ✨"
110
+ lora_image_2 = lora2['image']
111
 
112
  if selected_indices:
113
  last_selected_lora = loras_state[selected_indices[-1]]
 
115
  else:
116
  new_placeholder = "Type a prompt after selecting a LoRA"
117
 
118
+ return gr.update(placeholder=new_placeholder), selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, width, height, lora_image_1, lora_image_2
119
+
120
+ def remove_lora_1(selected_indices, loras_state):
121
+ if len(selected_indices) >= 1:
122
+ selected_indices.pop(0)
123
+ selected_info_1 = "Select a LoRA 1"
124
+ selected_info_2 = "Select a LoRA 2"
125
+ lora_scale_1 = 1.15
126
+ lora_scale_2 = 1.15
127
+ lora_image_1 = None
128
+ lora_image_2 = None
129
+ if len(selected_indices) >= 1:
130
+ lora1 = loras_state[selected_indices[0]]
131
+ selected_info_1 = f"### LoRA 1 Selected: [{lora1['title']}]({lora1['repo']}) ✨"
132
+ lora_image_1 = lora1['image']
133
+ if len(selected_indices) >= 2:
134
+ lora2 = loras_state[selected_indices[1]]
135
+ selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}]({lora2['repo']}) ✨"
136
+ lora_image_2 = lora2['image']
137
+ return selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2
138
+
139
+ def remove_lora_2(selected_indices, loras_state):
140
+ if len(selected_indices) >= 2:
141
+ selected_indices.pop(1)
142
+ selected_info_1 = "Select LoRA 1"
143
+ selected_info_2 = "Select LoRA 2"
144
+ lora_scale_1 = 1.15
145
+ lora_scale_2 = 1.15
146
+ lora_image_1 = None
147
+ lora_image_2 = None
148
+ if len(selected_indices) >= 1:
149
+ lora1 = loras_state[selected_indices[0]]
150
+ selected_info_1 = f"### LoRA 1 Selected: [{lora1['title']}]({lora1['repo']}) ✨"
151
+ lora_image_1 = lora1['image']
152
+ if len(selected_indices) >= 2:
153
+ lora2 = loras_state[selected_indices[1]]
154
+ selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}]({lora2['repo']}) ✨"
155
+ lora_image_2 = lora2['image']
156
+ return selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  def randomize_loras(selected_indices, loras_state):
159
+ if len(loras_state) < 2:
160
+ raise gr.Error("Not enough LoRAs to randomize.")
161
+ selected_indices = random.sample(range(len(loras_state)), 2)
162
+ lora1 = loras_state[selected_indices[0]]
163
+ lora2 = loras_state[selected_indices[1]]
164
+ selected_info_1 = f"### LoRA 1 Selected: [{lora1['title']}](https://huggingface.co/{lora1['repo']}) ✨"
165
+ selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}](https://huggingface.co/{lora2['repo']}) ✨"
166
+ lora_scale_1 = 1.15
167
+ lora_scale_2 = 1.15
168
+ lora_image_1 = lora1['image']
169
+ lora_image_2 = lora2['image']
 
 
170
  random_prompt = random.choice(prompt_values)
171
+ return selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2, random_prompt
 
 
 
 
 
 
172
 
173
  def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
174
  if custom_lora:
 
192
 
193
  # Update gallery
194
  gallery_items = [(item["image"], item["title"]) for item in current_loras]
195
+ # Update selected_indices if there's room
196
+ if len(selected_indices) < 2:
197
+ selected_indices.append(existing_item_index)
198
+ else:
199
+ gr.Warning("You can select up to 2 LoRAs, remove one to select a new one.")
200
 
201
  # Update selected_info and images
202
+ selected_info_1 = "Select a LoRA 1"
203
+ selected_info_2 = "Select a LoRA 2"
204
+ lora_scale_1 = 1.15
205
+ lora_scale_2 = 1.15
206
+ lora_image_1 = None
207
+ lora_image_2 = None
208
+ if len(selected_indices) >= 1:
209
+ lora1 = current_loras[selected_indices[0]]
210
+ selected_info_1 = f"### LoRA 1 Selected: {lora1['title']} ✨"
211
+ lora_image_1 = lora1['image'] if lora1['image'] else None
212
+ if len(selected_indices) >= 2:
213
+ lora2 = current_loras[selected_indices[1]]
214
+ selected_info_2 = f"### LoRA 2 Selected: {lora2['title']} ✨"
215
+ lora_image_2 = lora2['image'] if lora2['image'] else None
 
 
 
216
  print("Finished adding custom LoRA")
217
  return (
218
  current_loras,
219
  gr.update(value=gallery_items),
220
+ selected_info_1,
221
+ selected_info_2,
222
  selected_indices,
223
+ lora_scale_1,
224
+ lora_scale_2,
225
+ lora_image_1,
226
+ lora_image_2
227
  )
228
  except Exception as e:
229
  print(e)
230
  gr.Warning(str(e))
231
+ return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
232
  else:
233
+ return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
234
+
235
+ def remove_custom_lora(selected_indices, current_loras, gallery):
236
+ if current_loras:
237
+ custom_lora_repo = current_loras[-1]['repo']
238
+ # Remove from loras list
239
+ current_loras = current_loras[:-1]
240
+ # Remove from selected_indices if selected
241
+ custom_lora_index = len(current_loras)
242
+ if custom_lora_index in selected_indices:
243
+ selected_indices.remove(custom_lora_index)
244
+ # Update gallery
245
+ gallery_items = [(item["image"], item["title"]) for item in current_loras]
246
+ # Update selected_info and images
247
+ selected_info_1 = "Select a LoRA 1"
248
+ selected_info_2 = "Select a LoRA 2"
249
+ lora_scale_1 = 1.15
250
+ lora_scale_2 = 1.15
251
+ lora_image_1 = None
252
+ lora_image_2 = None
253
+ if len(selected_indices) >= 1:
254
+ lora1 = current_loras[selected_indices[0]]
255
+ selected_info_1 = f"### LoRA 1 Selected: [{lora1['title']}]({lora1['repo']}) ✨"
256
+ lora_image_1 = lora1['image']
257
+ if len(selected_indices) >= 2:
258
+ lora2 = current_loras[selected_indices[1]]
259
+ selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}]({lora2['repo']}) ✨"
260
+ lora_image_2 = lora2['image']
261
+ return (
262
+ current_loras,
263
+ gr.update(value=gallery_items),
264
+ selected_info_1,
265
+ selected_info_2,
266
+ selected_indices,
267
+ lora_scale_1,
268
+ lora_scale_2,
269
+ lora_image_1,
270
+ lora_image_2
271
+ )
272
 
273
  def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
274
  print("Generating image...")
 
308
  return final_image
309
 
310
  @spaces.GPU(duration=75)
311
+ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_indices, lora_scale_1, lora_scale_2, randomize_seed, seed, width, height, loras_state, progress=gr.Progress(track_tqdm=True)):
312
  if not selected_indices:
313
  raise gr.Error("You must select at least one LoRA before proceeding.")
314
 
 
340
  lora_name = f"lora_{idx}"
341
  lora_names.append(lora_name)
342
  print(f"Lora Name: {lora_name}")
343
+ lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
344
  lora_path = lora['repo']
345
  weight_name = lora.get("weights")
346
  print(f"Lora Path: {lora_path}")
 
351
  low_cpu_mem_usage=True,
352
  adapter_name=lora_name
353
  )
354
+ # if image_input is not None: pipe_i2i = pipe_to_use
355
+ # else: pipe = pipe_to_use
356
  print("Loaded LoRAs:", lora_names)
357
  print("Adapter weights:", lora_weights)
358
  if image_input is not None:
 
473
  )
474
  loras_state = gr.State(loras)
475
  selected_indices = gr.State([])
 
476
  with gr.Row():
477
  with gr.Column(scale=3):
478
  prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
479
  with gr.Column(scale=1):
480
  generate_button = gr.Button("Generate", variant="primary", elem_classes=["button_total"])
481
  with gr.Row(elem_id="loaded_loras"):
482
+ with gr.Column(scale=1, min_width=25):
483
+ randomize_button = gr.Button("🎲", variant="secondary", scale=1, elem_id="random_btn")
484
+ with gr.Column(scale=8):
485
+ with gr.Row():
486
+ with gr.Column(scale=0, min_width=50):
487
+ lora_image_1 = gr.Image(label="LoRA 1 Image", interactive=False, min_width=50, width=50, show_label=False, show_share_button=False, show_download_button=False, show_fullscreen_button=False, height=50)
488
+ with gr.Column(scale=3, min_width=100):
489
+ selected_info_1 = gr.Markdown("Select a LoRA 1")
490
+ with gr.Column(scale=5, min_width=50):
491
+ lora_scale_1 = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
492
+ with gr.Row():
493
+ remove_button_1 = gr.Button("Remove", size="sm")
494
+ with gr.Column(scale=8):
495
+ with gr.Row():
496
+ with gr.Column(scale=0, min_width=50):
497
+ lora_image_2 = gr.Image(label="LoRA 2 Image", interactive=False, min_width=50, width=50, show_label=False, show_share_button=False, show_download_button=False, show_fullscreen_button=False, height=50)
498
+ with gr.Column(scale=3, min_width=100):
499
+ selected_info_2 = gr.Markdown("Select a LoRA 2")
500
+ with gr.Column(scale=5, min_width=50):
501
+ lora_scale_2 = gr.Slider(label="LoRA 2 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
502
+ with gr.Row():
503
+ remove_button_2 = gr.Button("Remove", size="sm")
504
  with gr.Row():
505
  with gr.Column():
506
  with gr.Group():
 
545
  gallery.select(
546
  update_selection,
547
  inputs=[selected_indices, loras_state, width, height],
548
+ outputs=[prompt, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, width, height, lora_image_1, lora_image_2])
549
+ remove_button_1.click(
550
+ remove_lora_1,
551
+ inputs=[selected_indices, loras_state],
552
+ outputs=[selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
553
  )
554
+ remove_button_2.click(
555
+ remove_lora_2,
556
+ inputs=[selected_indices, loras_state],
557
+ outputs=[selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
558
  )
 
 
 
 
 
 
559
  randomize_button.click(
560
  randomize_loras,
561
  inputs=[selected_indices, loras_state],
562
+ outputs=[selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2, prompt]
563
  )
564
  add_custom_lora_button.click(
565
  add_custom_lora,
566
  inputs=[custom_lora, selected_indices, loras_state, gallery],
567
+ outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
568
+ )
569
+ remove_custom_lora_button.click(
570
+ remove_custom_lora,
571
+ inputs=[selected_indices, loras_state, gallery],
572
+ outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
573
  )
574
  gr.on(
575
  triggers=[generate_button.click, prompt.submit],
576
  fn=run_lora,
577
+ inputs=[prompt, input_image, image_strength, cfg_scale, steps, selected_indices, lora_scale_1, lora_scale_2, randomize_seed, seed, width, height, loras_state],
578
  outputs=[result, seed, progress_bar]
579
  ).then(
580
  fn=lambda x, history: update_history(x, history),
 
583
  )
584
 
585
  app.queue()
586
+ app.launch()