Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,68 +89,79 @@ css = """
|
|
| 89 |
"""
|
| 90 |
|
| 91 |
with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
| 92 |
-
|
| 93 |
-
gr.Markdown("## FIBO")
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
|
| 105 |
-
with gr.Row():
|
| 106 |
prompt_inspire_image = gr.Image(
|
| 107 |
label="Inspiration Image",
|
| 108 |
type="pil",
|
| 109 |
)
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
label="
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
demo.queue().launch()
|
|
|
|
|
|
| 89 |
"""
|
| 90 |
|
| 91 |
with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
| 92 |
+
gr.Markdown("## FIBO")
|
|
|
|
| 93 |
|
| 94 |
+
# Two-column layout
|
| 95 |
+
with gr.Row(elem_id="col-container"):
|
| 96 |
+
# ==== LEFT COLUMN ====
|
| 97 |
+
with gr.Column():
|
| 98 |
+
with gr.Row():
|
| 99 |
+
with gr.Tab("generate") as tab_generate:
|
| 100 |
+
prompt_generate = gr.Textbox(
|
| 101 |
+
label="Prompt",
|
| 102 |
+
placeholder="a man holding a goose screaming"
|
| 103 |
+
)
|
| 104 |
|
| 105 |
+
with gr.Tab("refine") as tab_refine:
|
| 106 |
+
prompt_refine = gr.Textbox(
|
| 107 |
+
label="Prompt",
|
| 108 |
+
info="describe the change you want to make",
|
| 109 |
+
placeholder="make the cat white"
|
| 110 |
+
)
|
| 111 |
|
| 112 |
+
with gr.Tab("inspire") as tab_inspire:
|
|
|
|
| 113 |
prompt_inspire_image = gr.Image(
|
| 114 |
label="Inspiration Image",
|
| 115 |
type="pil",
|
| 116 |
)
|
| 117 |
+
|
| 118 |
+
submit_btn = gr.Button("Generate", variant="primary")
|
| 119 |
+
|
| 120 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 121 |
+
with gr.Row():
|
| 122 |
+
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
|
| 123 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 124 |
+
with gr.Row():
|
| 125 |
+
guidance_scale = gr.Slider(label="guidance scale", minimum=1.0, maximum=10.0, step=0.1, value=5.0)
|
| 126 |
+
num_inference_steps = gr.Slider(
|
| 127 |
+
label="number of inference steps", minimum=1, maximum=60, step=1, value=50
|
| 128 |
+
)
|
| 129 |
+
height = gr.Slider(label="Height", minimum=768, maximum=1248, step=32, value=1024)
|
| 130 |
+
width = gr.Slider(label="Width", minimum=832, maximum=1344, step=64, value=1024)
|
| 131 |
+
with gr.Row():
|
| 132 |
+
negative_prompt = gr.Textbox(label="negative prompt")
|
| 133 |
+
negative_prompt_json = gr.JSON(label="json negative prompt")
|
| 134 |
+
|
| 135 |
+
# ==== RIGHT COLUMN ====
|
| 136 |
+
with gr.Column():
|
| 137 |
+
result = gr.Image(label="output")
|
| 138 |
+
with gr.Accordion("Structured Prompt", open=False) as structured_accordion:
|
| 139 |
+
prompt_in_json = gr.JSON(label="json structured prompt")
|
| 140 |
+
|
| 141 |
+
# Track active tab
|
| 142 |
+
current_mode = gr.State("generate")
|
| 143 |
+
tab_generate.select(lambda: "generate", outputs=current_mode)
|
| 144 |
+
tab_refine.select(lambda: "refine", outputs=current_mode)
|
| 145 |
+
tab_inspire.select(lambda: "inspire", outputs=current_mode)
|
| 146 |
+
|
| 147 |
+
submit_btn.click(
|
| 148 |
+
fn=infer,
|
| 149 |
+
inputs=[
|
| 150 |
+
prompt_generate,
|
| 151 |
+
prompt_refine,
|
| 152 |
+
prompt_inspire_image,
|
| 153 |
+
prompt_in_json,
|
| 154 |
+
negative_prompt,
|
| 155 |
+
seed,
|
| 156 |
+
randomize_seed,
|
| 157 |
+
width,
|
| 158 |
+
height,
|
| 159 |
+
guidance_scale,
|
| 160 |
+
num_inference_steps,
|
| 161 |
+
current_mode,
|
| 162 |
+
],
|
| 163 |
+
outputs=[result, seed, prompt_in_json, negative_prompt_json, structured_accordion],
|
| 164 |
+
)
|
| 165 |
|
| 166 |
demo.queue().launch()
|
| 167 |
+
|