Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,11 @@ def select_model(model_name):
|
|
26 |
return API_BASE_URL + model_name
|
27 |
|
28 |
def extend_prompt(input_text):
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
payload = {"inputs": input_text}
|
32 |
|
@@ -37,6 +41,10 @@ def extend_prompt(input_text):
|
|
37 |
return extended_prompt
|
38 |
|
39 |
def generate_image(prompt, selected_model, is_negative=False, steps=1, cfg_scale=6, seed=None):
|
|
|
|
|
|
|
|
|
40 |
model_url = select_model(selected_model)
|
41 |
API_URL = f"{model_url}"
|
42 |
|
@@ -80,15 +88,6 @@ with gr.Blocks(theme="soft") as playground:
|
|
80 |
with gr.Accordion("Advanced settings", open=False):
|
81 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
|
82 |
|
83 |
-
gr.HTML(
|
84 |
-
"""
|
85 |
-
<h2>Notes:</h2>
|
86 |
-
<p>
|
87 |
-
SDXL based models may take longer to generate than older models.
|
88 |
-
</p>
|
89 |
-
"""
|
90 |
-
)
|
91 |
-
|
92 |
gen_button.click(generate_image, inputs=[text_prompt, model_dropdown, negative_prompt], outputs=image_output)
|
93 |
extend_button.click(extend_prompt, inputs=text_prompt, outputs=text_prompt)
|
94 |
|
|
|
26 |
return API_BASE_URL + model_name
|
27 |
|
28 |
def extend_prompt(input_text):
|
29 |
+
if not input_text.strip():
|
30 |
+
gr.Warning("Input text is empty!")
|
31 |
+
return None
|
32 |
+
|
33 |
+
API_URL = API_BASE_URL + "Gustavosta/MagicPrompt-Stable-Diffusion"
|
34 |
|
35 |
payload = {"inputs": input_text}
|
36 |
|
|
|
41 |
return extended_prompt
|
42 |
|
43 |
def generate_image(prompt, selected_model, is_negative=False, steps=1, cfg_scale=6, seed=None):
|
44 |
+
if not input_text.strip():
|
45 |
+
gr.Warning("Input text is empty!")
|
46 |
+
return None
|
47 |
+
|
48 |
model_url = select_model(selected_model)
|
49 |
API_URL = f"{model_url}"
|
50 |
|
|
|
88 |
with gr.Accordion("Advanced settings", open=False):
|
89 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
gen_button.click(generate_image, inputs=[text_prompt, model_dropdown, negative_prompt], outputs=image_output)
|
92 |
extend_button.click(extend_prompt, inputs=text_prompt, outputs=text_prompt)
|
93 |
|