File size: 2,837 Bytes
33adbe7
b6016a7
796cb1f
0276c07
bb33d1a
2f3af37
31833d7
796cb1f
 
 
 
 
34a218b
796cb1f
34a218b
 
796cb1f
34a218b
 
 
 
 
796cb1f
34a218b
796cb1f
 
 
 
 
 
 
34a218b
 
796cb1f
34a218b
796cb1f
 
34a218b
796cb1f
 
 
 
34a218b
0276c07
34a218b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import gradio as gr
import random
import time
import shared
import argparse
import modules.path
import fooocus_version
import modules.html
import modules.async_worker as worker

from modules.sdxl_styles import style_keys, aspect_ratios

def generate(*args):
    yield gr.update(interactive=False), \
        gr.update(visible=True, value=modules.html.make_progress_html(1, "0/30")), \
        gr.update()

    while worker.is_working:
        time.sleep(0.1)
        
    worker.buffer=[list(args)]
    worker.outputs = []

    finished=False
    while not finished:
        time.sleep(0.01)
        if len(worker.outputs) > 0:
            flag, product = worker.outputs.pop(0)
            if flag == 'preview':
                percentage, title, image = product
                yield gr.update(interactive=False), \
                    gr.update(value=modules.html.make_progress_html(percentage, title)), \
                    gr.update(value=image) if image is not None else gr.update()
            if flag == 'results':
                image = product[0]
                yield gr.update(interactive=True), \
                    gr.update(visible=False), \
                    gr.update(value=image)
                finished = True
    return


shared.gradio_root = gr.Blocks(title='QualityMinds AI Christmas Card Maker', css=modules.html.css)
with shared.gradio_root:
    gr.Markdown(
    """
    # QualityMinds AI Christmas Card Maker
    Type a promt and click generate. Try our examples and different styles.
    """)
    with gr.Row(elem_classes='type_row'):
        with gr.Column(scale=0.7):
            prompt = gr.Textbox(label="Prompt", value="", placeholder="What's on your christmas card?", autofocus=True, elem_classes='type_row', lines=2)
        with gr.Column(scale=0.15, min_width="120px"):
            style_selection = gr.Dropdown(label='Style', choices=style_keys, value='Cinematic', elem_classes="stylebox")
        with gr.Column(scale=0.15, min_width="120px"):
            run_button = gr.Button(label="Generate", value="Generate", variant='primary', elem_classes='generate_button')
            progress_html = gr.HTML(visible=False, elem_id='progress-bar', elem_classes='progress-bar')
    gr.Examples(examples=["Santa Claus with his sack full of gifts", "Scenic winter village inside a snow globe", \
                          "Cute penguins wrapped up in scarves and hats", "Snowy trees and a reindeer"], inputs=[prompt], cache_examples=False)
    generated_image = gr.Image(show_label=False, width=1280, value="resources/init.png", show_share_button=True )

    run_button.click(fn=generate, inputs=[prompt, style_selection], outputs=[run_button, progress_html, generated_image])

shared.gradio_root.queue(concurrency_count=1, api_open=False)
shared.gradio_root.launch(server_name="0.0.0.0", show_api=False)