Commit
·
99a9568
1
Parent(s):
3cf01d0
add greeting part and prepare greeting overlay
Browse files- modules/html.py +10 -2
- webui.py +44 -12
modules/html.py
CHANGED
|
@@ -94,12 +94,16 @@ progress::after {
|
|
| 94 |
box-shadow: none !important;
|
| 95 |
}
|
| 96 |
|
| 97 |
-
#
|
| 98 |
display: none;
|
| 99 |
}
|
| 100 |
|
| 101 |
.input-label h5 {
|
| 102 |
-
margin: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
.icon-buttons > a > button > div, .icon-buttons > button > div {
|
|
@@ -107,6 +111,10 @@ progress::after {
|
|
| 107 |
height: 2em;
|
| 108 |
}
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
'''
|
| 111 |
progress_html = '''
|
| 112 |
<div class="loader-container" style="visibility:*visibility*;max-width:1280px;">
|
|
|
|
| 94 |
box-shadow: none !important;
|
| 95 |
}
|
| 96 |
|
| 97 |
+
#prompt-examples > .label, #greet-examples > .label {
|
| 98 |
display: none;
|
| 99 |
}
|
| 100 |
|
| 101 |
.input-label h5 {
|
| 102 |
+
margin: 0 !important;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.input-label {
|
| 106 |
+
margin-bottom: -10px !important;
|
| 107 |
}
|
| 108 |
|
| 109 |
.icon-buttons > a > button > div, .icon-buttons > button > div {
|
|
|
|
| 111 |
height: 2em;
|
| 112 |
}
|
| 113 |
|
| 114 |
+
#toggle-greet-checkbox span {
|
| 115 |
+
font-size: 1.05em !important;
|
| 116 |
+
font-weight: var(--prose-header-text-weight) !important;
|
| 117 |
+
}
|
| 118 |
'''
|
| 119 |
progress_html = '''
|
| 120 |
<div class="loader-container" style="visibility:*visibility*;max-width:1280px;">
|
webui.py
CHANGED
|
@@ -13,8 +13,9 @@ from modules.sdxl_styles import style_keys, aspect_ratios
|
|
| 13 |
|
| 14 |
def generate(*args):
|
| 15 |
yield gr.update(interactive=False), \
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
while worker.is_working:
|
| 20 |
time.sleep(0.1)
|
|
@@ -29,17 +30,28 @@ def generate(*args):
|
|
| 29 |
flag, product = worker.outputs.pop(0)
|
| 30 |
if flag == 'preview':
|
| 31 |
percentage, title, image = product
|
| 32 |
-
yield gr.update(
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
if flag == 'results':
|
| 36 |
image = product[0]
|
| 37 |
yield gr.update(interactive=True), \
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
finished = True
|
| 41 |
return
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
qm_color=Color(name="qm", c50="#effaed",c100="#def5db",c200="#64b445",c300="#c6eec0",c400="#b9ebb3",c500="#64b445",c600="#55993b",c700="#467e30",c800="#325a23",c900="#233f18",c950="#192d11")
|
| 44 |
shared.gradio_root = gr.Blocks(title='QualityMinds AI Christmas Card Maker', css=modules.html.css, theme=gr.themes.Default(primary_hue=qm_color))
|
| 45 |
with shared.gradio_root:
|
|
@@ -53,23 +65,43 @@ with shared.gradio_root:
|
|
| 53 |
with gr.Row(elem_classes='type_row'):
|
| 54 |
with gr.Column(scale=2):
|
| 55 |
gr.Markdown("##### Prompt (Englisch)", elem_classes="input-label")
|
| 56 |
-
prompt = gr.Textbox(label="Prompt (Englisch)", value="",
|
|
|
|
| 57 |
autofocus=True, elem_classes='type_row', container=False, lines=2)
|
| 58 |
description_de = gr.Textbox(label="Beschreibung", visible=False)
|
| 59 |
gr.Markdown("##### Beispiele", elem_classes="input-label")
|
| 60 |
gr.Examples(examples=[["Der Weihnachtsmann mit seinem Sack voller Geschenke", "Santa Claus with his sack full of gifts"],
|
| 61 |
["Malerisches Winterdorf in einer Schneekugel", "Scenic winter village inside a snow globe"],
|
| 62 |
["Niedliche Pinguine in Schals und Mützen eingewickelt", "Cute penguins wrapped up in scarves and hats"]],
|
| 63 |
-
inputs=[description_de, prompt], elem_id="
|
| 64 |
|
| 65 |
with gr.Column(scale=1, min_width="120px"):
|
| 66 |
gr.Markdown("##### Stil", elem_classes="input-label")
|
| 67 |
-
style_selection = gr.Dropdown(
|
| 68 |
run_button = gr.Button(value="Weihnachtskarte\nerstellen", variant='primary', elem_classes='generate_button')
|
| 69 |
progress_html = gr.HTML(visible=False, elem_id='progress-bar', elem_classes='progress-bar')
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
shared.gradio_root.queue(concurrency_count=1, api_open=False)
|
| 75 |
shared.gradio_root.launch(server_name="0.0.0.0", show_api=False)
|
|
|
|
| 13 |
|
| 14 |
def generate(*args):
|
| 15 |
yield gr.update(interactive=False), \
|
| 16 |
+
gr.update(visible=True, value=modules.html.make_progress_html(1, "0/30")), \
|
| 17 |
+
gr.update(visible=True, show_share_button=False, show_download_button=False), \
|
| 18 |
+
gr.update(visible=False)
|
| 19 |
|
| 20 |
while worker.is_working:
|
| 21 |
time.sleep(0.1)
|
|
|
|
| 30 |
flag, product = worker.outputs.pop(0)
|
| 31 |
if flag == 'preview':
|
| 32 |
percentage, title, image = product
|
| 33 |
+
yield gr.update(), \
|
| 34 |
+
gr.update(value=modules.html.make_progress_html(percentage, title)), \
|
| 35 |
+
gr.update(value=image) if image is not None else gr.update(), \
|
| 36 |
+
gr.update()
|
| 37 |
if flag == 'results':
|
| 38 |
image = product[0]
|
| 39 |
yield gr.update(interactive=True), \
|
| 40 |
+
gr.update(visible=False), \
|
| 41 |
+
gr.update(value=image), \
|
| 42 |
+
gr.update()
|
| 43 |
finished = True
|
| 44 |
return
|
| 45 |
|
| 46 |
+
def toggle_greet_visibility(is_visible):
|
| 47 |
+
yield gr.update(visible=is_visible), gr.update(visible=is_visible)
|
| 48 |
+
|
| 49 |
+
def debounce():
|
| 50 |
+
time.sleep(0.5)
|
| 51 |
+
|
| 52 |
+
def make_overlay(generated_image_raw, toggle_greet, greet):
|
| 53 |
+
return gr.update(visible=False), gr.update(visible=True, value=generated_image_raw)
|
| 54 |
+
|
| 55 |
qm_color=Color(name="qm", c50="#effaed",c100="#def5db",c200="#64b445",c300="#c6eec0",c400="#b9ebb3",c500="#64b445",c600="#55993b",c700="#467e30",c800="#325a23",c900="#233f18",c950="#192d11")
|
| 56 |
shared.gradio_root = gr.Blocks(title='QualityMinds AI Christmas Card Maker', css=modules.html.css, theme=gr.themes.Default(primary_hue=qm_color))
|
| 57 |
with shared.gradio_root:
|
|
|
|
| 65 |
with gr.Row(elem_classes='type_row'):
|
| 66 |
with gr.Column(scale=2):
|
| 67 |
gr.Markdown("##### Prompt (Englisch)", elem_classes="input-label")
|
| 68 |
+
prompt = gr.Textbox(label="Prompt (Englisch)", value="",
|
| 69 |
+
placeholder="Was möchtest Du auf der Weihnachtskarte abbilden?",
|
| 70 |
autofocus=True, elem_classes='type_row', container=False, lines=2)
|
| 71 |
description_de = gr.Textbox(label="Beschreibung", visible=False)
|
| 72 |
gr.Markdown("##### Beispiele", elem_classes="input-label")
|
| 73 |
gr.Examples(examples=[["Der Weihnachtsmann mit seinem Sack voller Geschenke", "Santa Claus with his sack full of gifts"],
|
| 74 |
["Malerisches Winterdorf in einer Schneekugel", "Scenic winter village inside a snow globe"],
|
| 75 |
["Niedliche Pinguine in Schals und Mützen eingewickelt", "Cute penguins wrapped up in scarves and hats"]],
|
| 76 |
+
inputs=[description_de, prompt], elem_id="prompt-examples", cache_examples=False)
|
| 77 |
|
| 78 |
with gr.Column(scale=1, min_width="120px"):
|
| 79 |
gr.Markdown("##### Stil", elem_classes="input-label")
|
| 80 |
+
style_selection = gr.Dropdown(choices=style_keys, value='Kinofilm', container=False)
|
| 81 |
run_button = gr.Button(value="Weihnachtskarte\nerstellen", variant='primary', elem_classes='generate_button')
|
| 82 |
progress_html = gr.HTML(visible=False, elem_id='progress-bar', elem_classes='progress-bar')
|
| 83 |
+
|
| 84 |
+
with gr.Row(elem_classes='type_row'):
|
| 85 |
+
with gr.Column(scale=2):
|
| 86 |
+
toggle_greet = gr.Checkbox(label="Persönliche Weihnachtsgrüße hinzufügen", elem_id="toggle-greet-checkbox",
|
| 87 |
+
container=False, value=True, interactive=True)
|
| 88 |
+
greet = gr.Textbox(value="", placeholder="", interactive=True,
|
| 89 |
+
elem_classes='type_row', container=False, lines=2)
|
| 90 |
+
greet_example_column = gr.Column(scale=1)
|
| 91 |
+
with greet_example_column:
|
| 92 |
+
gr.Markdown("<br>", elem_classes="input-label")
|
| 93 |
+
gr.Markdown("##### Beispiele", elem_classes="input-label")
|
| 94 |
+
greet_examples = gr.Examples(label="Beispiele", examples=["Frohe Weihnachten"], inputs=[greet],
|
| 95 |
+
elem_id="greet-examples")
|
| 96 |
+
|
| 97 |
+
generated_image_raw = gr.Image(visible=False, label="Weihnachtskarte", width=1280, value="resources/init.png", interactive=False )
|
| 98 |
+
generated_image_overlayed = gr.Image(label="Weihnachtskarte", width=1280, value="resources/init.png" )
|
| 99 |
|
| 100 |
+
toggle_greet.change(fn=toggle_greet_visibility, inputs=[toggle_greet], outputs=[greet, greet_example_column])
|
| 101 |
+
greet.change(fn=debounce)\
|
| 102 |
+
.then(fn=make_overlay, inputs=[generated_image_raw, toggle_greet, greet], outputs=[generated_image_raw, generated_image_overlayed])
|
| 103 |
+
run_button.click(fn=generate, inputs=[prompt, style_selection], outputs=[run_button, progress_html, generated_image_raw, generated_image_overlayed])\
|
| 104 |
+
.then(fn=make_overlay, inputs=[generated_image_raw, toggle_greet, greet], outputs=[generated_image_raw, generated_image_overlayed])
|
| 105 |
|
| 106 |
shared.gradio_root.queue(concurrency_count=1, api_open=False)
|
| 107 |
shared.gradio_root.launch(server_name="0.0.0.0", show_api=False)
|