Update app.py
Browse files
app.py
CHANGED
|
@@ -272,6 +272,12 @@ footer {visibility: hidden}
|
|
| 272 |
.example-region {margin-top: 2em; padding: 20px; background: #f0f0f0; border-radius: 10px;}
|
| 273 |
"""
|
| 274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
| 276 |
gr.HTML("""
|
| 277 |
<div class="main-title">
|
|
@@ -364,23 +370,31 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 364 |
{
|
| 365 |
"image": "examples/text.jpg",
|
| 366 |
"boxes": [{"xmin": 51, "ymin": 511, "xmax": 639, "ymax": 1255}],
|
|
|
|
|
|
|
| 367 |
},
|
| 368 |
{
|
| 369 |
"image": "examples/potted-plant.jpg",
|
| 370 |
"boxes": [{"xmin": 51, "ymin": 511, "xmax": 639, "ymax": 1255}],
|
|
|
|
| 371 |
},
|
| 372 |
{
|
| 373 |
"image": "examples/chair.jpg",
|
| 374 |
"boxes": [{"xmin": 98, "ymin": 330, "xmax": 973, "ymax": 1468}],
|
|
|
|
| 375 |
},
|
| 376 |
{
|
| 377 |
"image": "examples/black-lamp.jpg",
|
| 378 |
"boxes": [{"xmin": 88, "ymin": 148, "xmax": 700, "ymax": 1414}],
|
|
|
|
|
|
|
| 379 |
},
|
| 380 |
]
|
| 381 |
ex_bb = gr.Examples(
|
| 382 |
examples=examples_bb,
|
| 383 |
-
|
|
|
|
|
|
|
| 384 |
outputs=[oimg_bb, dlbt_bb],
|
| 385 |
fn=process_bbox,
|
| 386 |
cache_examples=True
|
|
@@ -391,7 +405,9 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 391 |
for inp in [iimg, prompt]:
|
| 392 |
inp.change(
|
| 393 |
fn=on_change_prompt,
|
| 394 |
-
|
|
|
|
|
|
|
| 395 |
outputs=[btn],
|
| 396 |
)
|
| 397 |
btn.click(
|
|
|
|
| 272 |
.example-region {margin-top: 2em; padding: 20px; background: #f0f0f0; border-radius: 10px;}
|
| 273 |
"""
|
| 274 |
|
| 275 |
+
def process_prompt(img: Image.Image, prompt: str, bg_prompt: str = None) -> tuple[tuple[Image.Image, Image.Image], gr.DownloadButton]:
|
| 276 |
+
return _process(img, prompt, bg_prompt)
|
| 277 |
+
|
| 278 |
+
def on_change_prompt(img: Image.Image | None, prompt: str | None, bg_prompt: str | None = None):
|
| 279 |
+
return gr.update(interactive=bool(img and prompt))
|
| 280 |
+
|
| 281 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
| 282 |
gr.HTML("""
|
| 283 |
<div class="main-title">
|
|
|
|
| 370 |
{
|
| 371 |
"image": "examples/text.jpg",
|
| 372 |
"boxes": [{"xmin": 51, "ymin": 511, "xmax": 639, "ymax": 1255}],
|
| 373 |
+
"white background" # bg_prompt 예제 추가
|
| 374 |
+
|
| 375 |
},
|
| 376 |
{
|
| 377 |
"image": "examples/potted-plant.jpg",
|
| 378 |
"boxes": [{"xmin": 51, "ymin": 511, "xmax": 639, "ymax": 1255}],
|
| 379 |
+
"natural garden background"
|
| 380 |
},
|
| 381 |
{
|
| 382 |
"image": "examples/chair.jpg",
|
| 383 |
"boxes": [{"xmin": 98, "ymin": 330, "xmax": 973, "ymax": 1468}],
|
| 384 |
+
"modern living room"
|
| 385 |
},
|
| 386 |
{
|
| 387 |
"image": "examples/black-lamp.jpg",
|
| 388 |
"boxes": [{"xmin": 88, "ymin": 148, "xmax": 700, "ymax": 1414}],
|
| 389 |
+
"minimalist interior"
|
| 390 |
+
|
| 391 |
},
|
| 392 |
]
|
| 393 |
ex_bb = gr.Examples(
|
| 394 |
examples=examples_bb,
|
| 395 |
+
|
| 396 |
+
inputs=[iimg, prompt, bg_prompt], # bg_prompt 추가
|
| 397 |
+
|
| 398 |
outputs=[oimg_bb, dlbt_bb],
|
| 399 |
fn=process_bbox,
|
| 400 |
cache_examples=True
|
|
|
|
| 405 |
for inp in [iimg, prompt]:
|
| 406 |
inp.change(
|
| 407 |
fn=on_change_prompt,
|
| 408 |
+
|
| 409 |
+
inputs=[iimg, prompt, bg_prompt], # bg_prompt 추가
|
| 410 |
+
|
| 411 |
outputs=[btn],
|
| 412 |
)
|
| 413 |
btn.click(
|