Spaces:
Running
on
Zero
Running
on
Zero
Style adjustments
Browse files
demo.css
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
.accordion {
|
|
|
2 |
background-color: transparent;
|
3 |
}
|
4 |
.accordion > button {
|
@@ -8,37 +9,46 @@
|
|
8 |
width: auto;
|
9 |
margin-right: 4px;
|
10 |
}
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
}
|
15 |
|
16 |
.tabs, .tabitem, .tab-nav, .tab-nav > .selected {
|
17 |
border-width: 0px;
|
18 |
}
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
#gallery {
|
25 |
-
|
26 |
-
|
27 |
-
#gallery > div:nth-child(2) {
|
28 |
-
overflow-y: hidden;
|
29 |
-
}
|
30 |
-
.dark #gallery {
|
31 |
-
background-color: var(--background-fill-primary);
|
32 |
}
|
33 |
|
34 |
#intro {
|
35 |
display: flex;
|
36 |
align-items: center;
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
#intro > svg {
|
39 |
display: inline-block;
|
40 |
-
width: 1.
|
41 |
-
height: 1.
|
|
|
42 |
margin-left: 0.5rem;
|
43 |
fill: #047857 !important;
|
44 |
animation: spin 3s linear infinite reverse;
|
@@ -49,18 +59,3 @@
|
|
49 |
@keyframes spin {
|
50 |
100% { transform: rotate(360deg); }
|
51 |
}
|
52 |
-
|
53 |
-
#menu-tabs {
|
54 |
-
margin-top: 12px;
|
55 |
-
}
|
56 |
-
|
57 |
-
#prompt {
|
58 |
-
background-color: var(--bg);
|
59 |
-
}
|
60 |
-
.dark #prompt {
|
61 |
-
background-color: var(--background-fill-primary);
|
62 |
-
}
|
63 |
-
|
64 |
-
#random-seed > button {
|
65 |
-
margin-right: 8px;
|
66 |
-
}
|
|
|
1 |
.accordion {
|
2 |
+
--block-border-width: 0px;
|
3 |
background-color: transparent;
|
4 |
}
|
5 |
.accordion > button {
|
|
|
9 |
width: auto;
|
10 |
margin-right: 4px;
|
11 |
}
|
12 |
+
.accordion .tabs {
|
13 |
+
margin-top: 12px;
|
14 |
+
}
|
15 |
+
.accordion .tabitem > div {
|
16 |
+
--block-border-width: 1px;
|
17 |
}
|
18 |
|
19 |
.tabs, .tabitem, .tab-nav, .tab-nav > .selected {
|
20 |
border-width: 0px;
|
21 |
}
|
22 |
+
.tabitem {
|
23 |
+
max-height: 600px;
|
24 |
+
overflow-y: auto;
|
25 |
+
}
|
26 |
+
.tabitem .markdown {
|
27 |
+
margin-top: 4px;
|
28 |
+
margin-left: 8px;
|
29 |
}
|
30 |
|
31 |
#gallery {
|
32 |
+
--block-border-width: 0px;
|
33 |
+
background-color: transparent;
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
#intro {
|
37 |
display: flex;
|
38 |
align-items: center;
|
39 |
}
|
40 |
+
#intro > h1 > span {
|
41 |
+
color: #047857 !important;
|
42 |
+
font-style: italic;
|
43 |
+
}
|
44 |
+
#intro > h1 > span:is(.dark *) {
|
45 |
+
color: #10b981 !important;
|
46 |
+
}
|
47 |
#intro > svg {
|
48 |
display: inline-block;
|
49 |
+
width: 1.5rem;
|
50 |
+
height: 1.5rem;
|
51 |
+
margin-top: 0.25rem;
|
52 |
margin-left: 0.5rem;
|
53 |
fill: #047857 !important;
|
54 |
animation: spin 3s linear infinite reverse;
|
|
|
59 |
@keyframes spin {
|
60 |
100% { transform: rotate(360deg); }
|
61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
demo.py
CHANGED
@@ -34,7 +34,7 @@ def generate_btn_click(*args, **kwargs):
|
|
34 |
if prompt is None or prompt.strip() == "":
|
35 |
raise gr.Error("You must enter a prompt")
|
36 |
|
37 |
-
images = generate(*args, **kwargs)
|
38 |
end = time.perf_counter()
|
39 |
diff = end - start
|
40 |
gr.Info(f"Generated {len(images)} images in {diff:.2f}s")
|
@@ -42,6 +42,7 @@ def generate_btn_click(*args, **kwargs):
|
|
42 |
|
43 |
|
44 |
with gr.Blocks(
|
|
|
45 |
css="./demo.css",
|
46 |
js="./demo.js",
|
47 |
theme=gr.themes.Default(
|
@@ -59,22 +60,17 @@ with gr.Blocks(
|
|
59 |
).set(
|
60 |
block_background_fill=gr.themes.colors.gray.c50,
|
61 |
block_background_fill_dark=gr.themes.colors.gray.c900,
|
62 |
-
block_border_width="0px",
|
63 |
-
block_border_width_dark="0px",
|
64 |
block_shadow="0 0 #0000",
|
65 |
block_shadow_dark="0 0 #0000",
|
66 |
-
block_title_text_weight=500,
|
67 |
-
form_gap_width="0px",
|
68 |
-
section_header_text_weight=500,
|
69 |
),
|
70 |
) as demo:
|
71 |
gr.HTML(read_file("intro.html"))
|
72 |
output_images = gr.Gallery(
|
73 |
-
height=320,
|
74 |
label="Output",
|
75 |
show_label=False,
|
76 |
-
columns=
|
77 |
interactive=False,
|
|
|
78 |
elem_id="gallery",
|
79 |
)
|
80 |
prompt = gr.Textbox(
|
@@ -83,7 +79,6 @@ with gr.Blocks(
|
|
83 |
lines=2,
|
84 |
placeholder="corgi, at the beach, cute",
|
85 |
value=None,
|
86 |
-
elem_id="prompt",
|
87 |
)
|
88 |
generate_btn = gr.Button("Generate", variant="primary", elem_classes=[])
|
89 |
|
@@ -93,7 +88,7 @@ with gr.Blocks(
|
|
93 |
elem_id="menu",
|
94 |
elem_classes=["accordion"],
|
95 |
):
|
96 |
-
with gr.Tabs(
|
97 |
with gr.TabItem("⚙️ Settings"):
|
98 |
with gr.Group():
|
99 |
negative_prompt = gr.Textbox(
|
@@ -116,6 +111,7 @@ with gr.Blocks(
|
|
116 |
value="1:1",
|
117 |
filterable=False,
|
118 |
)
|
|
|
119 |
|
120 |
with gr.Row():
|
121 |
guidance_scale = gr.Slider(
|
@@ -123,7 +119,7 @@ with gr.Blocks(
|
|
123 |
minimum=1.0,
|
124 |
maximum=15.0,
|
125 |
step=0.1,
|
126 |
-
value=7,
|
127 |
)
|
128 |
inference_steps = gr.Slider(
|
129 |
label="Inference Steps",
|
@@ -133,57 +129,67 @@ with gr.Blocks(
|
|
133 |
value=30,
|
134 |
)
|
135 |
|
136 |
-
with gr.
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
"
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
with gr.TabItem("
|
186 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
# update the random seed using JavaScript
|
189 |
random_seed_btn.click(None, outputs=[seed], js="() => Math.floor(Math.random() * 2**32)")
|
|
|
34 |
if prompt is None or prompt.strip() == "":
|
35 |
raise gr.Error("You must enter a prompt")
|
36 |
|
37 |
+
images = generate(*args, **kwargs, Error=gr.Error)
|
38 |
end = time.perf_counter()
|
39 |
diff = end - start
|
40 |
gr.Info(f"Generated {len(images)} images in {diff:.2f}s")
|
|
|
42 |
|
43 |
|
44 |
with gr.Blocks(
|
45 |
+
head=read_file("head.html"),
|
46 |
css="./demo.css",
|
47 |
js="./demo.js",
|
48 |
theme=gr.themes.Default(
|
|
|
60 |
).set(
|
61 |
block_background_fill=gr.themes.colors.gray.c50,
|
62 |
block_background_fill_dark=gr.themes.colors.gray.c900,
|
|
|
|
|
63 |
block_shadow="0 0 #0000",
|
64 |
block_shadow_dark="0 0 #0000",
|
|
|
|
|
|
|
65 |
),
|
66 |
) as demo:
|
67 |
gr.HTML(read_file("intro.html"))
|
68 |
output_images = gr.Gallery(
|
|
|
69 |
label="Output",
|
70 |
show_label=False,
|
71 |
+
columns=1,
|
72 |
interactive=False,
|
73 |
+
show_share_button=False,
|
74 |
elem_id="gallery",
|
75 |
)
|
76 |
prompt = gr.Textbox(
|
|
|
79 |
lines=2,
|
80 |
placeholder="corgi, at the beach, cute",
|
81 |
value=None,
|
|
|
82 |
)
|
83 |
generate_btn = gr.Button("Generate", variant="primary", elem_classes=[])
|
84 |
|
|
|
88 |
elem_id="menu",
|
89 |
elem_classes=["accordion"],
|
90 |
):
|
91 |
+
with gr.Tabs():
|
92 |
with gr.TabItem("⚙️ Settings"):
|
93 |
with gr.Group():
|
94 |
negative_prompt = gr.Textbox(
|
|
|
111 |
value="1:1",
|
112 |
filterable=False,
|
113 |
)
|
114 |
+
seed = gr.Number(label="Seed", value=0)
|
115 |
|
116 |
with gr.Row():
|
117 |
guidance_scale = gr.Slider(
|
|
|
119 |
minimum=1.0,
|
120 |
maximum=15.0,
|
121 |
step=0.1,
|
122 |
+
value=7.5,
|
123 |
)
|
124 |
inference_steps = gr.Slider(
|
125 |
label="Inference Steps",
|
|
|
129 |
value=30,
|
130 |
)
|
131 |
|
132 |
+
with gr.Row():
|
133 |
+
model = gr.Dropdown(
|
134 |
+
label="Model",
|
135 |
+
choices=[
|
136 |
+
"fluently/Fluently-v4",
|
137 |
+
"Linaqruf/anything-v3-1",
|
138 |
+
"Lykon/dreamshaper-8",
|
139 |
+
"prompthero/openjourney-v4",
|
140 |
+
"runwayml/stable-diffusion-v1-5",
|
141 |
+
"SG161222/Realistic_Vision_V5.1_Novae",
|
142 |
+
],
|
143 |
+
value="Lykon/dreamshaper-8",
|
144 |
+
)
|
145 |
+
scheduler = gr.Dropdown(
|
146 |
+
label="Scheduler",
|
147 |
+
choices=[
|
148 |
+
"DEIS 2M",
|
149 |
+
"DPM++ 2M",
|
150 |
+
"DPM2 a",
|
151 |
+
"Euler a",
|
152 |
+
"Heun",
|
153 |
+
"LMS",
|
154 |
+
"PNDM",
|
155 |
+
],
|
156 |
+
value="DEIS 2M",
|
157 |
+
elem_id="scheduler",
|
158 |
+
)
|
159 |
+
|
160 |
+
with gr.Row():
|
161 |
+
use_karras = gr.Checkbox(
|
162 |
+
label="Use Karras σ",
|
163 |
+
value=True,
|
164 |
+
elem_classes=["checkbox"],
|
165 |
+
scale=2,
|
166 |
+
)
|
167 |
+
increment_seed = gr.Checkbox(
|
168 |
+
label="Autoincrement seed",
|
169 |
+
value=True,
|
170 |
+
elem_classes=["checkbox"],
|
171 |
+
elem_id="increment-seed",
|
172 |
+
scale=2,
|
173 |
+
)
|
174 |
+
random_seed_btn = gr.Button(
|
175 |
+
"🎲 Random seed",
|
176 |
+
variant="secondary",
|
177 |
+
size="sm",
|
178 |
+
scale=1,
|
179 |
+
)
|
180 |
+
|
181 |
+
with gr.TabItem("🛠️ Advanced"):
|
182 |
+
gr.Markdown("_Coming soon..._", elem_classes=["markdown"])
|
183 |
+
|
184 |
+
with gr.TabItem("ℹ️ Info"):
|
185 |
+
gr.Markdown(read_file("info.md"), elem_classes=["markdown"])
|
186 |
+
|
187 |
+
# change gallery columns when num_images changes
|
188 |
+
num_images.change(
|
189 |
+
lambda n: gr.Gallery(columns=n),
|
190 |
+
inputs=[num_images],
|
191 |
+
outputs=[output_images],
|
192 |
+
)
|
193 |
|
194 |
# update the random seed using JavaScript
|
195 |
random_seed_btn.click(None, outputs=[seed], js="() => Math.floor(Math.random() * 2**32)")
|
head.html
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style>
|
2 |
+
/* gradio styles go in head */
|
3 |
+
@media (min-width: 1024px) {
|
4 |
+
gradio-app > .gradio-container {
|
5 |
+
max-width: 960px !important;
|
6 |
+
}
|
7 |
+
}
|
8 |
+
</style>
|
intro.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<div id="intro">
|
2 |
-
<h1>Stable Diffusion <
|
3 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 15 15">
|
4 |
<path d="M7.48877 6.75C7.29015 6.75 7.09967 6.82902 6.95923 6.96967C6.81879 7.11032 6.73989 7.30109 6.73989 7.5C6.73989 7.69891 6.81879 7.88968 6.95923 8.03033C7.09967 8.17098 7.29015 8.25 7.48877 8.25C7.68738 8.25 7.87786 8.17098 8.0183 8.03033C8.15874 7.88968 8.23764 7.69891 8.23764 7.5C8.23764 7.30109 8.15874 7.11032 8.0183 6.96967C7.87786 6.82902 7.68738 6.75 7.48877 6.75ZM7.8632 0C11.2331 0 11.3155 2.6775 9.54818 3.5625C8.80679 3.93 8.47728 4.7175 8.335 5.415C8.69446 5.565 9.00899 5.7975 9.24863 6.0975C12.0195 4.5975 15 5.19 15 7.875C15 11.25 12.3265 11.325 11.4428 9.5475C11.0684 8.805 10.2746 8.475 9.57813 8.3325C9.42836 8.6925 9.19621 9 8.89665 9.255C10.3869 12.0225 9.79531 15 7.11433 15C3.74438 15 3.67698 12.315 5.44433 11.43C6.17823 11.0625 6.50774 10.2825 6.65751 9.5925C6.29056 9.4425 5.96855 9.2025 5.72891 8.9025C2.96555 10.3875 0 9.8025 0 7.125C0 3.75 2.666 3.6675 3.54967 5.445C3.92411 6.1875 4.71043 6.51 5.40689 6.6525C5.54918 6.2925 5.78882 5.9775 6.09586 5.7375C4.60559 2.97 5.1972 0 7.8632 0Z"></path>
|
5 |
</svg>
|
6 |
</div>
|
7 |
-
<p>Stable Diffusion 1.5
|
|
|
1 |
<div id="intro">
|
2 |
+
<h1>Stable Diffusion <span>Zero</span></h1>
|
3 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 15 15">
|
4 |
<path d="M7.48877 6.75C7.29015 6.75 7.09967 6.82902 6.95923 6.96967C6.81879 7.11032 6.73989 7.30109 6.73989 7.5C6.73989 7.69891 6.81879 7.88968 6.95923 8.03033C7.09967 8.17098 7.29015 8.25 7.48877 8.25C7.68738 8.25 7.87786 8.17098 8.0183 8.03033C8.15874 7.88968 8.23764 7.69891 8.23764 7.5C8.23764 7.30109 8.15874 7.11032 8.0183 6.96967C7.87786 6.82902 7.68738 6.75 7.48877 6.75ZM7.8632 0C11.2331 0 11.3155 2.6775 9.54818 3.5625C8.80679 3.93 8.47728 4.7175 8.335 5.415C8.69446 5.565 9.00899 5.7975 9.24863 6.0975C12.0195 4.5975 15 5.19 15 7.875C15 11.25 12.3265 11.325 11.4428 9.5475C11.0684 8.805 10.2746 8.475 9.57813 8.3325C9.42836 8.6925 9.19621 9 8.89665 9.255C10.3869 12.0225 9.79531 15 7.11433 15C3.74438 15 3.67698 12.315 5.44433 11.43C6.17823 11.0625 6.50774 10.2825 6.65751 9.5925C6.29056 9.4425 5.96855 9.2025 5.72891 8.9025C2.96555 10.3875 0 9.8025 0 7.125C0 3.75 2.666 3.6675 3.54967 5.445C3.92411 6.1875 4.71043 6.51 5.40689 6.6525C5.54918 6.2925 5.78882 5.9775 6.09586 5.7375C4.60559 2.97 5.1972 0 7.8632 0Z"></path>
|
5 |
</svg>
|
6 |
</div>
|
7 |
+
<p>Stable Diffusion 1.5 powered by 🤗 <a href="https://huggingface.co/spaces/zero-gpu-explorers/README" target="_blank" rel="noopener noreferrer">ZeroGPU</a>.</p>
|