John Ho
commited on
Commit
·
a07c563
1
Parent(s):
603e63e
added control for dropping masks from result JSON
Browse files
app.py
CHANGED
|
@@ -119,7 +119,9 @@ def process_image(
|
|
| 119 |
@spaces.GPU
|
| 120 |
@torch.inference_mode()
|
| 121 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
| 122 |
-
def process_video(
|
|
|
|
|
|
|
| 123 |
"""
|
| 124 |
SAM2 Video Segmentation
|
| 125 |
|
|
@@ -144,7 +146,7 @@ def process_video(video_path: str, variant: str, masks: Union[list, str]):
|
|
| 144 |
masks=masks,
|
| 145 |
device="cuda",
|
| 146 |
do_tidy_up=True,
|
| 147 |
-
drop_mask=
|
| 148 |
async_frame_load=True,
|
| 149 |
)
|
| 150 |
|
|
@@ -193,6 +195,7 @@ with gr.Blocks() as demo:
|
|
| 193 |
JSON list of base64 encoded masks, e.g.: ["b'iVBORw0KGgoAAAANSUhEUgAABDgAAAeAAQAAAAADGtqnAAAXz...'",...]
|
| 194 |
""",
|
| 195 |
),
|
|
|
|
| 196 |
],
|
| 197 |
outputs=gr.JSON(label="Output JSON"),
|
| 198 |
title="SAM2 for Videos",
|
|
|
|
| 119 |
@spaces.GPU
|
| 120 |
@torch.inference_mode()
|
| 121 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
| 122 |
+
def process_video(
|
| 123 |
+
video_path: str, variant: str, masks: Union[list, str], drop_masks: bool = False
|
| 124 |
+
):
|
| 125 |
"""
|
| 126 |
SAM2 Video Segmentation
|
| 127 |
|
|
|
|
| 146 |
masks=masks,
|
| 147 |
device="cuda",
|
| 148 |
do_tidy_up=True,
|
| 149 |
+
drop_mask=drop_masks,
|
| 150 |
async_frame_load=True,
|
| 151 |
)
|
| 152 |
|
|
|
|
| 195 |
JSON list of base64 encoded masks, e.g.: ["b'iVBORw0KGgoAAAANSUhEUgAABDgAAAeAAQAAAAADGtqnAAAXz...'",...]
|
| 196 |
""",
|
| 197 |
),
|
| 198 |
+
gr.Checkbox(label="remove base64 encoded masks from result JSON"),
|
| 199 |
],
|
| 200 |
outputs=gr.JSON(label="Output JSON"),
|
| 201 |
title="SAM2 for Videos",
|