app.py
Browse files
app.py
CHANGED
@@ -28,22 +28,16 @@ def update_imgbox(choices):
|
|
28 |
choices_plus = extend_choices(choices)
|
29 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
30 |
|
31 |
-
def gen_fn(model_str, prompt
|
32 |
if model_str == 'NA':
|
33 |
return None
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
# Prepare the full prompt with negative prompt and CFG scale
|
38 |
-
full_prompt = f'{prompt} --negative_prompt "{negative_prompt}" --cfg_scale {cfg_scale} --sampler {sampler} --seed {noise}'
|
39 |
-
|
40 |
-
return models_load[model_str](full_prompt)
|
41 |
|
42 |
def make_me():
|
43 |
with gr.Row():
|
44 |
with gr.Column(scale=4):
|
45 |
txt_input = gr.Textbox(label='Your prompt:', lines=4, container=False, elem_id="custom_textbox", placeholder="Prompt", height=250)
|
46 |
-
negative_prompt = gr.Textbox(label='Negative Prompt:', lines=2, placeholder="What to avoid in the image", elem_id="custom_negative_prompt")
|
47 |
|
48 |
with gr.Column(scale=1):
|
49 |
gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
|
@@ -59,20 +53,10 @@ def make_me():
|
|
59 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
60 |
|
61 |
with gr.Row():
|
62 |
-
output = [gr.Image(label=m, width=
|
63 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
64 |
-
|
65 |
-
# Additional inputs for CFG, sampler, seed, and negative prompt
|
66 |
-
cfg_scale = gr.Slider(minimum=1, maximum=20, step=0.1, value=7, label="CFG Scale", elem_id="custom_cfg_scale")
|
67 |
-
sampler = gr.Dropdown(choices=["DDIM", "PLMS", "Euler", "Heun"], value="DDIM", label="Sampler", elem_id="custom_sampler")
|
68 |
-
seed = gr.Number(value=-1, label="Seed (-1 for random)", elem_id="custom_seed")
|
69 |
-
|
70 |
for m, o in zip(current_models, output):
|
71 |
-
gen_event = gen_button.click(
|
72 |
-
gen_fn,
|
73 |
-
[m, txt_input, negative_prompt, cfg_scale, sampler, seed],
|
74 |
-
o
|
75 |
-
)
|
76 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
|
77 |
|
78 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|
|
|
28 |
choices_plus = extend_choices(choices)
|
29 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
30 |
|
31 |
+
def gen_fn(model_str, prompt):
|
32 |
if model_str == 'NA':
|
33 |
return None
|
34 |
+
noise = str(randint(0, 99999999))
|
35 |
+
return models_load[model_str](f'{prompt} {noise}')
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
def make_me():
|
38 |
with gr.Row():
|
39 |
with gr.Column(scale=4):
|
40 |
txt_input = gr.Textbox(label='Your prompt:', lines=4, container=False, elem_id="custom_textbox", placeholder="Prompt", height=250)
|
|
|
41 |
|
42 |
with gr.Column(scale=1):
|
43 |
gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
|
|
|
53 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
54 |
|
55 |
with gr.Row():
|
56 |
+
output = [gr.Image(label=m, width=512, max_height=768, elem_id="custom_image", show_label=True, interactive=False, show_share_button=False) for m in default_models]
|
57 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
for m, o in zip(current_models, output):
|
59 |
+
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
|
|
|
|
|
|
|
|
60 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
|
61 |
|
62 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|