Spaces:
Running
Running
gunship999
commited on
Commit
•
2c52333
1
Parent(s):
5aa6ace
Update app.py
Browse files
app.py
CHANGED
@@ -176,103 +176,105 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
|
|
176 |
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgunship999-SexyImages.hf.space&countColor=%23263759" />
|
177 |
</a>""")
|
178 |
|
179 |
-
with gr.
|
180 |
-
with gr.
|
181 |
-
|
182 |
-
|
183 |
-
label=
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
-
with gr.
|
189 |
-
|
190 |
-
label='Your prompt:',
|
191 |
-
value=preSetPrompt,
|
192 |
-
lines=3,
|
193 |
-
autofocus=1
|
194 |
-
)
|
195 |
-
neg_input = gr.Textbox(
|
196 |
-
label='Negative prompt:',
|
197 |
-
value=negPreSetPrompt,
|
198 |
-
lines=1
|
199 |
-
)
|
200 |
-
with gr.Accordion("Advanced Settings", open=False):
|
201 |
-
with gr.Row():
|
202 |
-
width = gr.Slider(label="Width", maximum=1216, step=32, value=0)
|
203 |
-
height = gr.Slider(label="Height", maximum=1216, step=32, value=0)
|
204 |
with gr.Row():
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
seed_rand.click(randomize_seed, None, [seed], queue=False)
|
210 |
|
211 |
-
with gr.
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
scale=3,
|
216 |
-
elem_classes="primary-btn"
|
217 |
-
)
|
218 |
-
random_button = gr.Button(
|
219 |
-
'Randomize Models',
|
220 |
-
variant='secondary',
|
221 |
-
scale=1
|
222 |
-
)
|
223 |
-
|
224 |
-
with gr.Column(scale=1):
|
225 |
-
with gr.Group():
|
226 |
-
with gr.Row():
|
227 |
-
output = [gr.Image(label=m, show_download_button=True,
|
228 |
-
elem_classes="output",
|
229 |
-
interactive=False, width=112, height=112,
|
230 |
-
show_share_button=False, format="png",
|
231 |
-
visible=True) for m in default_models]
|
232 |
-
current_models = [gr.Textbox(m, visible=False)
|
233 |
-
for m in default_models]
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
interactive=False,
|
241 |
-
show_share_button=False,
|
242 |
-
container=True,
|
243 |
-
format="png",
|
244 |
-
preview=True,
|
245 |
-
object_fit="cover",
|
246 |
-
columns=2,
|
247 |
-
rows=2
|
248 |
-
)
|
249 |
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
|
|
|
|
|
|
|
|
|
276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
-
demo.
|
|
|
|
|
|
176 |
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgunship999-SexyImages.hf.space&countColor=%23263759" />
|
177 |
</a>""")
|
178 |
|
179 |
+
with gr.Tab('6 Models'):
|
180 |
+
with gr.Column(scale=2):
|
181 |
+
with gr.Group():
|
182 |
+
txt_input = gr.Textbox(label='Your prompt:', value=preSetPrompt, lines=3, autofocus=1)
|
183 |
+
neg_input = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
|
184 |
+
with gr.Accordion("Advanced", open=False, visible=True):
|
185 |
+
with gr.Row():
|
186 |
+
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
187 |
+
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
188 |
+
with gr.Row():
|
189 |
+
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
190 |
+
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
191 |
+
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
192 |
+
seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
|
193 |
+
seed_rand.click(randomize_seed, None, [seed], queue=False)
|
194 |
+
with gr.Row():
|
195 |
+
gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3)
|
196 |
+
random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
|
197 |
+
#stop_button = gr.Button('Stop', variant='stop', interactive=False, scale=1)
|
198 |
+
#gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
|
199 |
+
gr.Markdown("", elem_classes="guide")
|
200 |
|
201 |
+
with gr.Column(scale=1):
|
202 |
+
with gr.Group():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
with gr.Row():
|
204 |
+
output = [gr.Image(label=m, show_download_button=True, elem_classes="output",
|
205 |
+
interactive=False, width=112, height=112, show_share_button=False, format="png",
|
206 |
+
visible=True) for m in default_models]
|
207 |
+
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
|
|
208 |
|
209 |
+
with gr.Column(scale=2):
|
210 |
+
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
211 |
+
interactive=False, show_share_button=False, container=True, format="png",
|
212 |
+
preview=True, object_fit="cover", columns=2, rows=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
+
for m, o in zip(current_models, output):
|
215 |
+
gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
|
216 |
+
inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o],
|
217 |
+
concurrency_limit=None, queue=False) # Be sure to delete ", queue=False" when activating the stop button
|
218 |
+
o.change(add_gallery, [o, m, gallery], [gallery])
|
219 |
+
#stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
+
with gr.Column(scale=4):
|
222 |
+
with gr.Accordion('Model selection'):
|
223 |
+
model_choice = gr.CheckboxGroup(models, label = f'Choose up to {int(num_models)} different models from the {len(models)} available!', value=default_models, interactive=True)
|
224 |
+
model_choice.change(update_imgbox, model_choice, output)
|
225 |
+
model_choice.change(extend_choices, model_choice, current_models)
|
226 |
+
random_button.click(random_choices, None, model_choice)
|
227 |
|
228 |
+
with gr.Tab('Single model'):
|
229 |
+
with gr.Column(scale=2):
|
230 |
+
model_choice2 = gr.Dropdown(models, label='Choose model', value=models[0])
|
231 |
+
with gr.Group():
|
232 |
+
# global preSetPrompt
|
233 |
+
# global negPreSetPrompt
|
234 |
+
txt_input2 = gr.Textbox(label='Your prompt:', value = preSetPrompt, lines=3, autofocus=1)
|
235 |
+
neg_input2 = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
|
236 |
+
with gr.Accordion("Advanced", open=False, visible=True):
|
237 |
+
with gr.Row():
|
238 |
+
width2 = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
239 |
+
height2 = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
240 |
+
with gr.Row():
|
241 |
+
steps2 = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
242 |
+
cfg2 = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
243 |
+
seed2 = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
244 |
+
seed_rand2 = gr.Button("Randomize Seed", size="sm", variant="secondary")
|
245 |
+
seed_rand2.click(randomize_seed, None, [seed2], queue=False)
|
246 |
+
num_images = gr.Slider(1, max_images, value=max_images, step=1, label='Number of images')
|
247 |
+
with gr.Row():
|
248 |
+
gen_button2 = gr.Button('Let the machine halucinate', variant='primary', scale=2)
|
249 |
+
#stop_button2 = gr.Button('Stop', variant='stop', interactive=False, scale=1)
|
250 |
+
#gen_button2.click(lambda: gr.update(interactive=True), None, stop_button2)
|
251 |
|
252 |
+
with gr.Column(scale=1):
|
253 |
+
with gr.Group():
|
254 |
+
with gr.Row():
|
255 |
+
output2 = [gr.Image(label='', show_download_button=True, elem_classes="output",
|
256 |
+
interactive=False, width=112, height=112, visible=True, format="png",
|
257 |
+
show_share_button=False, show_label=False) for _ in range(max_images)]
|
258 |
|
259 |
+
with gr.Column(scale=2):
|
260 |
+
gallery2 = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
261 |
+
interactive=False, show_share_button=True, container=True, format="png",
|
262 |
+
preview=True, object_fit="cover", columns=2, rows=2)
|
263 |
|
264 |
+
for i, o in enumerate(output2):
|
265 |
+
img_i = gr.Number(i, visible=False)
|
266 |
+
num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, queue=False)
|
267 |
+
gen_event2 = gr.on(triggers=[gen_button2.click, txt_input2.submit],
|
268 |
+
fn=lambda i, n, m, t1, t2, n1, n2, n3, n4, n5: gen_fn(m, t1, t2, n1, n2, n3, n4, n5) if (i < n) else None,
|
269 |
+
inputs=[img_i, num_images, model_choice2, txt_input2, neg_input2,
|
270 |
+
height2, width2, steps2, cfg2, seed2], outputs=[o],
|
271 |
+
concurrency_limit=None, queue=False) # Be sure to delete ", queue=False" when activating the stop button
|
272 |
+
o.change(add_gallery, [o, model_choice2, gallery2], [gallery2])
|
273 |
+
#stop_button2.click(lambda: gr.update(interactive=False), None, stop_button2, cancels=[gen_event2])
|
274 |
+
|
275 |
+
# gr.Markdown(js_AutoSave)
|
276 |
+
gr.Markdown("")
|
277 |
|
278 |
+
# demo.queue(default_concurrency_limit=200, max_size=200)
|
279 |
+
demo.launch(show_api=False, max_threads=400)
|
280 |
+
# demo.launch(show_api=False, max_threads=400, js=js_AutoSave)
|