目录
https://github.com/IDEA-Research/Grounded-Segment-Anything
Grounded-Segment-Anything本地部署
1. 克隆源码
cd AI
mkdir sd_grounded_sam
git clone https://github.com/IDEA-Research/Grounded-Segment-Anything.git # 克隆源码
2. 创建虚拟环境(安装python pytorch)
conda create -n grounded_sam python==3.8.10
conda activate grounded_sam
# 下载前面很快,后面慢
pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
3. 安装requirements.txt库
cd AI/sd_grounded_sam/Grounded-Segment-Anything
pip install -r requirements.txt
4. pth下载
wget下载慢,建议输入链接直接下载再上传到服务器
cd Grounded-Segment-Anything
# download the pretrained groundingdino-swin-tiny model
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
# 暂未下载
cd Tag2Text
wget https://huggingface.co/spaces/xinyu1205/Tag2Text/resolve/main/ram_swin_large_14m.pth
wget https://huggingface.co/spaces/xinyu1205/Tag2Text/resolve/main/tag2text_swin_14m.pth
在此下载 SAM-HQ 检查点
建议单独放到一个 weight 文件夹
5. 运行demo
5.1 grounding_dino_demo.py
所有的 from groundingdino……
改为 from GroundingDINO.groundingdino……
包括:
当前项目.py
GroundingDINO.groundingdino.util.inference.py
GroundingDINO.groundingdino.models.GroundingDINO.ms_deform_attn.py
报错:
1. NameError: name ‘_C’ is not defined
https://github.com/IDEA-Research/Grounded-Segment-Anything/issues
(1)考虑安装 python -m pip install -e GroundingDINO
(2)如果(1)不行。尝试下面:
export AM_I_DOCKER=False
export BUILD_WITH_CUDA=True
export CUDA_HOME=/usr/local/cuda-11.2/ # 这个路径不知道如何确定?
cd GroundingDINO
python setup.py build
python setup.py install
需要gcc > 5
gcc升级及版本切换 : https://blog.csdn.net/qq_41475067/article/details/117404235
如果报错: Command '['which', 'g++']' returned non-zero exit status 1.
可能是gcc的问题:
yum -y update gcc
yum -y install gcc gcc-c++
报错 No package gcc+ available
:https://www.cnblogs.com/lemon-le/p/10538130.html
还是报错的话,卸载重装:https://blog.csdn.net/mocha11/article/details/104133309
ncvv 报错:https://blog.csdn.net/LLL_mg/article/details/107823465