Tool Sharing#
MobileSAM is smaller and faster than FastSAM, and its processing flow is closer to SAM.
Features#
MobileSAM is about 7 times smaller and 5 times faster than the current FastSAM, and its key feature is being fast and good.
Deployment#
-
Install the project
git clone git@github.com:ChaoningZhang/MobileSAM.git && cd MobileSAM pip install -e .
-
Usage
from mobile_sam import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor model_type = "vit_t" sam_checkpoint = "./weights/mobile_sam.pt" device = "cuda" if torch.cuda.is_available() else "cpu" mobile_sam = sam_model_registry[model_type](checkpoint=sam_checkpoint) mobile_sam.to(device=device) mobile_sam.eval() predictor = SamPredictor(mobile_sam) predictor.set_image(<your_image>) # Input prompt masks, _, _ = predictor.predict(<input_prompts>)
Platform#
Disclaimer#
This article is only intended as a tool sharing record.
This article is synchronized with HBlog.