Skip to content

Commit c5569a5

Browse files
committed
update model path
1 parent 01cee1a commit c5569a5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sam2_image.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def sam2_image_seg(image_path, prompt=None, output_path=None):
2121
np.ndarray: Segmentation mask
2222
"""
2323
# Model paths
24-
checkpoint = "/home/ti_wang/AmadeusGPT/sam2/checkpoints/sam2.1_hiera_small.pt"
24+
# checkpoint = "~/SAM2/checkpoints/sam2.1_hiera_small.pt"
25+
checkpoint = os.path.expanduser("~/SAM2/checkpoints/sam2.1_hiera_small.pt")
2526
model_cfg = "configs/sam2.1/sam2.1_hiera_s.yaml"
2627

2728
# Initialize predictor
@@ -72,9 +73,11 @@ def sam2_image_seg(image_path, prompt=None, output_path=None):
7273
plt.title("Image with Predicted Mask")
7374
plt.savefig(output_path)
7475
plt.close()
75-
76+
7677
return masks
7778

79+
# from SAM.sam2_image import sam2_image_seg
80+
# from sam2.build_sam import build_sam2
7881

7982
if __name__ == "__main__":
8083

@@ -103,6 +106,6 @@ def sam2_image_seg(image_path, prompt=None, output_path=None):
103106
# plt.title("Image with Predicted Mask")
104107
# plt.savefig("./test_images/mask_overlay.png") # Save the figure
105108

106-
image_path = "./sam2/notebooks/images/truck.jpg"
107-
output_path = "./ti_test/mask_overlay_2.png"
109+
image_path = "./SAM/notebooks/images/truck.jpg"
110+
output_path = "./ti_test/mask_overlay_4.png"
108111
sam2_image_seg(image_path, output_path=output_path)

0 commit comments

Comments
 (0)