Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ import os
|
|
8 |
import spaces
|
9 |
import random
|
10 |
|
|
|
|
|
11 |
is_shared_ui = True if "fffiloni/sd-xl-lora-fusion" in os.environ['SPACE_ID'] else False
|
12 |
hf_token = os.environ.get("HF_TOKEN")
|
13 |
login(token = hf_token)
|
@@ -75,7 +77,7 @@ def load_sfts(repo_1_id, repo_2_id):
|
|
75 |
return gr.update(choices=sfts_available_files_1, value=sfts_available_files_1[0], visible=True), gr.update(choices=sfts_available_files_2, value=sfts_available_files_2[0], visible=True), gr.update(value=instance_prompt_1, visible=True), gr.update(value=instance_prompt_2, visible=True)
|
76 |
|
77 |
@spaces.GPU
|
78 |
-
def infer(lora_1_id, lora_1_sfts, lora_2_id, lora_2_sfts, prompt, negative_prompt, lora_1_scale, lora_2_scale, seed):
|
79 |
|
80 |
unet = copy.deepcopy(original_pipe.unet)
|
81 |
text_encoder = copy.deepcopy(original_pipe.text_encoder)
|
@@ -148,7 +150,18 @@ def infer(lora_1_id, lora_1_sfts, lora_2_id, lora_2_sfts, prompt, negative_promp
|
|
148 |
).images[0]
|
149 |
|
150 |
pipe.unfuse_lora()
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
return image, seed
|
153 |
|
154 |
css="""
|
@@ -290,6 +303,9 @@ with gr.Blocks(css=css) as demo:
|
|
290 |
label = "Output"
|
291 |
)
|
292 |
|
|
|
|
|
|
|
293 |
# Advanced Settings
|
294 |
with gr.Accordion("Advanced Settings", open=False):
|
295 |
|
|
|
8 |
import spaces
|
9 |
import random
|
10 |
|
11 |
+
import user_history
|
12 |
+
|
13 |
is_shared_ui = True if "fffiloni/sd-xl-lora-fusion" in os.environ['SPACE_ID'] else False
|
14 |
hf_token = os.environ.get("HF_TOKEN")
|
15 |
login(token = hf_token)
|
|
|
77 |
return gr.update(choices=sfts_available_files_1, value=sfts_available_files_1[0], visible=True), gr.update(choices=sfts_available_files_2, value=sfts_available_files_2[0], visible=True), gr.update(value=instance_prompt_1, visible=True), gr.update(value=instance_prompt_2, visible=True)
|
78 |
|
79 |
@spaces.GPU
|
80 |
+
def infer(lora_1_id, lora_1_sfts, lora_2_id, lora_2_sfts, prompt, negative_prompt, lora_1_scale, lora_2_scale, seed, profile: gr.OAuthProfile | None):
|
81 |
|
82 |
unet = copy.deepcopy(original_pipe.unet)
|
83 |
text_encoder = copy.deepcopy(original_pipe.text_encoder)
|
|
|
150 |
).images[0]
|
151 |
|
152 |
pipe.unfuse_lora()
|
153 |
+
|
154 |
+
# save generated images (if logged in)
|
155 |
+
user_history.save_image(label=prompt, image=image, profile=profile, metadata={
|
156 |
+
"prompt": prompt,
|
157 |
+
"negative_prompt": negative_prompt,
|
158 |
+
"lora_1_repo_id": lora_1_id,
|
159 |
+
"lora_2_repo_id": lora_2_id,
|
160 |
+
"lora_1_scale": lora_1_scale,
|
161 |
+
"lora_2_scale": lora_2_scale,
|
162 |
+
"seed": seed,
|
163 |
+
})
|
164 |
+
|
165 |
return image, seed
|
166 |
|
167 |
css="""
|
|
|
303 |
label = "Output"
|
304 |
)
|
305 |
|
306 |
+
with gr.Accordion("Past generations", open=False):
|
307 |
+
user_history.render()
|
308 |
+
|
309 |
# Advanced Settings
|
310 |
with gr.Accordion("Advanced Settings", open=False):
|
311 |
|