Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -135,42 +135,34 @@ with gr.Blocks(css=css, title="ZenCtrl Inpainting") as demo:
|
|
| 135 |
bg_img = gr.Image(label="Background", visible=True)
|
| 136 |
|
| 137 |
# ---------- Example wrapper ---------------------------------
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
return
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
examples = [
|
| 150 |
-
row("examples/sofa1.png", "examples/sofa1_bg.png", "add the sofa"),
|
| 151 |
-
row("examples/sofa2.png", "examples/sofa2_bg.png", "add this sofa"),
|
| 152 |
-
row("examples/chair1.png", "examples/chair1_bg.png", "add the chair"),
|
| 153 |
-
row("examples/console_table.png",
|
| 154 |
-
"examples/console_table_bg.png",
|
| 155 |
-
"Scandinavian console table against a gallery-style wall filled with abstract framed art"),
|
| 156 |
-
row("examples/office_chair.png", "examples/office_chair_bg.png", "office chair"),
|
| 157 |
-
row("examples/car.png", "examples/car_bg.png", "car on the road"),
|
| 158 |
-
]
|
| 159 |
-
|
| 160 |
-
# identity returns the filled-in widgets unchanged
|
| 161 |
-
def identity(a, b, c):
|
| 162 |
-
return a, b, c
|
| 163 |
-
|
| 164 |
gr.Examples(
|
| 165 |
-
examples
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
)
|
| 173 |
|
|
|
|
| 174 |
# ---------- Buttons & interactions --------------------------
|
| 175 |
# run_btn.click(
|
| 176 |
# process_image_and_text,
|
|
|
|
| 135 |
bg_img = gr.Image(label="Background", visible=True)
|
| 136 |
|
| 137 |
# ---------- Example wrapper ---------------------------------
|
| 138 |
+
def _load_and_show(subj_path, bg_path, prompt_text):
|
| 139 |
+
out_path = subj_path.replace(".png", "_out.png")
|
| 140 |
+
return (
|
| 141 |
+
Image.open(subj_path),
|
| 142 |
+
Image.open(bg_path),
|
| 143 |
+
prompt_text,
|
| 144 |
+
Image.open(out_path)
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
# ---------- Examples ----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
gr.Examples(
|
| 149 |
+
examples=[
|
| 150 |
+
["examples/sofa1_1.png", "examples/sofa1_bg.png", "add the sofa"], #"examples/sofa1_out.png"],
|
| 151 |
+
["examples/sofa2.png", "examples/sofa2_bg.png", "add this sofa"],# "examples/sofa2_out.png"],
|
| 152 |
+
["examples/chair1.png", "examples/chair1_bg.png", "add the chair"], #"examples/chair1_out.png"],
|
| 153 |
+
["examples/console_table.png", "examples/console_table_bg.png", "Scandinavian console table against a gallery-style wall filled with abstract framed art,"], #"examples/console_table_out.png"],
|
| 154 |
+
["examples/office_chair.png", "examples/office_chair_bg.png", "office chair"], #"examples/office_chair_out.png"],
|
| 155 |
+
["examples/car.png", "examples/car_bg.png", "car on the road"], #"examples/car_out.png"],
|
| 156 |
+
],
|
| 157 |
+
inputs=[subj_img, ref_img, promptbox], # three inputs
|
| 158 |
+
outputs=[subj_img, ref_img, promptbox, output_img], #
|
| 159 |
+
fn=_load_and_show,
|
| 160 |
+
label="Visual Presets – Subject · Background · Prompt",
|
| 161 |
+
examples_per_page="all",
|
| 162 |
+
cache_examples=False,
|
| 163 |
)
|
| 164 |
|
| 165 |
+
|
| 166 |
# ---------- Buttons & interactions --------------------------
|
| 167 |
# run_btn.click(
|
| 168 |
# process_image_and_text,
|