Spaces:
Running
Running
Charbel Malo
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ import time
|
|
15 |
import requests
|
16 |
import pandas as pd
|
17 |
|
18 |
-
#
|
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
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
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 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
lora_scales.append(lora_scale)
|
177 |
-
lora_images.append(lora_image)
|
178 |
random_prompt = random.choice(prompt_values)
|
179 |
-
|
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
|
|
|
|
|
|
|
211 |
|
212 |
# Update selected_info and images
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
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 |
-
|
|
|
235 |
selected_indices,
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
)
|
241 |
except Exception as e:
|
242 |
print(e)
|
243 |
gr.Warning(str(e))
|
244 |
-
return current_loras, gr.update(),
|
245 |
else:
|
246 |
-
return current_loras, gr.update(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
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(
|
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 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
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,
|
|
|
|
|
|
|
|
|
522 |
)
|
523 |
-
|
524 |
-
|
525 |
-
inputs=[
|
526 |
-
outputs=[
|
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=[
|
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,
|
|
|
|
|
|
|
|
|
|
|
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,
|
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()
|