目录
一、anylabeling
二、Segment Anything模型ONNX导出
1、下载这个项目
2、环境配置
3、下载SAM预训练权重
4、导出ONNX格式
三、yaml文件编写
四、视频讲解
五、使用记录
六、其他
一、anylabeling
anylabeling项目地址
我直接用的之前yolov5的conda虚拟环境
pip install anylabeling -i https://pypi.tuna.tsinghua.edu.cn/simple
或许可能直接安装好依赖,但是把该项目的requirenments.txt
pip install -r requirements.txt -i https://pypi.douban.com/simple
以下代码启动运行:
anylabeling
可能会报错:
报错1
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
你把 /etc/gdm/custom.conf中,#
WaylandEnable=false改为WaylandEnable=false,然后重启
报错2
Qt platform plugin “xcb“缺失
sudo apt-get install libxcb-xinerama0
然后再次执行
anylabeling
就会出现一个图形界面了
这里第二步选择的模型可以有Segment Anything和yolo系列的网络模型。
二、Segment Anything模型ONNX导出
1、下载这个项目
2、环境配置
cd segment-anything; pip install -e .
pip install opencv-python pycocotools matplotlib onnxruntime onnx
3、下载SAM预训练权重
下载以下几个预训练权重文件,文件从小到大依次排列,越大的模型分割效果越好,但是分割时间也越长,建议先使用最小的模型试试效果,目前实测最小的模型分割效果也很不错。
1,sam_vit_b_01ec64.pth
2,sam_vit_l_0b3195.pth
3,sam_vit_h_4b8939.pth
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
4、导出ONNX格式
--checkpoint The path to the SAM model checkpoint 即SAM预训练权重
--output The filename to save the ONNX model to
--model-type In ['default', 'vit_h', 'vit_l', 'vit_b']. Which type of SAM model to export.
python scripts/export_onnx_model.py --checkpoint ./sam_vit_b_01ec64.pth --model-type vit_b --output sam_vit_b.onnx
三、yaml文件编写
这个软件加载模型必须要yaml文件:
Load Custom Model · Issue #39 · vietanhdev/anylabeling · GitHub
yaml文件如何编写:
Custom Models for Auto Labeling – AnyLabeling
yaml文件与onnx格式文件在同一目录下
运行软件会在家目录生成 anylabling文件夹
SegmentAnything:
type: segment_anything
name: segment_anything_vit_b_quant-r20230416
display_name: Segment Anything (ViT-B Quant)
decoder_model_path: segment_anything_vit_b_decoder_quant.onnx
encoder_model_path: segment_anything_vit_b_encoder_quant.onnx
input_size: 1024
max_height: 682
max_width: 1024
YOLOv5:
type: yolov5
name: yolov5l-r20230415
display_name: YOLOv5l Ultralytics
model_path: yolov5l.onnx
confidence_threshold: 0.45
input_height: 640
input_width: 640
nms_threshold: 0.45
score_threshold: 0.5
classes:
- person
- bicycle
- car
- motorcycle
- airplane
- bus
- train
- truck
- boat
- traffic light
- fire hydrant
- stop sign
- parking meter
- bench
- bird
- cat
- dog
- horse
- sheep
- cow
- elephant
- bear
- zebra
- giraffe
- backpack
- umbrella
- handbag
- tie
- suitcase
- frisbee
- skis
- snowboard
- sports ball
- kite
- baseball bat
- baseball glove
- skateboard
- surfboard
- tennis racket
- bottle
- wine glass
- cup
- fork
- knife
- spoon
- bowl
- banana
- apple
- sandwich
- orange
- broccoli
- carrot
- hot dog
- pizza
- donut
- cake
- chair
- couch
- potted plant
- bed
- dining table
- toilet
- tv
- laptop
- mouse
- remote
- keyboard
- cell phone
- microwave
- oven
- toaster
- sink
- refrigerator
- book
- clock
- vase
- scissors
- teddy bear
- hair drier
- toothbrush
YOLOv8:
type: yolov8
name: yolov8m-r20230415
display_name: YOLOv8m Ultralytics
model_path: yolov8m.onnx
confidence_threshold: 0.45
input_height: 640
input_width: 640
nms_threshold: 0.45
score_threshold: 0.5
classes:
- person
- bicycle
- car
- motorcycle
- airplane
- bus
- train
- truck
- boat
- traffic light
- fire hydrant
- stop sign
- parking meter
- bench
- bird
- cat
- dog
- horse
- sheep
- cow
- elephant
- bear
- zebra
- giraffe
- backpack
- umbrella
- handbag
- tie
- suitcase
- frisbee
- skis
- snowboard
- sports ball
- kite
- baseball bat
- baseball glove
- skateboard
- surfboard
- tennis racket
- bottle
- wine glass
- cup
- fork
- knife
- spoon
- bowl
- banana
- apple
- sandwich
- orange
- broccoli
- carrot
- hot dog
- pizza
- donut
- cake
- chair
- couch
- potted plant
- bed
- dining table
- toilet
- tv
- laptop
- mouse
- remote
- keyboard
- cell phone
- microwave
- oven
- toaster
- sink
- refrigerator
- book
- clock
- vase
- scissors
- teddy bear
- hair drier
- toothbrush
四、视频讲解
自动标注项目AnyLabeling上手体验和教程
五、使用记录
yolo模型还是蛮好用
标注文件:
但是vit模型在window,onnxruntime获取内存报错。linux端即使最小的模型,也只能点一个点跑不起来,最好有GPU,然后在环境中安装onnx-runtime-gpu
六、其他
SAM+LabelStudio实现自动标注试过了,点了猫图片半天没有反应。还接着尝试了好几个,如SAM-Tool项目,跑不起来。搞了我大半天时间,还是上面这个项目好用,stars走起
参考:
Qt运行出现 Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run....解决_楽 - 冰の菓的博客-CSDN博客