Grounded-Segment-Anything 环境配置
- Grounded-Segment-Anything 介绍
- 环境配置
- Install osx(非必须):
- Install RAM & Tag2Text:
- 报错 module ‘pkgutil‘ has no attribute ‘ImpImporter‘. Did you mean: ‘zipimporter‘?
- 运行
- 输出分割+文本提示检测
- 远程服务器
Grounded-Segment-Anything 介绍
github项目地址
接地分段任何事物
该项目的核心思想是整合不同模型的优势,构建一个极其强大的流程来解决复杂问题。值得一提的是,这是一个组合强大专家模型的工作流程,其中所有部分都可以单独使用或组合使用,并且可以替换为任何相似但不同的模型(例如,用 GLIP 或其他检测器替换 Grounding DINO / 用 ControlNet 或 GLIGEN 替换 Stable-Diffusion / 与 ChatGPT 结合使用)。
环境配置
创建环境等跳过
安装torch等
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
验证
import torch
torch.cuda.is_available()
输出true即证明可以使用gpu
Install without Docker
pip install --upgrade "diffusers[torch]"
Install osx(非必须):
git submodule update --init --recursive
cd grounded-sam-osx && bash install.sh
这里如果运行不成功的话可以命令行挨个指令再走一遍
pip install mmcv-full==1.7.1
相关文章:1 下载地址
暂时跳过,我总觉得这个好像不是必选的
Install RAM & Tag2Text:
git clone https://github.com/xinyu1205/recognize-anything.git
pip install -r ./recognize-anything/requirements.txt
pip install -e ./recognize-anything/
报错 module ‘pkgutil‘ has no attribute ‘ImpImporter‘. Did you mean: ‘zipimporter‘?
python -m ensurepip --upgrade
python -m pip install --upgrade setuptools
运行
步骤 1:下载预训练权重
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
运行演示
python grounding_dino_demo.py
这一步没有分割结果输出
输出分割+文本提示检测
cd Grounded-Segment-Anythingwget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
python grounded_sam_demo.py \--config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \--grounded_checkpoint groundingdino_swint_ogc.pth \--sam_checkpoint sam_vit_h_4b8939.pth \--input_image assets/demo1.jpg \--output_dir "outputs" \--box_threshold 0.3 \--text_threshold 0.25 \--text_prompt "bear" \--device "cuda"
基本功能也就是这些了,如果需要更多的需求的话,可以去原始项目探索一下。
远程服务器
Pycharm远程连接服务器并运行代码(详细!)
Pycharm 实现本地与服务器代码同步
conda克隆环境
假设已有环境名为A,需要生成的环境名为B:
conda create -n B --clone A
pycharm 远程运行时,出现报错 can’t open file '/tmp/ ': [Errno 2] No such file or directory
解决pycharm中,远程服务器上文件找不到的问题