Spaces:
Running
on
Zero
Running
on
Zero
wondervictor
commited on
Commit
•
698ff57
1
Parent(s):
98a4644
update
Browse files- .DS_Store +0 -0
- .vscode/sftp.json +12 -0
- model/.DS_Store +0 -0
- model/segment_anything_2/sam2/utils/misc.py +16 -15
- requirements.txt +1 -1
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
.vscode/sftp.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "devcloud",
|
3 |
+
"host": "9.134.244.213",
|
4 |
+
"protocol": "sftp",
|
5 |
+
"port": 36000,
|
6 |
+
"username": "adriancheng",
|
7 |
+
"privateKeyPath": "/Users/tianhengcheng/.ssh/9.134.244.213_rsa",
|
8 |
+
"remotePath": "/group/40034/adriancheng/evf-sam2",
|
9 |
+
"uploadOnSave": false,
|
10 |
+
"useTempFile": false,
|
11 |
+
"openSsh": false
|
12 |
+
}
|
model/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
model/segment_anything_2/sam2/utils/misc.py
CHANGED
@@ -43,24 +43,25 @@ def get_sdpa_settings():
|
|
43 |
|
44 |
return old_gpu, use_flash_attn, math_kernel_on
|
45 |
|
|
|
46 |
|
47 |
-
def get_connected_components(mask):
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
|
66 |
def mask_to_box(masks: torch.Tensor):
|
|
|
43 |
|
44 |
return old_gpu, use_flash_attn, math_kernel_on
|
45 |
|
46 |
+
from sam2.utils.misc import get_connected_components
|
47 |
|
48 |
+
# def get_connected_components(mask):
|
49 |
+
# """
|
50 |
+
# Get the connected components (8-connectivity) of binary masks of shape (N, 1, H, W).
|
51 |
|
52 |
+
# Inputs:
|
53 |
+
# - mask: A binary mask tensor of shape (N, 1, H, W), where 1 is foreground and 0 is
|
54 |
+
# background.
|
55 |
+
|
56 |
+
# Outputs:
|
57 |
+
# - labels: A tensor of shape (N, 1, H, W) containing the connected component labels
|
58 |
+
# for foreground pixels and 0 for background pixels.
|
59 |
+
# - counts: A tensor of shape (N, 1, H, W) containing the area of the connected
|
60 |
+
# components for foreground pixels and 0 for background pixels.
|
61 |
+
# """
|
62 |
+
# from model.segment_anything_2.sam2 import _C
|
63 |
|
64 |
+
# return _C.get_connected_componnets(mask.to(torch.uint8).contiguous())
|
65 |
|
66 |
|
67 |
def mask_to_box(masks: torch.Tensor):
|
requirements.txt
CHANGED
@@ -30,7 +30,7 @@ deepspeed
|
|
30 |
pycocoevalcap
|
31 |
torchscale
|
32 |
gradio
|
33 |
-
timm
|
34 |
samv2
|
35 |
torch
|
36 |
hydra-core
|
|
|
30 |
pycocoevalcap
|
31 |
torchscale
|
32 |
gradio
|
33 |
+
timm
|
34 |
samv2
|
35 |
torch
|
36 |
hydra-core
|