Spaces:
Running
on
Zero
Running
on
Zero
adamelliotfields
commited on
Commit
•
b7c0c19
1
Parent(s):
9d8b222
Menu improvements
Browse files
app.css
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
.accordion {
|
2 |
--block-border-width: 0px;
|
3 |
background-color: transparent;
|
|
|
4 |
}
|
5 |
.accordion > button {
|
|
|
6 |
justify-content: flex-start;
|
7 |
color: var(--body-text-color-subdued);
|
8 |
}
|
@@ -13,9 +15,6 @@
|
|
13 |
width: auto;
|
14 |
margin-right: 4px;
|
15 |
}
|
16 |
-
.accordion .tabs {
|
17 |
-
margin-top: 8px;
|
18 |
-
}
|
19 |
.accordion .tabitem > div {
|
20 |
--block-border-width: 1px;
|
21 |
}
|
@@ -39,16 +38,6 @@
|
|
39 |
max-height: none;
|
40 |
}
|
41 |
}
|
42 |
-
@media (min-width: 768px) {
|
43 |
-
.gallery, .gallery > .grid-wrap {
|
44 |
-
height: 702px;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
@media (min-width: 1024px) {
|
48 |
-
.gallery, .gallery > .grid-wrap{
|
49 |
-
height: 894px;
|
50 |
-
}
|
51 |
-
}
|
52 |
|
53 |
.icon-button {
|
54 |
max-width: 42px;
|
@@ -73,7 +62,8 @@
|
|
73 |
content: 'Clear gallery';
|
74 |
}
|
75 |
.icon-button#random:hover::after {
|
76 |
-
|
|
|
77 |
}
|
78 |
|
79 |
#intro {
|
@@ -109,11 +99,16 @@
|
|
109 |
border-width: 0px;
|
110 |
}
|
111 |
.tabitem {
|
112 |
-
max-height:
|
|
|
113 |
overflow-y: auto;
|
|
|
114 |
}
|
115 |
.tabitem .markdown {
|
116 |
-
|
|
|
|
|
|
|
117 |
}
|
118 |
.tab-nav > button {
|
119 |
padding-bottom: 8px;
|
|
|
1 |
.accordion {
|
2 |
--block-border-width: 0px;
|
3 |
background-color: transparent;
|
4 |
+
padding: 0px;
|
5 |
}
|
6 |
.accordion > button {
|
7 |
+
margin-bottom: 16px;
|
8 |
justify-content: flex-start;
|
9 |
color: var(--body-text-color-subdued);
|
10 |
}
|
|
|
15 |
width: auto;
|
16 |
margin-right: 4px;
|
17 |
}
|
|
|
|
|
|
|
18 |
.accordion .tabitem > div {
|
19 |
--block-border-width: 1px;
|
20 |
}
|
|
|
38 |
max-height: none;
|
39 |
}
|
40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
.icon-button {
|
43 |
max-width: 42px;
|
|
|
62 |
content: 'Clear gallery';
|
63 |
}
|
64 |
.icon-button#random:hover::after {
|
65 |
+
/* set seed via JS */
|
66 |
+
content: var(--seed, "0");
|
67 |
}
|
68 |
|
69 |
#intro {
|
|
|
99 |
border-width: 0px;
|
100 |
}
|
101 |
.tabitem {
|
102 |
+
max-height: 488px;
|
103 |
+
overflow-x: hidden;
|
104 |
overflow-y: auto;
|
105 |
+
padding: 0 0 8px;
|
106 |
}
|
107 |
.tabitem .markdown {
|
108 |
+
padding-left: 12px;
|
109 |
+
}
|
110 |
+
.tab-nav {
|
111 |
+
margin-bottom: 16px;
|
112 |
}
|
113 |
.tab-nav > button {
|
114 |
padding-bottom: 8px;
|
app.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
() =>{
|
2 |
-
const header = document.querySelector("#intro");
|
3 |
const menu = document.querySelector("#menu");
|
4 |
const menuButton = menu.querySelector("button");
|
5 |
const menuSpan = menuButton.querySelector("span:first-child");
|
@@ -7,12 +6,6 @@
|
|
7 |
const updateMenuText = () => {
|
8 |
const isOpen = menuButton.classList.contains("open");
|
9 |
menuSpan.textContent = isOpen ? "Close menu" : "Open menu";
|
10 |
-
|
11 |
-
if (isOpen) {
|
12 |
-
menu.scrollIntoView({ behavior: "instant" });
|
13 |
-
} else {
|
14 |
-
header.scrollIntoView({ behavior: "instant" });
|
15 |
-
}
|
16 |
};
|
17 |
|
18 |
const observer = new MutationObserver(updateMenuText);
|
|
|
1 |
() =>{
|
|
|
2 |
const menu = document.querySelector("#menu");
|
3 |
const menuButton = menu.querySelector("button");
|
4 |
const menuSpan = menuButton.querySelector("span:first-child");
|
|
|
6 |
const updateMenuText = () => {
|
7 |
const isOpen = menuButton.classList.contains("open");
|
8 |
menuSpan.textContent = isOpen ? "Close menu" : "Open menu";
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
};
|
10 |
|
11 |
const observer = new MutationObserver(updateMenuText);
|
app.py
CHANGED
@@ -14,6 +14,18 @@ SANS_FONTS = [
|
|
14 |
"Noto Color Emoji",
|
15 |
]
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def read_file(path: str) -> str:
|
19 |
with open(path, "r", encoding="utf-8") as file:
|
@@ -57,44 +69,6 @@ with gr.Blocks(
|
|
57 |
) as demo:
|
58 |
gr.HTML(read_file("./partials/intro.html"))
|
59 |
|
60 |
-
with gr.Group():
|
61 |
-
output_images = gr.Gallery(
|
62 |
-
elem_classes=["gallery"],
|
63 |
-
show_share_button=False,
|
64 |
-
interactive=False,
|
65 |
-
show_label=False,
|
66 |
-
label="Output",
|
67 |
-
format="png",
|
68 |
-
columns=2,
|
69 |
-
)
|
70 |
-
prompt = gr.Textbox(
|
71 |
-
placeholder="corgi, at the beach, cute, 8k",
|
72 |
-
show_label=False,
|
73 |
-
label="Prompt",
|
74 |
-
value=None,
|
75 |
-
lines=2,
|
76 |
-
)
|
77 |
-
|
78 |
-
with gr.Row():
|
79 |
-
generate_btn = gr.Button("Generate", variant="primary", scale=6, elem_classes=[])
|
80 |
-
random_btn = gr.Button(
|
81 |
-
elem_classes=["icon-button"],
|
82 |
-
variant="secondary",
|
83 |
-
elem_id="random",
|
84 |
-
min_width=0,
|
85 |
-
value="🎲",
|
86 |
-
scale=1,
|
87 |
-
)
|
88 |
-
clear_btn = gr.ClearButton(
|
89 |
-
elem_classes=["icon-button"],
|
90 |
-
components=[output_images],
|
91 |
-
variant="secondary",
|
92 |
-
elem_id="clear",
|
93 |
-
min_width=0,
|
94 |
-
value="🗑️",
|
95 |
-
scale=1,
|
96 |
-
)
|
97 |
-
|
98 |
with gr.Accordion(
|
99 |
elem_classes=["accordion"],
|
100 |
elem_id="menu",
|
@@ -155,6 +129,7 @@ with gr.Blocks(
|
|
155 |
with gr.Row():
|
156 |
model = gr.Dropdown(
|
157 |
value="Lykon/dreamshaper-8",
|
|
|
158 |
label="Model",
|
159 |
scale=2,
|
160 |
choices=[
|
@@ -170,6 +145,7 @@ with gr.Blocks(
|
|
170 |
elem_id="scheduler",
|
171 |
label="Scheduler",
|
172 |
value="DEIS 2M",
|
|
|
173 |
scale=2,
|
174 |
choices=[
|
175 |
"DEIS 2M",
|
@@ -181,7 +157,7 @@ with gr.Blocks(
|
|
181 |
"PNDM",
|
182 |
],
|
183 |
)
|
184 |
-
seed = gr.Number(label="Seed", value=
|
185 |
|
186 |
with gr.Row():
|
187 |
use_karras = gr.Checkbox(
|
@@ -245,8 +221,47 @@ with gr.Blocks(
|
|
245 |
with gr.TabItem("ℹ️ Info"):
|
246 |
gr.Markdown(read_file("info.md"), elem_classes=["markdown"])
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
# update the random seed using JavaScript
|
249 |
-
random_btn.click(None, outputs=[seed], js=
|
250 |
|
251 |
# ensure correct argument order
|
252 |
generate_btn.click(
|
@@ -278,8 +293,6 @@ with gr.Blocks(
|
|
278 |
|
279 |
# https://www.gradio.app/docs/gradio/interface#interface-queue
|
280 |
demo.queue().launch(
|
281 |
-
|
282 |
-
|
283 |
-
"server_port": 7860,
|
284 |
-
}
|
285 |
)
|
|
|
14 |
"Noto Color Emoji",
|
15 |
]
|
16 |
|
17 |
+
# random seed JS
|
18 |
+
# display the seed as hover text
|
19 |
+
# note that the CSS `content` attribute expects a string so we need to wrap the number in quotes
|
20 |
+
SEED_JS = """
|
21 |
+
() => {
|
22 |
+
const n = Math.floor(Math.random() * 2**32);
|
23 |
+
const button = document.getElementById("random");
|
24 |
+
button.style.setProperty("--seed", `"${n}"`);
|
25 |
+
return n;
|
26 |
+
}
|
27 |
+
"""
|
28 |
+
|
29 |
|
30 |
def read_file(path: str) -> str:
|
31 |
with open(path, "r", encoding="utf-8") as file:
|
|
|
69 |
) as demo:
|
70 |
gr.HTML(read_file("./partials/intro.html"))
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
with gr.Accordion(
|
73 |
elem_classes=["accordion"],
|
74 |
elem_id="menu",
|
|
|
129 |
with gr.Row():
|
130 |
model = gr.Dropdown(
|
131 |
value="Lykon/dreamshaper-8",
|
132 |
+
min_width=200,
|
133 |
label="Model",
|
134 |
scale=2,
|
135 |
choices=[
|
|
|
145 |
elem_id="scheduler",
|
146 |
label="Scheduler",
|
147 |
value="DEIS 2M",
|
148 |
+
min_width=200,
|
149 |
scale=2,
|
150 |
choices=[
|
151 |
"DEIS 2M",
|
|
|
157 |
"PNDM",
|
158 |
],
|
159 |
)
|
160 |
+
seed = gr.Number(label="Seed", value=0, scale=1)
|
161 |
|
162 |
with gr.Row():
|
163 |
use_karras = gr.Checkbox(
|
|
|
221 |
with gr.TabItem("ℹ️ Info"):
|
222 |
gr.Markdown(read_file("info.md"), elem_classes=["markdown"])
|
223 |
|
224 |
+
with gr.Group():
|
225 |
+
output_images = gr.Gallery(
|
226 |
+
elem_classes=["gallery"],
|
227 |
+
show_share_button=False,
|
228 |
+
interactive=False,
|
229 |
+
show_label=False,
|
230 |
+
object_fit="cover",
|
231 |
+
label="Output",
|
232 |
+
format="png",
|
233 |
+
columns=2,
|
234 |
+
)
|
235 |
+
prompt = gr.Textbox(
|
236 |
+
placeholder="corgi, at the beach, cute, 8k",
|
237 |
+
show_label=False,
|
238 |
+
label="Prompt",
|
239 |
+
value=None,
|
240 |
+
lines=2,
|
241 |
+
)
|
242 |
+
|
243 |
+
with gr.Row():
|
244 |
+
generate_btn = gr.Button("Generate", variant="primary", scale=6, elem_classes=[])
|
245 |
+
random_btn = gr.Button(
|
246 |
+
elem_classes=["icon-button"],
|
247 |
+
variant="secondary",
|
248 |
+
elem_id="random",
|
249 |
+
min_width=0,
|
250 |
+
value="🎲",
|
251 |
+
scale=1,
|
252 |
+
)
|
253 |
+
clear_btn = gr.ClearButton(
|
254 |
+
elem_classes=["icon-button"],
|
255 |
+
components=[output_images],
|
256 |
+
variant="secondary",
|
257 |
+
elem_id="clear",
|
258 |
+
min_width=0,
|
259 |
+
value="🗑️",
|
260 |
+
scale=1,
|
261 |
+
)
|
262 |
+
|
263 |
# update the random seed using JavaScript
|
264 |
+
random_btn.click(None, outputs=[seed], js=SEED_JS)
|
265 |
|
266 |
# ensure correct argument order
|
267 |
generate_btn.click(
|
|
|
293 |
|
294 |
# https://www.gradio.app/docs/gradio/interface#interface-queue
|
295 |
demo.queue().launch(
|
296 |
+
server_name="0.0.0.0",
|
297 |
+
server_port=7860,
|
|
|
|
|
298 |
)
|