Spaces:
Runtime error
Runtime error
Tobias Cornille
commited on
Commit
·
b57f1bb
1
Parent(s):
fe2d465
Add examples + title
Browse files
app.py
CHANGED
|
@@ -383,17 +383,6 @@ clipseg_model = CLIPSegForImageSegmentation.from_pretrained(
|
|
| 383 |
)
|
| 384 |
clipseg_model.to(device)
|
| 385 |
|
| 386 |
-
|
| 387 |
-
title = "Interactive demo: panoptic segment anything"
|
| 388 |
-
description = "Demo for zero-shot panoptic segmentation using Segment Anything, Grounding DINO, and CLIPSeg. To use it, simply upload an image and add a text to mask (identify in the image), or use one of the examples below and click 'submit'."
|
| 389 |
-
article = "<p style='text-align: center'><a href='https://github.com/segments-ai/panoptic-segment-anything'>Github</a></p>"
|
| 390 |
-
|
| 391 |
-
examples = [
|
| 392 |
-
["a2d2.png", "car, bus, person", "road, sky, buildings", 0.3, 0.25, 0.1, 20, 1000],
|
| 393 |
-
["dogs.png", "dog, wooden stick", "sky, sand"],
|
| 394 |
-
["bxl.png", "car, tram, motorcycle, person", "road, buildings, sky"],
|
| 395 |
-
]
|
| 396 |
-
|
| 397 |
if __name__ == "__main__":
|
| 398 |
parser = argparse.ArgumentParser("Panoptic Segment Anything demo", add_help=True)
|
| 399 |
parser.add_argument("--debug", action="store_true", help="using debug mode")
|
|
@@ -402,8 +391,14 @@ if __name__ == "__main__":
|
|
| 402 |
|
| 403 |
print(f"args = {args}")
|
| 404 |
|
| 405 |
-
block = gr.Blocks().queue()
|
| 406 |
with block:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
with gr.Row():
|
| 408 |
with gr.Column():
|
| 409 |
input_image = gr.Image(source="upload", type="pil")
|
|
@@ -456,6 +451,54 @@ if __name__ == "__main__":
|
|
| 456 |
with gr.Column():
|
| 457 |
plot = gr.Plot()
|
| 458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
run_button.click(
|
| 460 |
fn=generate_panoptic_mask,
|
| 461 |
inputs=[
|
|
|
|
| 383 |
)
|
| 384 |
clipseg_model.to(device)
|
| 385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
if __name__ == "__main__":
|
| 387 |
parser = argparse.ArgumentParser("Panoptic Segment Anything demo", add_help=True)
|
| 388 |
parser.add_argument("--debug", action="store_true", help="using debug mode")
|
|
|
|
| 391 |
|
| 392 |
print(f"args = {args}")
|
| 393 |
|
| 394 |
+
block = gr.Blocks(title="Panoptic Segment Anything").queue()
|
| 395 |
with block:
|
| 396 |
+
title = gr.Markdown(
|
| 397 |
+
"# [Panoptic Segment Anything](https://github.com/segments-ai/panoptic-segment-anything): Demo"
|
| 398 |
+
)
|
| 399 |
+
description = gr.Markdown(
|
| 400 |
+
"## Demo for zero-shot panoptic segmentation using Segment Anything, Grounding DINO, and CLIPSeg."
|
| 401 |
+
)
|
| 402 |
with gr.Row():
|
| 403 |
with gr.Column():
|
| 404 |
input_image = gr.Image(source="upload", type="pil")
|
|
|
|
| 451 |
with gr.Column():
|
| 452 |
plot = gr.Plot()
|
| 453 |
|
| 454 |
+
examples = gr.Examples(
|
| 455 |
+
examples=[
|
| 456 |
+
[
|
| 457 |
+
"a2d2.png",
|
| 458 |
+
"car, bus, person",
|
| 459 |
+
"road, sky, buildings",
|
| 460 |
+
0.3,
|
| 461 |
+
0.25,
|
| 462 |
+
0.1,
|
| 463 |
+
20,
|
| 464 |
+
1000,
|
| 465 |
+
],
|
| 466 |
+
[
|
| 467 |
+
"dogs.png",
|
| 468 |
+
"dog, wooden stick",
|
| 469 |
+
"sky, sand",
|
| 470 |
+
0.3,
|
| 471 |
+
0.25,
|
| 472 |
+
0.1,
|
| 473 |
+
20,
|
| 474 |
+
1000,
|
| 475 |
+
],
|
| 476 |
+
[
|
| 477 |
+
"bxl.png",
|
| 478 |
+
"car, tram, motorcycle, person",
|
| 479 |
+
"road, buildings, sky",
|
| 480 |
+
0.3,
|
| 481 |
+
0.25,
|
| 482 |
+
0.1,
|
| 483 |
+
20,
|
| 484 |
+
1000,
|
| 485 |
+
],
|
| 486 |
+
],
|
| 487 |
+
fn=generate_panoptic_mask,
|
| 488 |
+
inputs=[
|
| 489 |
+
input_image,
|
| 490 |
+
thing_category_names_string,
|
| 491 |
+
stuff_category_names_string,
|
| 492 |
+
box_threshold,
|
| 493 |
+
text_threshold,
|
| 494 |
+
segmentation_background_threshold,
|
| 495 |
+
shrink_kernel_size,
|
| 496 |
+
num_samples_factor,
|
| 497 |
+
],
|
| 498 |
+
outputs=[plot],
|
| 499 |
+
cache_examples=True,
|
| 500 |
+
)
|
| 501 |
+
|
| 502 |
run_button.click(
|
| 503 |
fn=generate_panoptic_mask,
|
| 504 |
inputs=[
|