This repo is a packaged version of the segment-anything model.
pip install metaseg
from metaseg import SegAutoMaskPredictor, SegManualMaskPredictor
# If gpu memory is not enough, reduce the points_per_side and points_per_batch.
# For image
autoseg_image = SegAutoMaskPredictor().save_image(
source="image.jpg",
model_type="vit_l", # vit_l, vit_h, vit_b
points_per_side=16,
points_per_batch=64,
min_area=0,
)
# For video
autoseg_video = SegAutoMaskPredictor().save_video(
source="video.mp4",
model_type="vit_l", # vit_l, vit_h, vit_b
points_per_side=16,
points_per_batch=64,
min_area=1000,
)
# For manuel box and point selection
seg_manual_mask_generator = SegManualMaskPredictor().save_image(
source="image.jpg",
model_type="vit_l", # vit_l, vit_h, vit_b
input_point=[[100, 100], [200, 200]],
input_label=[0, 1],
input_box=[100, 100, 200, 200], # x,y,w,h
multimask_output=False,
)
# For multi box selection
seg_manual_mask_generator = SegManualMaskPredictor().save_image(
source="data/brain.png",
model_type="vit_l",
input_point=None,
input_label=None,
input_box= [[100, 100, 400, 400]],
multimask_output=False,
)
- Support for video files
- Support for pip installation
- Support for web application
- Support for manual single multi box and point selection
- Support for automatic download model weights