
Semantic-SAM Repository Application
My repository: https://github.com/Chen-Yulin/Semantic-SAM
Installation
官方步骤:
1 | pip3 install torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu113 |
一些绊脚石 ^ ^
1
根据[[Cuda+Torch]],需要先安装cudatoolkit
和cuda-toolkit
1 | conda install nvidia/label/cuda-11.7.0::cuda-toolkit -c nvidia/label/cuda-11.7.0 |
然后按照torch官网的安装指令:
1 | conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia |
2
第二行直接运行可能会报错,提示系统gcc版本过高,安装gcc=11.2.0
1 | conda install -c conda-forge gcc=11.2.0 |
如果编译时出现ld: cannot find -lcudart: No such file or directory collect2: error: ld returned 1 exit status
报错,只是因为没有安装cudatoolkit
^ ^
3
安装完成后直接import semantic_sam
会报错ModuleNotFoundError: No module named 'MultiScaleDeformableAttention'
^ ^
提示:
1 | Please compile MultiScaleDeformableAttention CUDA op with the following commands: |
需要手动make一下 Mask2Former
:
1 | cd Mask2Former/mask2former/modeling/pixel_decoder/ops/ |
4
一些版本问题
1 | pip install gradio==3.37.0 |
Demo 🐱
Generate multi-granularity Mask on CLICK
1 | python demo.py --ckpt ./weights/swinl_only_sam_many2many.pth |
Comment: 效果相较于SAM更多体现了语义的一致性,而不是基于texture进行分割。
Automatically Generate Mask on Different Granularity
1 | python demo_auto_generation.py --ckpt ./weights/swinl_only_sam_many2many.pth |