Grounded-SAM

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  

PyTorch下载

在这里插入图片描述

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

Grounded-Segment-Anything本地部署

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+ availablehttps://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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值