Spaces:
Running
Running
risunobushi
commited on
Commit
·
abce027
1
Parent(s):
f55be02
Add hidden mask image component for API access
Browse files- Add mask_in component with visible=False to keep UI clean
- Update generate function parameter order to match Gradio inputs
- Mask component is hidden from web UI but available for API users
- Enables ComfyUI and other API integrations to pass optional mask images
app.py
CHANGED
|
@@ -281,8 +281,8 @@ def generate(
|
|
| 281 |
base_img: Image.Image,
|
| 282 |
garment_img: Image.Image,
|
| 283 |
workflow_choice: str,
|
| 284 |
-
|
| 285 |
-
|
| 286 |
) -> Image.Image:
|
| 287 |
if base_img is None or garment_img is None:
|
| 288 |
raise gr.Error("Please provide both images.")
|
|
@@ -462,6 +462,13 @@ with gr.Blocks(title="YOURMIRROR.IO - SM4LL-VTON Demo") as demo:
|
|
| 462 |
height=IMG_SIZE,
|
| 463 |
width=IMG_SIZE,
|
| 464 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
|
| 466 |
# Third column: Result
|
| 467 |
with gr.Column(scale=2):
|
|
@@ -528,7 +535,7 @@ with gr.Blocks(title="YOURMIRROR.IO - SM4LL-VTON Demo") as demo:
|
|
| 528 |
# Wire up interaction
|
| 529 |
generate_btn.click(
|
| 530 |
generate,
|
| 531 |
-
inputs=[base_in, garment_in, workflow_selector],
|
| 532 |
outputs=result_out,
|
| 533 |
)
|
| 534 |
|
|
|
|
| 281 |
base_img: Image.Image,
|
| 282 |
garment_img: Image.Image,
|
| 283 |
workflow_choice: str,
|
| 284 |
+
mask_img: Optional[Image.Image], # NEW: Optional mask parameter
|
| 285 |
+
request: gr.Request
|
| 286 |
) -> Image.Image:
|
| 287 |
if base_img is None or garment_img is None:
|
| 288 |
raise gr.Error("Please provide both images.")
|
|
|
|
| 462 |
height=IMG_SIZE,
|
| 463 |
width=IMG_SIZE,
|
| 464 |
)
|
| 465 |
+
mask_in = gr.Image(
|
| 466 |
+
label="Mask Image (Optional)",
|
| 467 |
+
type="pil",
|
| 468 |
+
height=IMG_SIZE,
|
| 469 |
+
width=IMG_SIZE,
|
| 470 |
+
visible=False, # Hidden from UI but available for API
|
| 471 |
+
)
|
| 472 |
|
| 473 |
# Third column: Result
|
| 474 |
with gr.Column(scale=2):
|
|
|
|
| 535 |
# Wire up interaction
|
| 536 |
generate_btn.click(
|
| 537 |
generate,
|
| 538 |
+
inputs=[base_in, garment_in, workflow_selector, mask_in],
|
| 539 |
outputs=result_out,
|
| 540 |
)
|
| 541 |
|