赞
踩
以后在csdn写笔记成为一种态度,我觉得很好,可以记录过程,下次也好找,也可给大家参考,可谓一举两得
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.07-2-Windows-x86_64.exe
注意安装地址
C:\Users\Administrator\anaconda3;C:\Users\Administrator\anaconda3\Scripts;
C:\Users\Administrator\anaconda3\Library\bin;
C:\Users\Administrator\anaconda3\Library\mingw-w64\bin
删除之前的镜像源,恢复默认状态
conda config --remove-key channels#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2#显示检索路径
conda config --set show_channel_urls yes#显示镜像通道
conda config --show channels
下载源码
git clone https://github.com/IDEA-Research/Grounded-Segment-Anything.git获取osx,Tag2Text:
cd C:\work\Grounded-Segment-Anything
git submodule update --init --recursive
这里路径有点问题,修改下Grounded-Segment-Anything目录下的.gitmodules
改为
[submodule "grounded-sam-osx"]
path = grounded-sam-osx
url = https://github.com/linjing7/grounded-sam-osx.git
[submodule "VISAM"]
path = VISAM
url = https://github.com/BingfengYan/VISAM.git
[submodule "Tag2Text"]
path = Tag2Text
url = https://github.com/xinyu1205/recognize-anything.git
再执行 git submodule update --init --recursive
conda create -n env_jkp python==3.11.4
运行以下两条语句才能用conda
conda init cmd.exe
conda init powershell
进入虚拟环境
conda activate env_jkp退出
conda deactivate
#pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
测试是否安装成功
conda list
tk 8.6.12 h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torch 2.0.0+cu117 pypi_0 pypi
torchaudio 2.0.1+cu117 pypi_0 pypi
torchvision 0.15.1+cu117 pypi_0 pypi
依赖包,基本解决大部分错误
conda install libpython m2w64-toolchain -c msys2
conda install m2-base
conda install -c conda-forge pycocotools(有效)pip install opencv-python matplotlib onnxruntime onnx ipykernel
安装scipy scipy
conda install scipypip install --upgrade Pillow
安装Segment Anything:
python -m pip install -e segment_anything
安装diffusers:
pip install --upgrade diffusers[torch]
cd grounded-sam-osx && bash install.shInstall RAM & Tag2Text:
cd C:\work\Grounded-Segment-Anything\Tag2Text && pip install -r requirements.txtrunning build_ext
running build_rust
error: can't find Rust compiler
window下安装rustup-initcd C:\work\Grounded-Segment-Anything
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
安装GroundingDINO(错误很多,放在最后搞下):
python -m pip install -e GroundingDINO
下载检测点,太大太大
groundingdino_swint_ogc.pth https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
sam_vit_h_4b8939.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
sam_hq_vit_h.pth https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_h.pth
ram_swin_large_14m.pth https://huggingface.co/spaces/xinyu1205/Tag2Text/resolve/main/ram_swin_large_14m.pth
tag2text_swin_14m.pth https://huggingface.co/spaces/xinyu1205/Tag2Text/resolve/main/tag2text_swin_14m.pth
运行grounding_dino_demo.py文件
修改文件
无gpu,将DEVICE 值改为 cpu
有gpu,无需修改参数python grounding_dino_demo.py
运行grounded_sam_demo.py文件
无gpu,参数使用默认的cpu
有gpu,将DEVICE 值改为 cuda图片改为自己的
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/water1.jpg --output_dir "outputs" --box_threshold 0.3 --text_threshold 0.25 --text_prompt "Water. Sewage"
运行grounded_sam_simple_demo.py文件 这个效果不错,图片改为自己的
python grounded_sam_simple_demo.py
6.4 运行automatic_label_ram_demo.py`文件
python automatic_label_ram_demo.py --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py --ram_checkpoint ram_swin_large_14m.pth --grounded_checkpoint groundingdino_swint_ogc.pth --sam_checkpoint sam_vit_h_4b8939.pth --input_image assets/water1.jpg --output_dir "outputs" --box_threshold 0.25 --text_threshold 0.2 --iou_threshold 0.5
运行automatic_label_demo.py文件
报错,需要
pip install --upgrade transformers
Resource punkt not found. Please use the NLTK Downloader to obtain the resource错误解决方案
方案就是直接下载放在该放的地方
下载wordnet,punkt,averaged_perceptron_tagger
- 'C:\\Users\\Administrator/nltk_data'
- 'C:\\Users\\Administrator\\anaconda3\\envs\\env_jkp\\nltk_data'
- 'C:\\Users\\Administrator\\anaconda3\\envs\\env_jkp\\share\\nltk_data'
- 'C:\\Users\\Administrator\\anaconda3\\envs\\env_jkp\\lib\\nltk_data'
- 'C:\\Users\\Administrator\\AppData\\Roaming\\nltk_data'
看看这个结构图,应该都懂的,目录位置报错的上面有,目录结构严格安装这个来,注意文件要解压,不解压不行,本来这玩意应该是网上下载的,那个国外网址不行,下不动,过程就是先下载,再解压,所以我们得帮他做了,他就认为,已经干过这事了,这次就不干了,直接用
感谢大家,基本完成,centos7.9正在调,毕竟这才是真实的系统,
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。