Spaces:
Running
on
T4
Running
on
T4
Tony Lian
commited on
Commit
•
aca39c8
1
Parent(s):
e6327f4
Update instructions
Browse files
app.py
CHANGED
@@ -52,7 +52,11 @@ def get_layout_image_gallery(response):
|
|
52 |
|
53 |
def get_ours_image(response, overall_prompt_override="", seed=0, num_inference_steps=250, dpm_scheduler=True, use_autocast=False, fg_seed_start=20, fg_blending_ratio=0.1, frozen_step_ratio=0.5, attn_guidance_step_ratio=0.6, gligen_scheduled_sampling_beta=0.4, attn_guidance_scale=20, use_ref_ca=True, so_negative_prompt=DEFAULT_SO_NEGATIVE_PROMPT, overall_negative_prompt=DEFAULT_OVERALL_NEGATIVE_PROMPT, show_so_imgs=False, scale_boxes=False):
|
54 |
if response == "":
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
gen_boxes, bg_prompt, neg_prompt = parse_input_with_negative(response, no_input=True)
|
57 |
gen_boxes = filter_boxes(gen_boxes, scale_boxes=scale_boxes)
|
58 |
spec = {
|
@@ -117,9 +121,9 @@ def preset_change(preset):
|
|
117 |
# frozen_step_ratio, attn_guidance_step_ratio, attn_guidance_scale, use_ref_ca, so_negative_prompt
|
118 |
if preset == "Standard":
|
119 |
return gr.update(value=0.5, interactive=True), gr.update(value=0.6, interactive=True), gr.update(interactive=True), gr.update(value=True, interactive=True), gr.update(interactive=True)
|
120 |
-
elif preset == "Faster (disable attention guidance)":
|
121 |
return gr.update(value=0.5, interactive=True), gr.update(value=0, interactive=False), gr.update(interactive=False), gr.update(value=True, interactive=True), gr.update(interactive=True)
|
122 |
-
elif preset == "Faster (disable per-box guidance)":
|
123 |
return gr.update(value=0, interactive=False), gr.update(value=0.6, interactive=True), gr.update(interactive=True), gr.update(value=False, interactive=False), gr.update(interactive=False)
|
124 |
elif preset == "Fastest (disable both)":
|
125 |
return gr.update(value=0, interactive=False), gr.update(value=0, interactive=False), gr.update(interactive=False), gr.update(value=False, interactive=False), gr.update(interactive=True)
|
@@ -158,7 +162,7 @@ with gr.Blocks(
|
|
158 |
response = gr.Textbox(lines=8, label="Paste ChatGPT response here (no original caption needed here)", placeholder=layout_placeholder)
|
159 |
num_inference_steps = gr.Slider(1, 100 if low_memory else 250, value=default_num_inference_steps, step=1, label="Number of denoising steps (set to >=50 for higher generation quality)")
|
160 |
# Using a environment variable allows setting default to faster/fastest on low-end GPUs.
|
161 |
-
preset = gr.Radio(label="Guidance: apply less control for faster generation", choices=["Standard", "Faster (disable attention guidance)", "Faster (disable per-box guidance)", "Fastest (disable both)"], value="Faster (disable attention guidance)" if low_memory else "Standard")
|
162 |
seed = gr.Slider(0, 10000, value=0, step=1, label="Seed")
|
163 |
with gr.Accordion("Advanced options (play around for better generation)", open=False):
|
164 |
with gr.Tab("Guidance"):
|
|
|
52 |
|
53 |
def get_ours_image(response, overall_prompt_override="", seed=0, num_inference_steps=250, dpm_scheduler=True, use_autocast=False, fg_seed_start=20, fg_blending_ratio=0.1, frozen_step_ratio=0.5, attn_guidance_step_ratio=0.6, gligen_scheduled_sampling_beta=0.4, attn_guidance_scale=20, use_ref_ca=True, so_negative_prompt=DEFAULT_SO_NEGATIVE_PROMPT, overall_negative_prompt=DEFAULT_OVERALL_NEGATIVE_PROMPT, show_so_imgs=False, scale_boxes=False):
|
54 |
if response == "":
|
55 |
+
if overall_prompt_override == "":
|
56 |
+
# Both are empty so generate a placeholder
|
57 |
+
response = layout_placeholder
|
58 |
+
else:
|
59 |
+
raise gr.Error("Please paste ChatGPT response in the text box or select an example below to get started.")
|
60 |
gen_boxes, bg_prompt, neg_prompt = parse_input_with_negative(response, no_input=True)
|
61 |
gen_boxes = filter_boxes(gen_boxes, scale_boxes=scale_boxes)
|
62 |
spec = {
|
|
|
121 |
# frozen_step_ratio, attn_guidance_step_ratio, attn_guidance_scale, use_ref_ca, so_negative_prompt
|
122 |
if preset == "Standard":
|
123 |
return gr.update(value=0.5, interactive=True), gr.update(value=0.6, interactive=True), gr.update(interactive=True), gr.update(value=True, interactive=True), gr.update(interactive=True)
|
124 |
+
elif preset == "Faster (disable attention guidance, keep per-box guidance)":
|
125 |
return gr.update(value=0.5, interactive=True), gr.update(value=0, interactive=False), gr.update(interactive=False), gr.update(value=True, interactive=True), gr.update(interactive=True)
|
126 |
+
elif preset == "Faster (disable per-box guidance, keep attention guidance)":
|
127 |
return gr.update(value=0, interactive=False), gr.update(value=0.6, interactive=True), gr.update(interactive=True), gr.update(value=False, interactive=False), gr.update(interactive=False)
|
128 |
elif preset == "Fastest (disable both)":
|
129 |
return gr.update(value=0, interactive=False), gr.update(value=0, interactive=False), gr.update(interactive=False), gr.update(value=False, interactive=False), gr.update(interactive=True)
|
|
|
162 |
response = gr.Textbox(lines=8, label="Paste ChatGPT response here (no original caption needed here)", placeholder=layout_placeholder)
|
163 |
num_inference_steps = gr.Slider(1, 100 if low_memory else 250, value=default_num_inference_steps, step=1, label="Number of denoising steps (set to >=50 for higher generation quality)")
|
164 |
# Using a environment variable allows setting default to faster/fastest on low-end GPUs.
|
165 |
+
preset = gr.Radio(label="Guidance: apply less control for faster generation", choices=["Standard", "Faster (disable attention guidance, keep per-box guidance)", "Faster (disable per-box guidance, keep attention guidance)", "Fastest (disable both)"], value="Faster (disable attention guidance)" if low_memory else "Standard")
|
166 |
seed = gr.Slider(0, 10000, value=0, step=1, label="Seed")
|
167 |
with gr.Accordion("Advanced options (play around for better generation)", open=False):
|
168 |
with gr.Tab("Guidance"):
|