lang-segment-anything环境配置

  • 最新需要为数据集提取mask,用了SAM发现可以分割,但是我的需求是挖出前景物体即可,SAM分割的时候不仅会挖出前景物体,还会有很多其他instance的mask,同事没有label信息,所以需要手动选择每一个图片对应的mask。发现repo里有人推荐lang-segment-anything(简称langSAM),大致思路是用GroundingDINO用text给boundind box,然后用bounding box给SAM做prompt(SAM本身release的code不支持prompt)。所以需要配置lang-segment-anything。
  • 我的环境:Ubuntu,无法连接git。
  • 步骤如下:
    首先按照langSAM官方repo的tutorial,因为我没办法在服务器上git,所以windows本地git好之后上传到服务器。
git clone https://github.com/luca-medeiros/lang-segment-anything 
cd lang-segment-anything
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip install -e .

运行到pip install -e .报错如下:

Obtaining file:///home/cjji/robotics/lang-segment-anything
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting groundingdino@ git+https://github.com/IDEA-Research/GroundingDINO.git (from lang-sam==0.1.0)
  Cloning https://github.com/IDEA-Research/GroundingDINO.git to /tmp/pip-install-cy0xnetm/groundingdino_7a99903979344473a897fbc678f8cb25
  Running command git clone --filter=blob:none --quiet https://github.com/IDEA-Research/GroundingDINO.git /tmp/pip-install-cy0xnetm/groundingdino_7a99903979344473a897fbc678f8cb25
  fatal: unable to access 'https://github.com/IDEA-Research/GroundingDINO.git/': Failed to connect to github.com port 443: Connection timed out
  error: subprocess-exited-with-error

  × git clone --filter=blob:none --quiet https://github.com/IDEA-Research/GroundingDINO.git /tmp/pip-install-cy0xnetm/groundingdino_7a99903979344473a897fbc678f8cb25 did not run successfully.
  │ exit code: 128
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/IDEA-Research/GroundingDINO.git /tmp/pip-install-cy0xnetm/groundingdino_7a99903979344473a897fbc678f8cb25 did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

因为pip install -e .通常与 setup.py 文件或 pyproject.toml 文件一起使用,根据这两个文件来安装,看了langSAM官方repo的pyproject.toml文件,发现是安装segment-anything和groundingdino可能因为git安装的问题连接不了,所以自己根据pyproject.toml安装,安装以下库(pip install),可以不管版本号,直接安装库:

gradio = "^3.24.1"
huggingface-hub = "^0.16.4"
numpy = "^1.24.2"
opencv_python = "^4.7.0.72"
Pillow = "9.3.0"
transformers = "^4.27.4"
lightning = "^2.0.1"

然后去SAM官方repoGroundingDINO官方repo手动安装,SAM可以直接按照官方repo教程安装,没有碰到问题;安装GroundingDINO时候pip install -e .报错如下:

RuntimeError:
    The detected CUDA version (11.8) mismatches the version that was used to compile
    PyTorch (12.1). Please make sure to use the same CUDA versions.

    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

重新安装一遍pytorch,然后再运行pip install -e .就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值