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中,遠程服務器上文件找不到的問題