Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,15 +141,16 @@ with gr.Blocks(css=css, title="ZenCtrl Inpainting") as demo:
|
|
| 141 |
bg_img = gr.Image(label="Background", visible=True)
|
| 142 |
|
| 143 |
# ---------- Example wrapper ---------------------------------
|
| 144 |
-
def _run_example(
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
| 153 |
|
| 154 |
# ---------- Examples ----------------------------------------
|
| 155 |
gr.Examples(
|
|
@@ -163,6 +164,7 @@ with gr.Blocks(css=css, title="ZenCtrl Inpainting") as demo:
|
|
| 163 |
],
|
| 164 |
inputs=[subj_img, ref_img, promptbox],
|
| 165 |
outputs=[output_img],
|
|
|
|
| 166 |
label="Visual Presets: Subject · Background · Prompt · Output",
|
| 167 |
examples_per_page="all"
|
| 168 |
)
|
|
|
|
| 141 |
bg_img = gr.Image(label="Background", visible=True)
|
| 142 |
|
| 143 |
# ---------- Example wrapper ---------------------------------
|
| 144 |
+
def _run_example(subj_path, bg_path, prompt):
|
| 145 |
+
subj = Image.open(subj_path)
|
| 146 |
+
bg = Image.open(bg_path)
|
| 147 |
+
|
| 148 |
+
# Automatically infer output path from naming convention
|
| 149 |
+
# Replace `examples/sofa1.png` → `examples/sofa1_out.png`
|
| 150 |
+
output_path = subj_path.replace(".png", "_out.png")
|
| 151 |
+
result = Image.open(output_path)
|
| 152 |
+
|
| 153 |
+
return result, bg # or just `return result` if not showing background
|
| 154 |
|
| 155 |
# ---------- Examples ----------------------------------------
|
| 156 |
gr.Examples(
|
|
|
|
| 164 |
],
|
| 165 |
inputs=[subj_img, ref_img, promptbox],
|
| 166 |
outputs=[output_img],
|
| 167 |
+
fn=_run_example,
|
| 168 |
label="Visual Presets: Subject · Background · Prompt · Output",
|
| 169 |
examples_per_page="all"
|
| 170 |
)
|