Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -135,33 +135,38 @@ 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 |
return [
|
| 140 |
-
|
| 141 |
-
{"image":
|
| 142 |
-
|
| 143 |
]
|
| 144 |
|
| 145 |
examples = [
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
| 153 |
]
|
| 154 |
|
| 155 |
-
|
|
|
|
| 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], #
|
| 162 |
-
fn = identity,
|
| 163 |
-
cache_examples = False,
|
| 164 |
-
preprocess = False, # data already in widget form
|
| 165 |
label = "Visual Presets – Subject · Background · Prompt",
|
| 166 |
examples_per_page = "all",
|
| 167 |
)
|
|
|
|
| 135 |
bg_img = gr.Image(label="Background", visible=True)
|
| 136 |
|
| 137 |
# ---------- Example wrapper ---------------------------------
|
| 138 |
+
from pathlib import Path
|
| 139 |
+
def pil(path): # open once, keep handles alive for the table
|
| 140 |
+
return Image.open(Path(path))
|
| 141 |
+
|
| 142 |
+
def row(subj_path, bg_path, prompt):
|
| 143 |
return [
|
| 144 |
+
pil(subj_path), # goes to subj_img (Image widget)
|
| 145 |
+
{"image": pil(bg_path), "mask": None}, # → ref_img (sketch widget)
|
| 146 |
+
prompt # → promptbox (Textbox)
|
| 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 = examples,
|
| 166 |
inputs = [subj_img, ref_img, promptbox],
|
| 167 |
+
outputs = [subj_img, ref_img, promptbox], # must match `identity`
|
| 168 |
+
fn = identity,
|
| 169 |
+
cache_examples = False, # fine – we’re not pre-computing anything
|
|
|
|
| 170 |
label = "Visual Presets – Subject · Background · Prompt",
|
| 171 |
examples_per_page = "all",
|
| 172 |
)
|