Spaces:
Runtime error
Runtime error
Commit
•
9155e06
1
Parent(s):
8612be0
Update app.py
Browse files
app.py
CHANGED
@@ -119,13 +119,17 @@ def shuffle_images():
|
|
119 |
repo_id_2 = gr.update(value=two_shuffled_items[1]['repo'])
|
120 |
description_1, trigger_word_1 = get_description(two_shuffled_items[0])
|
121 |
description_2, trigger_word_2 = get_description(two_shuffled_items[1])
|
122 |
-
|
|
|
|
|
123 |
prompt_description_1 = gr.update(value=description_1, visible=True)
|
124 |
prompt_description_2 = gr.update(value=description_2, visible=True)
|
125 |
prompt = gr.update(value=f"{trigger_word_1} {trigger_word_2}")
|
126 |
scale = gr.update(value=0.7)
|
|
|
|
|
127 |
|
128 |
-
return title_1, prompt_description_1, repo_id_1, title_2, prompt_description_2, repo_id_2, prompt, two_shuffled_items, scale, scale
|
129 |
|
130 |
def save_preferences(lora_1_id, lora_1_scale, lora_2_id, lora_2_scale, prompt, generated_image, thumbs_direction, seed):
|
131 |
image_path = IMAGE_DATASET_DIR / f"{uuid4()}.png"
|
@@ -149,13 +153,15 @@ with gr.Blocks(css=css) as demo:
|
|
149 |
with gr.Column(min_width=10, scale=16, elem_classes="plus_column"):
|
150 |
with gr.Row():
|
151 |
with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
|
152 |
-
|
|
|
153 |
lora_1_id = gr.Textbox(visible=False, elem_id="random_lora_1_id")
|
154 |
lora_1_prompt = gr.Markdown(visible=False)
|
155 |
with gr.Column(min_width=10, scale=1, elem_classes="plus_column"):
|
156 |
plus = gr.HTML("+", elem_classes="plus_button")
|
157 |
with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
|
158 |
-
|
|
|
159 |
lora_2_id = gr.Textbox(visible=False, elem_id="random_lora_2_id")
|
160 |
lora_2_prompt = gr.Markdown(visible=False)
|
161 |
with gr.Column(min_width=10, scale=2, elem_classes="plus_column"):
|
@@ -186,9 +192,10 @@ with gr.Blocks(css=css) as demo:
|
|
186 |
lora_1_scale = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=1, step=0.1, value=0.7)
|
187 |
lora_2_scale = gr.Slider(label="LoRa 2 Scale", minimum=0, maximum=1, step=0.1, value=0.7)
|
188 |
shuffle_button = gr.Button("Reshuffle!")
|
|
|
189 |
|
190 |
-
demo.load(shuffle_images, inputs=[], outputs=[lora_1, lora_1_prompt, lora_1_id, lora_2, lora_2_prompt, lora_2_id, prompt, shuffled_items, lora_1_scale, lora_2_scale], queue=False, show_progress="hidden")
|
191 |
-
shuffle_button.click(shuffle_images, outputs=[lora_1, lora_1_prompt, lora_1_id, lora_2, lora_2_prompt, lora_2_id, prompt, shuffled_items, lora_1_scale, lora_2_scale], queue=False, show_progress="hidden")
|
192 |
|
193 |
run_btn.click(merge_and_run, inputs=[prompt, negative_prompt, shuffled_items, lora_1_scale, lora_2_scale, seed], outputs=[output_image, post_gen_info, last_used_seed])
|
194 |
prompt.submit(merge_and_run, inputs=[prompt, negative_prompt, shuffled_items, lora_1_scale, lora_2_scale, seed], outputs=[output_image, post_gen_info, last_used_seed])
|
|
|
119 |
repo_id_2 = gr.update(value=two_shuffled_items[1]['repo'])
|
120 |
description_1, trigger_word_1 = get_description(two_shuffled_items[0])
|
121 |
description_2, trigger_word_2 = get_description(two_shuffled_items[1])
|
122 |
+
|
123 |
+
lora_1_link = f"[{repo_id_1}](https://huggingface.co/{repo_id_1}) ✨"
|
124 |
+
lora_2_link = f"[{repo_id_2}](https://huggingface.co/{repo_id_2}) ✨"
|
125 |
prompt_description_1 = gr.update(value=description_1, visible=True)
|
126 |
prompt_description_2 = gr.update(value=description_2, visible=True)
|
127 |
prompt = gr.update(value=f"{trigger_word_1} {trigger_word_2}")
|
128 |
scale = gr.update(value=0.7)
|
129 |
+
|
130 |
+
|
131 |
|
132 |
+
return lora_link_1, title_1, prompt_description_1, repo_id_1, lora_link_2, title_2, prompt_description_2, repo_id_2, prompt, two_shuffled_items, scale, scale
|
133 |
|
134 |
def save_preferences(lora_1_id, lora_1_scale, lora_2_id, lora_2_scale, prompt, generated_image, thumbs_direction, seed):
|
135 |
image_path = IMAGE_DATASET_DIR / f"{uuid4()}.png"
|
|
|
153 |
with gr.Column(min_width=10, scale=16, elem_classes="plus_column"):
|
154 |
with gr.Row():
|
155 |
with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
|
156 |
+
lora_1_link = gr.Markdown()
|
157 |
+
lora_1 = gr.Image(interactive=False, show_label=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_1", show_share_button=False, show_download_button=False)
|
158 |
lora_1_id = gr.Textbox(visible=False, elem_id="random_lora_1_id")
|
159 |
lora_1_prompt = gr.Markdown(visible=False)
|
160 |
with gr.Column(min_width=10, scale=1, elem_classes="plus_column"):
|
161 |
plus = gr.HTML("+", elem_classes="plus_button")
|
162 |
with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
|
163 |
+
lora_2_link = gr.Markdown()
|
164 |
+
lora_2 = gr.Image(interactive=False, show_label=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_2", show_share_button=False, show_download_button=False)
|
165 |
lora_2_id = gr.Textbox(visible=False, elem_id="random_lora_2_id")
|
166 |
lora_2_prompt = gr.Markdown(visible=False)
|
167 |
with gr.Column(min_width=10, scale=2, elem_classes="plus_column"):
|
|
|
192 |
lora_1_scale = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=1, step=0.1, value=0.7)
|
193 |
lora_2_scale = gr.Slider(label="LoRa 2 Scale", minimum=0, maximum=1, step=0.1, value=0.7)
|
194 |
shuffle_button = gr.Button("Reshuffle!")
|
195 |
+
gr.Markdown("For generating with intent visit the [LoRA the Explorer Space](https://huggingface.co/spaces/multimodalart/LoraTheExplorer), but don't forget that sometimes restirctions flourish creativity 🌸")
|
196 |
|
197 |
+
demo.load(shuffle_images, inputs=[], outputs=[lora_1_link, lora_1, lora_1_prompt, lora_1_id, lora_2_link, lora_2, lora_2_prompt, lora_2_id, prompt, shuffled_items, lora_1_scale, lora_2_scale], queue=False, show_progress="hidden")
|
198 |
+
shuffle_button.click(shuffle_images, outputs=[lora_1_link, lora_1, lora_1_prompt, lora_1_id, lora_2_link, lora_2, lora_2_prompt, lora_2_id, prompt, shuffled_items, lora_1_scale, lora_2_scale], queue=False, show_progress="hidden")
|
199 |
|
200 |
run_btn.click(merge_and_run, inputs=[prompt, negative_prompt, shuffled_items, lora_1_scale, lora_2_scale, seed], outputs=[output_image, post_gen_info, last_used_seed])
|
201 |
prompt.submit(merge_and_run, inputs=[prompt, negative_prompt, shuffled_items, lora_1_scale, lora_2_scale, seed], outputs=[output_image, post_gen_info, last_used_seed])
|