Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
from threading import RLock
|
| 7 |
from datetime import datetime
|
| 8 |
|
| 9 |
-
preSetPrompt = "tall slender athletic 18+ caucasian woman. gorgeous face. perky tits. short
|
| 10 |
negPreSetPrompt = "[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry, text, fuzziness"
|
| 11 |
|
| 12 |
lock = RLock()
|
|
@@ -33,8 +33,8 @@ def load_fn(models):
|
|
| 33 |
|
| 34 |
load_fn(models)
|
| 35 |
|
| 36 |
-
num_models =
|
| 37 |
-
max_images =
|
| 38 |
inference_timeout = 400
|
| 39 |
default_models = models[:num_models]
|
| 40 |
MAX_SEED = 2**32-1
|
|
@@ -191,93 +191,49 @@ CSS="""
|
|
| 191 |
</style>
|
| 192 |
"""
|
| 193 |
|
| 194 |
-
# with gr.Blocks(fill_width=True, head=js) as demo:
|
| 195 |
with gr.Blocks(head=CSS + JS) as demo:
|
| 196 |
-
with gr.
|
| 197 |
-
with gr.
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
with gr.Accordion("Advanced", open=False, visible=True):
|
| 202 |
-
with gr.Row():
|
| 203 |
-
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
| 204 |
-
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
| 205 |
-
with gr.Row():
|
| 206 |
-
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
| 207 |
-
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
| 208 |
-
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
| 209 |
-
seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
|
| 210 |
-
seed_rand.click(randomize_seed, None, [seed], queue=False)
|
| 211 |
-
with gr.Row():
|
| 212 |
-
gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3, elem_classes=["butt"])
|
| 213 |
-
random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
|
| 214 |
-
|
| 215 |
-
with gr.Column(scale=1):
|
| 216 |
-
with gr.Group():
|
| 217 |
with gr.Row():
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
visible=True) for m in default_models]
|
| 221 |
-
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
| 222 |
-
|
| 223 |
-
with gr.Column(scale=2):
|
| 224 |
-
gallery = gr.Gallery(label="Output", show_download_button=True,
|
| 225 |
-
interactive=False, show_share_button=False, container=True, format="png",
|
| 226 |
-
preview=True, object_fit="cover", columns=2, rows=2)
|
| 227 |
-
|
| 228 |
-
for m, o in zip(current_models, output):
|
| 229 |
-
gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
|
| 230 |
-
inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o],
|
| 231 |
-
concurrency_limit=None, queue=False)
|
| 232 |
-
o.change(add_gallery, [o, m, gallery], [gallery])
|
| 233 |
-
|
| 234 |
-
with gr.Column(scale=4):
|
| 235 |
-
with gr.Accordion('Model selection'):
|
| 236 |
-
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)
|
| 237 |
-
model_choice.change(update_imgbox, model_choice, output)
|
| 238 |
-
model_choice.change(extend_choices, model_choice, current_models)
|
| 239 |
-
random_button.click(random_choices, None, model_choice)
|
| 240 |
-
|
| 241 |
-
with gr.Tab('Single model'):
|
| 242 |
-
with gr.Column(scale=2):
|
| 243 |
-
model_choice2 = gr.Dropdown(models, label='Choose model', value=models[0])
|
| 244 |
-
with gr.Group():
|
| 245 |
-
txt_input2 = gr.Textbox(label='Your prompt:', value = preSetPrompt, lines=3, autofocus=1)
|
| 246 |
-
neg_input2 = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
|
| 247 |
-
with gr.Accordion("Advanced", open=False, visible=True):
|
| 248 |
-
with gr.Row():
|
| 249 |
-
width2 = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
| 250 |
-
height2 = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
| 251 |
-
with gr.Row():
|
| 252 |
-
steps2 = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
| 253 |
-
cfg2 = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
| 254 |
-
seed2 = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
| 255 |
-
seed_rand2 = gr.Button("Randomize Seed", size="sm", variant="secondary")
|
| 256 |
-
seed_rand2.click(randomize_seed, None, [seed2], queue=False)
|
| 257 |
-
num_images = gr.Slider(1, max_images, value=max_images, step=1, label='Number of images')
|
| 258 |
-
with gr.Row():
|
| 259 |
-
gen_button2 = gr.Button('Let the machine halucinate', variant='primary', scale=2, elem_classes=["butt"])
|
| 260 |
-
|
| 261 |
-
with gr.Column(scale=1):
|
| 262 |
-
with gr.Group():
|
| 263 |
with gr.Row():
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
demo.launch(show_api=False, max_threads=400)
|
|
|
|
| 6 |
from threading import RLock
|
| 7 |
from datetime import datetime
|
| 8 |
|
| 9 |
+
preSetPrompt = "tall slender athletic 18+ caucasian woman. gorgeous face. perky tits. short hair. open jeans. shredded ripped torn shirt. coy smile. explicit. artistic. photorealistic. f1.4"
|
| 10 |
negPreSetPrompt = "[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry, text, fuzziness"
|
| 11 |
|
| 12 |
lock = RLock()
|
|
|
|
| 33 |
|
| 34 |
load_fn(models)
|
| 35 |
|
| 36 |
+
num_models = 3
|
| 37 |
+
max_images = 3
|
| 38 |
inference_timeout = 400
|
| 39 |
default_models = models[:num_models]
|
| 40 |
MAX_SEED = 2**32-1
|
|
|
|
| 191 |
</style>
|
| 192 |
"""
|
| 193 |
|
|
|
|
| 194 |
with gr.Blocks(head=CSS + JS) as demo:
|
| 195 |
+
with gr.Column(scale=2):
|
| 196 |
+
with gr.Group():
|
| 197 |
+
txt_input = gr.Textbox(label='Your prompt:', value=preSetPrompt, lines=3, autofocus=1)
|
| 198 |
+
neg_input = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
|
| 199 |
+
with gr.Accordion("Advanced", open=False, visible=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
with gr.Row():
|
| 201 |
+
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
| 202 |
+
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
with gr.Row():
|
| 204 |
+
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
| 205 |
+
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
| 206 |
+
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
| 207 |
+
seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
|
| 208 |
+
seed_rand.click(randomize_seed, None, [seed], queue=False)
|
| 209 |
+
with gr.Row():
|
| 210 |
+
gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3, elem_classes=["butt"])
|
| 211 |
+
random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
|
| 212 |
+
|
| 213 |
+
with gr.Column(scale=1):
|
| 214 |
+
with gr.Group():
|
| 215 |
+
with gr.Row():
|
| 216 |
+
output = [gr.Image(label=m, show_download_button=True, elem_classes=["image-monitor"],
|
| 217 |
+
interactive=False, width=112, height=112, show_share_button=False, format="png",
|
| 218 |
+
visible=True) for m in default_models]
|
| 219 |
+
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
| 220 |
+
|
| 221 |
+
with gr.Column(scale=2):
|
| 222 |
+
gallery = gr.Gallery(label="Output", show_download_button=True,
|
| 223 |
+
interactive=False, show_share_button=False, container=True, format="png",
|
| 224 |
+
preview=True, object_fit="cover", columns=2, rows=2)
|
| 225 |
+
|
| 226 |
+
for m, o in zip(current_models, output):
|
| 227 |
+
gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
|
| 228 |
+
inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o],
|
| 229 |
+
concurrency_limit=None, queue=False)
|
| 230 |
+
o.change(add_gallery, [o, m, gallery], [gallery])
|
| 231 |
+
|
| 232 |
+
with gr.Column(scale=4):
|
| 233 |
+
with gr.Accordion('Model selection'):
|
| 234 |
+
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)
|
| 235 |
+
model_choice.change(update_imgbox, model_choice, output)
|
| 236 |
+
model_choice.change(extend_choices, model_choice, current_models)
|
| 237 |
+
random_button.click(random_choices, None, model_choice)
|
| 238 |
|
| 239 |
demo.launch(show_api=False, max_threads=400)
|