salso commited on
Commit
fa93f10
·
verified ·
1 Parent(s): bd16ee4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
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(subj, bg, prompt):
145
- if isinstance(subj, str):
146
- subj = Image.open(subj)
147
- if isinstance(bg, str):
148
- bg = Image.open(bg)
149
-
150
- adapter_dict = {"image": bg, "mask": None}
151
- gallery_out, _ = process_image_and_text(subj, adapter_dict, prompt, False, "")
152
- return gallery_out, gr.update(value=bg)
 
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
  )