MobileSAM
MobileSAM copied to clipboard
Error running notebook
Hi, I try to run the notebook https://github.com/ChaoningZhang/MobileSAM/blob/master/notebooks/automatic_mask_generator_example.ipynb on colab, and I get this error.
Add
!pip install timm
to the import and install of the notebook to fix this issue
On colab you get one more error, when loading the model. Fix with the following code:
import sys
sys.path.append("..")
from mobile_sam import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor
if 'google.colab' in sys.modules:
sam_checkpoint = "/content/mobile_sam.pt"
else:
sam_checkpoint = "../weights/mobile_sam.pt"
model_type = "vit_t"
device = "cuda" if torch.cuda.is_available() else "cpu"
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
sam.to(device=device)
sam.eval()
mask_generator = SamAutomaticMaskGenerator(sam)