salso commited on
Commit
5a9de69
·
verified ·
1 Parent(s): 1d8646d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -135,27 +135,35 @@ with gr.Blocks(css=css, title="ZenCtrl Inpainting") as demo:
135
  bg_img = gr.Image(label="Background", visible=True)
136
 
137
  # ---------- Example wrapper ---------------------------------
138
- from pathlib import Path
139
- def load_pil(p): # tiny helper
140
- return Image.open(Path(p))
 
 
 
141
 
142
  examples = [
143
- # subject path background-image path prompt
144
- ["examples/sofa1.png", "examples/sofa1_bg.png", "add the sofa"],
145
- ["examples/sofa2.png", "examples/sofa2_bg.png", "add this sofa"],
146
- ["examples/chair1.png", "examples/chair1_bg.png", "add the chair"],
147
- ["examples/console_table.png","examples/console_table_bg.png",
148
- "Scandinavian console table against a gallery-style wall filled with abstract framed art"],
149
- ["examples/office_chair.png","examples/office_chair_bg.png", "office chair"],
150
- ["examples/car.png", "examples/car_bg.png", "car on the road"],
151
  ]
152
 
 
 
 
153
  gr.Examples(
154
- examples = examples, # ← plain strings only
155
- inputs = [subj_img, ref_img, promptbox],
156
- label = "Visual Presets Subject · Background · Prompt",
157
- cache_examples = False,
158
- examples_per_page= "all",
 
 
 
159
  )
160
 
161
  # ---------- Buttons & interactions --------------------------
 
135
  bg_img = gr.Image(label="Background", visible=True)
136
 
137
  # ---------- Example wrapper ---------------------------------
138
+ def ex(subj, bg): # ← both string paths
139
+ return [
140
+ subj, # goes to subj_img (Image widget)
141
+ {"image": bg, "mask": None}, # goes to ref_img (sketch widget)
142
+ "prompt text here" # goes to promptbox (Textbox)
143
+ ]
144
 
145
  examples = [
146
+ ex("examples/sofa1.png", "examples/sofa1_bg.png")[:2] + ["add the sofa"],
147
+ ex("examples/sofa2.png", "examples/sofa2_bg.png")[:2] + ["add this sofa"],
148
+ ex("examples/chair1.png", "examples/chair1_bg.png")[:2] + ["add the chair"],
149
+ ex("examples/console_table.png", "examples/console_table_bg.png")[:2] +
150
+ ["Scandinavian console table against a gallery-style wall filled with abstract framed art"],
151
+ ex("examples/office_chair.png", "examples/office_chair_bg.png")[:2] + ["office chair"],
152
+ ex("examples/car.png", "examples/car_bg.png")[:2] + ["car on the road"],
 
153
  ]
154
 
155
+ def identity(a, b, c): # just pass the filled widgets straight back
156
+ return a, b, c
157
+
158
  gr.Examples(
159
+ examples = examples,
160
+ inputs = [subj_img, ref_img, promptbox],
161
+ outputs = [subj_img, ref_img, promptbox], # <- MUST match `identity`
162
+ fn = identity, # <- avoids missing table
163
+ cache_examples = False, # fine now
164
+ preprocess = False, # data already in widget form
165
+ label = "Visual Presets – Subject · Background · Prompt",
166
+ examples_per_page = "all",
167
  )
168
 
169
  # ---------- Buttons & interactions --------------------------