Skip to content

Commit

Permalink
fixed toml sam-2 dependency; clean-up after post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
mese79 committed Nov 7, 2024
1 parent 8f1c8d9 commit 9d4ca5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies = [
"iopath>=0.1.10",
"timm==1.0.9",
"segment-anything-py",
"sam2 @ git+https://github.com/facebookresearch/sam2.git"
"sam-2 @ git+https://github.com/facebookresearch/sam2.git"
]
[project.optional-dependencies]
# development dependencies and tooling
Expand Down
8 changes: 8 additions & 0 deletions src/featureforest/postprocess/postprocess_with_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def postprocess_with_sam(
# put the final label mask into final result mask
final_mask[sam_label_mask] = label

# clean-up
del predictor
torch.cuda.empty_cache()

return final_mask


Expand Down Expand Up @@ -232,6 +236,10 @@ def get_sam_auto_masks(input_image: np.ndarray) -> Tuple[np.ndarray, np.ndarray]
sam_masks = np.array([mask["segmentation"] for mask in sam_generated_masks])
sam_areas = np.array([mask["area"] for mask in sam_generated_masks])

# clean-up
del mask_generator
torch.cuda.empty_cache()

return sam_masks, sam_areas


Expand Down

0 comments on commit 9d4ca5e

Please sign in to comment.