git clone https://github.com/yoletPig/Annotation-with-SAM.gitcd segment-anything
pip install -e .pip install -r requirements.txtwget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth把你的数据放在同一个图片文件夹(dataset_path/images)中,后续会自动处理提取 embeddings 特征并保存为 npy 后缀的文件。
/dataset_path
/images
xxx.jpg/png
/embeddings
xxx.npypython helpers/extract_embeddings.py --checkpoint-path sam_vit_h_4b8939.pth --dataset-folder <dataset_path> --device cpu/cuda注意如果是非图片数据会报错,请确定images文件下没有非图片数据
python helpers/generate_onnx.py --checkpoint-path sam_vit_h_4b8939.pth --onnx-model-path ./sam_onnx.onnx --orig-im-size 720 1280我有提供转好的onnx的文件,如果你转换有问题可以尝试我的onnx文件,值得注意的是,opset-version需要15及以上 这里不支持动态图片输入,如果需要别的尺寸的需要重新转换onnx文件。
python ../SAM-Tool/segment_anything_annotator.py --onnx-model-path sam_onnx.onnx --dataset-path <dataset_path> --categories cat,dog类别这里使用英文逗号分割,不带空格
1、没有配置X11转发
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)
解决方法参考我之前的文章:(最新+详细+Pycharm远程调试GUI程序)解决qt.qpa.xcb: could not connect to display问题
2、动态链接库缺失 如果发现配置x11-forwarding后还是上面的报错,需要进行以下步骤来定位问题。
vim ~/.bashrc
# 在最后一行加上
export QT_DEBUG_PLUGINS=1
source ~/.bashrc上述步骤可以打印详细的报错信息。

cd /root/miniconda3/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/
# 查看关联内容
ldd libqxcb.so
sudo apt-get update
sudo apt-get install libxcb-icccm4 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1 libxkbcommon-x11-0Ubuntu18.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“问题 SAM-Tool segment-anything
