Spaces:
Running
Running
Update app.py
Browse files
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(
|
| 151 |
-
|
| 152 |
-
subj
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
subj,
|
| 156 |
-
|
| 157 |
prompt,
|
| 158 |
use_detect=False,
|
| 159 |
detect_prompt=""
|
| 160 |
)
|
| 161 |
-
|
| 162 |
-
|
|
|
|
| 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(
|