salso commited on
Commit
0bf2b25
·
verified ·
1 Parent(s): 6380b70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -146,20 +146,28 @@ with gr.Blocks(css=css, title="ZenCtrl Inpainting") as demo:
146
  bg_img = gr.Image(label="Background", visible=False)
147
 
148
  # ---------- Example wrapper ---------------------------------
149
- from PIL import Image
150
- def _run_example(subj_path, bg_path, prompt):
151
- """Convert the plain bg image to the dict format and run generation."""
152
- subj = Image.open(subj_path)
153
- bg = Image.open(bg_path)
154
- outputs, _ = process_image_and_text(
 
 
 
 
 
 
 
155
  subj,
156
- {"image": bg, "mask": None}, # wrap as dict for pipeline
157
  prompt,
158
  use_detect=False,
159
  detect_prompt=""
160
  )
161
- # Return generation + also show bg in the sketch component so user can draw
162
- return outputs[0], gr.update(value=bg) # gallery, ref_img update
 
163
 
164
  # ---------- Examples ----------------------------------------
165
  gr.Examples(
 
146
  bg_img = gr.Image(label="Background", visible=False)
147
 
148
  # ---------- Example wrapper ---------------------------------
149
+ #from PIL import Image
150
+ def _run_example(subj, bg, prompt):
151
+ # 1️⃣ Ensure we have PIL.Image objects
152
+ if isinstance(subj, str):
153
+ subj = Image.open(subj)
154
+ if isinstance(bg, str):
155
+ bg = Image.open(bg)
156
+
157
+ # 2️⃣ Wrap background for pipeline (no mask)
158
+ adapter_dict = {"image": bg, "mask": None}
159
+
160
+ # 3️⃣ Call your real pipeline
161
+ gallery_out, _ = process_image_and_text(
162
  subj,
163
+ adapter_dict,
164
  prompt,
165
  use_detect=False,
166
  detect_prompt=""
167
  )
168
+
169
+ # 4️⃣ Also show the bg in the visible sketch component so user can draw
170
+ return gallery_out, gr.update(value=bg)
171
 
172
  # ---------- Examples ----------------------------------------
173
  gr.Examples(