Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import os
|
|
7 |
import spaces
|
8 |
import random
|
9 |
|
|
|
10 |
hf_token = os.environ.get("HF_TOKEN")
|
11 |
login(token = hf_token)
|
12 |
|
@@ -70,13 +71,52 @@ def infer(lora_1_id, lora_1_sfts, lora_2_id, lora_2_sfts, prompt, negative_promp
|
|
70 |
|
71 |
css="""
|
72 |
#col-container{
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
"""
|
76 |
|
77 |
with gr.Blocks(css=css) as demo:
|
78 |
with gr.Column(elem_id="col-container"):
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
title = gr.HTML(
|
81 |
'''
|
82 |
<h1 style="text-align: center;">LoRA Fusion</h1>
|
|
|
7 |
import spaces
|
8 |
import random
|
9 |
|
10 |
+
is_shared_ui = True if "fffiloni/sd-xl-lora-fusion" in os.environ['SPACE_ID'] else False
|
11 |
hf_token = os.environ.get("HF_TOKEN")
|
12 |
login(token = hf_token)
|
13 |
|
|
|
71 |
|
72 |
css="""
|
73 |
#col-container{
|
74 |
+
margin: 0 auto;
|
75 |
+
max-width: 680px;
|
76 |
+
text-align: left;
|
77 |
+
}
|
78 |
+
div#warning-duplicate {
|
79 |
+
background-color: #ebf5ff;
|
80 |
+
padding: 0 10px 5px;
|
81 |
+
margin: 20px 0;
|
82 |
+
}
|
83 |
+
div#warning-duplicate > .gr-prose > h2, div#warning-duplicate > .gr-prose > p {
|
84 |
+
color: #0f4592!important;
|
85 |
+
}
|
86 |
+
div#warning-duplicate strong {
|
87 |
+
color: #0f4592;
|
88 |
+
}
|
89 |
+
p.actions {
|
90 |
+
display: flex;
|
91 |
+
align-items: center;
|
92 |
+
margin: 20px 0;
|
93 |
+
}
|
94 |
+
div#warning-duplicate .actions a {
|
95 |
+
display: inline-block;
|
96 |
+
margin-right: 10px;
|
97 |
+
}
|
98 |
"""
|
99 |
|
100 |
with gr.Blocks(css=css) as demo:
|
101 |
with gr.Column(elem_id="col-container"):
|
102 |
|
103 |
+
if is_shared_ui:
|
104 |
+
top_description = gr.HTML(f'''
|
105 |
+
<div class="gr-prose">
|
106 |
+
<h2><svg xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" style="margin-right: 0px;display: inline-block;"fill="none"><path fill="#fff" d="M7 13.2a6.3 6.3 0 0 0 4.4-10.7A6.3 6.3 0 0 0 .6 6.9 6.3 6.3 0 0 0 7 13.2Z"/><path fill="#fff" fill-rule="evenodd" d="M7 0a6.9 6.9 0 0 1 4.8 11.8A6.9 6.9 0 0 1 0 7 6.9 6.9 0 0 1 7 0Zm0 0v.7V0ZM0 7h.6H0Zm7 6.8v-.6.6ZM13.7 7h-.6.6ZM9.1 1.7c-.7-.3-1.4-.4-2.2-.4a5.6 5.6 0 0 0-4 1.6 5.6 5.6 0 0 0-1.6 4 5.6 5.6 0 0 0 1.6 4 5.6 5.6 0 0 0 4 1.7 5.6 5.6 0 0 0 4-1.7 5.6 5.6 0 0 0 1.7-4 5.6 5.6 0 0 0-1.7-4c-.5-.5-1.1-.9-1.8-1.2Z" clip-rule="evenodd"/><path fill="#000" fill-rule="evenodd" d="M7 2.9a.8.8 0 1 1 0 1.5A.8.8 0 0 1 7 3ZM5.8 5.7c0-.4.3-.6.6-.6h.7c.3 0 .6.2.6.6v3.7h.5a.6.6 0 0 1 0 1.3H6a.6.6 0 0 1 0-1.3h.4v-3a.6.6 0 0 1-.6-.7Z" clip-rule="evenodd"/></svg>
|
107 |
+
Note: you might want to use private custom LoRa models</h2>
|
108 |
+
<p class="main-message">
|
109 |
+
To do so, <strong>duplicate the Space</strong> and run it on your own profile using <strong>your own access token</strong> and eventually a GPU (T4-small or A10G-small) for faster inference without waiting in the queue.<br />
|
110 |
+
</p>
|
111 |
+
<p class="actions">
|
112 |
+
<a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}?duplicate=true">
|
113 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg-dark.svg" alt="Duplicate this Space" />
|
114 |
+
</a>
|
115 |
+
to start using private models and skip the queue
|
116 |
+
</p>
|
117 |
+
</div>
|
118 |
+
''', elem_id="warning-duplicate")
|
119 |
+
|
120 |
title = gr.HTML(
|
121 |
'''
|
122 |
<h1 style="text-align: center;">LoRA Fusion</h1>
|