Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -30,11 +30,8 @@ def set_model(current_model):
|
|
30 |
current_model = models[current_model]
|
31 |
return gr.update(label=(f"{current_model}"))
|
32 |
|
33 |
-
def send_it1(inputs, model_choice, neg_input, height, width, steps, cfg, seed):
|
34 |
-
#proc1 = models2[model_choice]
|
35 |
-
#output1 = proc1(inputs)
|
36 |
output1 = gen_fn(model_choice, inputs, neg_input, height, width, steps, cfg, seed)
|
37 |
-
#negative_prompt=negative_prompt
|
38 |
return (output1)
|
39 |
|
40 |
# https://huggingface.co/docs/api-inference/detailed_parameters
|
@@ -84,63 +81,83 @@ def gen_fn(model_index, prompt, nprompt="", height=None, width=None, steps=None,
|
|
84 |
return result
|
85 |
|
86 |
css="""
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
"""
|
92 |
|
93 |
-
with gr.Blocks(
|
94 |
-
gr.HTML("""
|
95 |
<div style="text-align: center; max-width: 1200px; margin: 0 auto;">
|
96 |
<div>
|
97 |
<style>
|
98 |
-
h1 {
|
99 |
font-size: 6em;
|
100 |
color: #ffc99f;
|
101 |
margin-top: 30px;
|
102 |
margin-bottom: 30px;
|
103 |
text-shadow: 3px 3px 0 rgba(0, 0, 0, 1) !important;
|
104 |
-
}
|
105 |
-
h3 {
|
106 |
color: #ffc99f; !important;
|
107 |
-
}
|
108 |
-
h4 {
|
109 |
display: inline-block;
|
110 |
color: #ffffff !important;
|
111 |
-
}
|
112 |
-
.wrapper img {
|
113 |
font-size: 98% !important;
|
114 |
white-space: nowrap !important;
|
115 |
text-align: center !important;
|
116 |
display: inline-block !important;
|
117 |
color: #ffffff !important;
|
118 |
-
}
|
119 |
-
.wrapper {
|
120 |
color: #ffffff !important;
|
121 |
-
}
|
122 |
-
.gradio-container {
|
123 |
background-image: linear-gradient(#254150, #1e2f40, #182634) !important;
|
124 |
color: #ffaa66 !important;
|
125 |
font-family: 'IBM Plex Sans', sans-serif !important;
|
126 |
-
}
|
127 |
-
.text-gray-500 {
|
128 |
color: #ffc99f !important;
|
129 |
-
}
|
130 |
-
.gr-box {
|
131 |
background-image: linear-gradient(#182634, #1e2f40, #254150) !important;
|
132 |
border-top-color: #000000 !important;
|
133 |
border-right-color: #ffffff !important;
|
134 |
border-bottom-color: #ffffff !important;
|
135 |
border-left-color: #000000 !important;
|
136 |
-
}
|
137 |
-
.gr-input {
|
138 |
color: #ffc99f; !important;
|
139 |
background-color: #254150 !important;
|
140 |
-
}
|
141 |
-
:root {
|
142 |
--neutral-100: #000000 !important;
|
143 |
-
}
|
144 |
</style>
|
145 |
<body>
|
146 |
<div class="center"><h1>Blitz Diffusion</h1>
|
@@ -148,7 +165,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as myface:
|
|
148 |
</body>
|
149 |
</div>
|
150 |
<p style="margin-bottom: 1px; color: #ffaa66;">
|
151 |
-
<h3>
|
152 |
<br><div class="wrapper">9.3 <img src="https://huggingface.co/Yntec/DucHaitenLofi/resolve/main/NEW.webp" alt="NEW!" style="width:32px;height:16px;">This has become a legacy backup copy of old <u><a href="https://huggingface.co/spaces/Yntec/ToyWorld">ToyWorld</a></u>'s UI! Newer models added dailty over there! 25 new models since last update!</div>
|
153 |
<p style="margin-bottom: 1px; font-size: 98%">
|
154 |
<br><h4>If a model is already loaded each new image takes less than <b>10</b> seconds to generate!</h4></p>
|
@@ -156,79 +173,48 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as myface:
|
|
156 |
<br><div class="wrapper">Generate 6 images from 1 prompt at the <u><a href="https://huggingface.co/spaces/Yntec/PrintingPress">PrintingPress</a></u>, and use 6 different models at <u><a href="https://huggingface.co/spaces/Yntec/diffusion80xx">Huggingface Diffusion!</a></u>!
|
157 |
</p></p>
|
158 |
</div>
|
159 |
-
""")
|
160 |
with gr.Row():
|
161 |
with gr.Column(scale=100):
|
162 |
-
#Model selection dropdown
|
163 |
-
model_name1 = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index",
|
|
|
164 |
with gr.Row():
|
165 |
with gr.Column(scale=100):
|
166 |
with gr.Group():
|
167 |
-
magic1 = gr.Textbox(label="Your Prompt", lines=4) #Positive
|
168 |
-
with gr.Accordion("Advanced", open=False, visible=True):
|
169 |
-
neg_input = gr.Textbox(label='Negative prompt
|
170 |
with gr.Row():
|
171 |
-
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
172 |
-
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
173 |
with gr.Row():
|
174 |
-
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
175 |
-
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
176 |
-
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
177 |
-
|
178 |
-
|
179 |
-
gr.HTML("""<style> .gr-button {
|
180 |
-
color: #ffffff !important;
|
181 |
-
text-shadow: 1px 1px 0 rgba(0, 0, 0, 1) !important;
|
182 |
-
background-image: linear-gradient(#76635a, #d2a489) !important;
|
183 |
-
border-radius: 24px !important;
|
184 |
-
border: solid 1px !important;
|
185 |
-
border-top-color: #ffc99f !important;
|
186 |
-
border-right-color: #000000 !important;
|
187 |
-
border-bottom-color: #000000 !important;
|
188 |
-
border-left-color: #ffc99f !important;
|
189 |
-
padding: 6px 30px;
|
190 |
-
}
|
191 |
-
.gr-button:active {
|
192 |
-
color: #ffc99f !important;
|
193 |
-
font-size: 98% !important;
|
194 |
-
text-shadow: 0px 0px 0 rgba(0, 0, 0, 1) !important;
|
195 |
-
background-image: linear-gradient(#d2a489, #76635a) !important;
|
196 |
-
border-top-color: #000000 !important;
|
197 |
-
border-right-color: #ffffff !important;
|
198 |
-
border-bottom-color: #ffffff !important;
|
199 |
-
border-left-color: #000000 !important;
|
200 |
-
}
|
201 |
-
.gr-button:hover {
|
202 |
-
filter: brightness(130%);
|
203 |
-
}
|
204 |
-
</style>""")
|
205 |
-
run = gr.Button("Generate Image")
|
206 |
with gr.Row():
|
207 |
with gr.Column():
|
208 |
-
output1 = gr.Image(label=(f"{current_model}"), show_download_button=True,
|
209 |
-
interactive=False, show_share_button=False, format=".png")
|
210 |
|
211 |
with gr.Row():
|
212 |
with gr.Column(scale=50):
|
213 |
-
input_text=gr.Textbox(label="Use this box to extend an idea automagically, by typing some words and clicking Extend Idea", lines=2)
|
214 |
-
see_prompts=gr.Button("Extend Idea -> overwrite the contents of the `Your Prompt´ box above")
|
215 |
-
use_short=gr.Button("Copy the contents of this box to the `Your Prompt´ box above")
|
216 |
def short_prompt(inputs):
|
217 |
return (inputs)
|
218 |
|
219 |
model_name1.change(set_model, inputs=model_name1, outputs=[output1])
|
220 |
-
|
221 |
-
#run.click(send_it1, inputs=[magic1, model_name1, neg_input, height, width, steps, cfg, seed], outputs=[output1])
|
222 |
-
|
223 |
gr.on(
|
224 |
triggers=[run.click, magic1.submit],
|
225 |
fn=send_it1,
|
226 |
inputs=[magic1, model_name1, neg_input, height, width, steps, cfg, seed],
|
227 |
outputs=[output1],
|
228 |
)
|
229 |
-
|
230 |
use_short.click(short_prompt, inputs=[input_text], outputs=magic1)
|
231 |
-
|
232 |
see_prompts.click(text_it1, inputs=[input_text], outputs=magic1)
|
233 |
|
234 |
myface.queue(default_concurrency_limit=200, max_size=200)
|
|
|
30 |
current_model = models[current_model]
|
31 |
return gr.update(label=(f"{current_model}"))
|
32 |
|
33 |
+
def send_it1(inputs, model_choice, neg_input, height, width, steps, cfg, seed):
|
|
|
|
|
34 |
output1 = gen_fn(model_choice, inputs, neg_input, height, width, steps, cfg, seed)
|
|
|
35 |
return (output1)
|
36 |
|
37 |
# https://huggingface.co/docs/api-inference/detailed_parameters
|
|
|
81 |
return result
|
82 |
|
83 |
css="""
|
84 |
+
.gradio-container {background-image: linear-gradient(#254150, #1e2f40, #182634) !important;
|
85 |
+
color: #ffaa66 !important; font-family: 'IBM Plex Sans', sans-serif !important;}
|
86 |
+
h1 {font-size: 6em; color: #ffc99f; margin-top: 30px; margin-bottom: 30px;
|
87 |
+
text-shadow: 3px 3px 0 rgba(0, 0, 0, 1) !important;}
|
88 |
+
h3 {color: #ffc99f; !important;}
|
89 |
+
h4 {display: inline-block; color: #ffffff !important;}
|
90 |
+
.wrapper img {font-size: 98% !important; white-space: nowrap !important; text-align: center !important;
|
91 |
+
display: inline-block !important; color: #ffffff !important;}
|
92 |
+
.wrapper {color: #ffffff !important;}
|
93 |
+
.text-gray-500 {color: #ffc99f !important;}
|
94 |
+
.gr-box {background-image: linear-gradient(#182634, #1e2f40, #254150) !important;
|
95 |
+
border-top-color: #000000 !important; border-right-color: #ffffff !important;
|
96 |
+
border-bottom-color: #ffffff !important; border-left-color: #000000 !important;}
|
97 |
+
.gr-input {color: #ffc99f; !important; background-color: #254150 !important;}
|
98 |
+
:root {--neutral-100: #000000 !important;}
|
99 |
+
.gr-button {color: #ffffff !important; text-shadow: 1px 1px 0 rgba(0, 0, 0, 1) !important;
|
100 |
+
background-image: linear-gradient(#76635a, #d2a489) !important; border-radius: 24px !important;
|
101 |
+
border: solid 1px !important; border-top-color: #ffc99f !important; border-right-color: #000000 !important;
|
102 |
+
border-bottom-color: #000000 !important; border-left-color: #ffc99f !important; padding: 6px 30px;}
|
103 |
+
.gr-button:active {color: #ffc99f !important; font-size: 98% !important;
|
104 |
+
text-shadow: 0px 0px 0 rgba(0, 0, 0, 1) !important; background-image: linear-gradient(#d2a489, #76635a) !important;
|
105 |
+
border-top-color: #000000 !important; border-right-color: #ffffff !important;
|
106 |
+
border-bottom-color: #ffffff !important; border-left-color: #000000 !important;}
|
107 |
+
.gr-button:hover {filter: brightness(130%);}
|
108 |
"""
|
109 |
|
110 |
+
with gr.Blocks(fill_width=True, css=css) as myface:
|
111 |
+
gr.HTML(f"""
|
112 |
<div style="text-align: center; max-width: 1200px; margin: 0 auto;">
|
113 |
<div>
|
114 |
<style>
|
115 |
+
h1 {{
|
116 |
font-size: 6em;
|
117 |
color: #ffc99f;
|
118 |
margin-top: 30px;
|
119 |
margin-bottom: 30px;
|
120 |
text-shadow: 3px 3px 0 rgba(0, 0, 0, 1) !important;
|
121 |
+
}}
|
122 |
+
h3 {{
|
123 |
color: #ffc99f; !important;
|
124 |
+
}}
|
125 |
+
h4 {{
|
126 |
display: inline-block;
|
127 |
color: #ffffff !important;
|
128 |
+
}}
|
129 |
+
.wrapper img {{
|
130 |
font-size: 98% !important;
|
131 |
white-space: nowrap !important;
|
132 |
text-align: center !important;
|
133 |
display: inline-block !important;
|
134 |
color: #ffffff !important;
|
135 |
+
}}
|
136 |
+
.wrapper {{
|
137 |
color: #ffffff !important;
|
138 |
+
}}
|
139 |
+
.gradio-container {{
|
140 |
background-image: linear-gradient(#254150, #1e2f40, #182634) !important;
|
141 |
color: #ffaa66 !important;
|
142 |
font-family: 'IBM Plex Sans', sans-serif !important;
|
143 |
+
}}
|
144 |
+
.text-gray-500 {{
|
145 |
color: #ffc99f !important;
|
146 |
+
}}
|
147 |
+
.gr-box {{
|
148 |
background-image: linear-gradient(#182634, #1e2f40, #254150) !important;
|
149 |
border-top-color: #000000 !important;
|
150 |
border-right-color: #ffffff !important;
|
151 |
border-bottom-color: #ffffff !important;
|
152 |
border-left-color: #000000 !important;
|
153 |
+
}}
|
154 |
+
.gr-input {{
|
155 |
color: #ffc99f; !important;
|
156 |
background-color: #254150 !important;
|
157 |
+
}}
|
158 |
+
:root {{
|
159 |
--neutral-100: #000000 !important;
|
160 |
+
}}
|
161 |
</style>
|
162 |
<body>
|
163 |
<div class="center"><h1>Blitz Diffusion</h1>
|
|
|
165 |
</body>
|
166 |
</div>
|
167 |
<p style="margin-bottom: 1px; color: #ffaa66;">
|
168 |
+
<h3>{int(len(models))} Stable Diffusion models, but why? For your enjoyment!</h3></p>
|
169 |
<br><div class="wrapper">9.3 <img src="https://huggingface.co/Yntec/DucHaitenLofi/resolve/main/NEW.webp" alt="NEW!" style="width:32px;height:16px;">This has become a legacy backup copy of old <u><a href="https://huggingface.co/spaces/Yntec/ToyWorld">ToyWorld</a></u>'s UI! Newer models added dailty over there! 25 new models since last update!</div>
|
170 |
<p style="margin-bottom: 1px; font-size: 98%">
|
171 |
<br><h4>If a model is already loaded each new image takes less than <b>10</b> seconds to generate!</h4></p>
|
|
|
173 |
<br><div class="wrapper">Generate 6 images from 1 prompt at the <u><a href="https://huggingface.co/spaces/Yntec/PrintingPress">PrintingPress</a></u>, and use 6 different models at <u><a href="https://huggingface.co/spaces/Yntec/diffusion80xx">Huggingface Diffusion!</a></u>!
|
174 |
</p></p>
|
175 |
</div>
|
176 |
+
""", elem_classes="gr-box")
|
177 |
with gr.Row():
|
178 |
with gr.Column(scale=100):
|
179 |
+
#Model selection dropdown
|
180 |
+
model_name1 = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index",
|
181 |
+
value=current_model, interactive=True, elem_classes=["gr-box", "gr-input"])
|
182 |
with gr.Row():
|
183 |
with gr.Column(scale=100):
|
184 |
with gr.Group():
|
185 |
+
magic1 = gr.Textbox(label="Your Prompt", lines=4, elem_classes=["gr-box", "gr-input"]) #Positive
|
186 |
+
with gr.Accordion("Advanced", open=False, visible=True, elem_classes="gr-box"):
|
187 |
+
neg_input = gr.Textbox(label='Negative prompt', lines=1, elem_classes=["gr-box", "gr-input"])
|
188 |
with gr.Row():
|
189 |
+
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0, elem_classes=["gr-box", "gr-input"])
|
190 |
+
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0, elem_classes=["gr-box", "gr-input"])
|
191 |
with gr.Row():
|
192 |
+
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0, elem_classes=["gr-box", "gr-input"])
|
193 |
+
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0, elem_classes=["gr-box", "gr-input"])
|
194 |
+
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1, elem_classes=["gr-box", "gr-input"])
|
195 |
+
run = gr.Button("Generate Image", elem_classes="gr-button")
|
196 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
with gr.Row():
|
198 |
with gr.Column():
|
199 |
+
output1 = gr.Image(label=(f"{current_model}"), show_download_button=True,
|
200 |
+
interactive=False, show_share_button=False, format=".png", elem_classes="gr-box")
|
201 |
|
202 |
with gr.Row():
|
203 |
with gr.Column(scale=50):
|
204 |
+
input_text=gr.Textbox(label="Use this box to extend an idea automagically, by typing some words and clicking Extend Idea", lines=2, elem_classes=["gr-box", "gr-input"])
|
205 |
+
see_prompts=gr.Button("Extend Idea -> overwrite the contents of the `Your Prompt´ box above", elem_classes="gr-button")
|
206 |
+
use_short=gr.Button("Copy the contents of this box to the `Your Prompt´ box above", elem_classes="gr-button")
|
207 |
def short_prompt(inputs):
|
208 |
return (inputs)
|
209 |
|
210 |
model_name1.change(set_model, inputs=model_name1, outputs=[output1])
|
|
|
|
|
|
|
211 |
gr.on(
|
212 |
triggers=[run.click, magic1.submit],
|
213 |
fn=send_it1,
|
214 |
inputs=[magic1, model_name1, neg_input, height, width, steps, cfg, seed],
|
215 |
outputs=[output1],
|
216 |
)
|
|
|
217 |
use_short.click(short_prompt, inputs=[input_text], outputs=magic1)
|
|
|
218 |
see_prompts.click(text_it1, inputs=[input_text], outputs=magic1)
|
219 |
|
220 |
myface.queue(default_concurrency_limit=200, max_size=200)
|