1.在本地克隆存储库:
git clone https://github.com/chongzhou96/EdgeSAM.git && cd EdgeSAM
2.安装其他依赖性
pip install -r requirements.txt
但是加载huggingface.co时卡住,
解决方案:查询到huggingface.co已无法访问,通过镜像网站hf-mirror.com.将 Huggingface 的模型文件链接中的 `huggingface.co` 替换为 `hf-mirror.com`
安装pycocotool时候卡住了,解决方案:修改requirements.txt文件,将版本2.0.6修改为2.0.7
3.使用该模型,获得掩码
from edge_sam import SamPredictor, sam_model_registry
sam = sam_model_registry["edge_sam"](checkpoint="<path/to/checkpoint>")
predictor = SamPredictor(sam)
predictor.set_image(<your_image>)
masks, _, _ = predictor.predict(<input_prompts>)