【语义分割 01】Open MMLab

1 Tutorial

https://github.com/TommyZihao/MMSegmentation_Tutorials
https://github.com/TommyZihao/Train_Custom_Dataset
https://github.com/TommyZihao/aidlux_tutorial

OpenMMLab是一个由中国开发者主导的具有世界影响力的人工智能计算机视觉开源算法体系, 至今已经开源了30+视觉算法库。
OpenMMLab is a world-influential open source artificial intelligence computer vision algorithm system led by Chinese developers, and has opened 30+ visual algorithms library so far.

语义分割不能解决三维问题.

2 Introduce

openmmlab介绍视频:Github八万star,开源计算机视觉神器OpenMMLab_哔哩哔哩_bilibili

 MMSegmentation分割:主要应用于医疗影像、遥感图像
 MMSegmentation: Mainly applied to medical images and remote sensing images

 MMPretrain:

  MMHuman3D:

  MMAction2:

MMagic:生成模型+底层视觉+AIGC算法库
MMagic: Generative model + low-level vision +AIGC algorithm library

3 Semantic segmentation annotation format

Integer mask

  • Watermelon data set

  • When to use semantic segmentation? When to split by instance?

如果不存在“实例”概念,只需要每个像素分类,用语义分割
If there is no "instance" concept, you just need to classify each pixel and use semantic segmentation.
如果需要目标检测预测框(计数、追踪、流量统计)用实例分割
If the target detection prediction box (counting, tracking, traffic statistics) is required, use the instance segmentation

Track-Anything:https://github.com/gaomingqi/Track-Anything
Segment-Anything:Segment Anything | Meta AI

  • Development trend of image segmentation.

        Use Transformer architecture
        Unified semantic segmentation, instance segmentation, panoramic segmentation
        Vision Large Model (SAM)
        Multimodal +AIGC(Text-generated picture, Picture-generated picture , Image editing)

  • Semantic segmentation evaluation

  • Summary

        There are many application scenarios for semantic segmentation, and some time ago I also wanted to use sam on ROS, but it has not been made.

4 labelme

Download link:https://github.com/wkentaro/labelme/releases

使用这种方式会闪退 

   

The resulting json file.

     

可以使用sam大模型去做图像分割
需要在虚拟环境里面使用:pip install labelme

5 Install and configure the MMSegmentation environment

 First,let's create a new virtual environment.

 

 Install Pytorch using the following command.

pip3 install install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

Follow the second tutorial to make your environment successful!

6 use API to predict

7 Train

40000 Iter
Logs are printed every 100 steps
aux.acc_seg:辅助语义分割损失函数
表格是在测试集上的评估性能(6类)
mIoU:平均IoU

8 visualize log

 

9 Test set evaluates metrics

10 Use the trained model to predict

 

 

 11 Deploy

Netron  -- onnx可视化模型结构

12 ONNX Runtime Deploy

 

13 AidLux图像分割部署-安卓鸿蒙高通ARM

 AidLux Image Segmentation Deployment - Andrew Hung Meng Qualcomm ARM
AidLux智能物联网(AIoT)应用开发和部署平台-阿加犀智能科技
AidLux Docs

 

14 other question

如何使用mmseg框架训练4波段 tif格式的遥感图像 以及 预训练模型载入的时候分配给rgb然后第四波段随机初始化?
多波段用pca主成分取前三个映射rgb

Docsicon-default.png?t=N7T8https://qxi0eyc5s7.feishu.cn/docx/Gx5OdFfa6oKOsBxFfmYcTKLhn1N

先教会大模型分割西瓜,然后把大模型当老师,再教一个轻量模型专门学习分割西瓜…先是迁移再蒸馏:用mmrazor

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
本文将以语义分割为例,介绍如何使用OpenMMLab框架进行实战操作。 一、准备工作 1.安装OpenMMLab框架 可以按照官网提供的安装方式进行安装,也可以使用pip install mmcv-full安装mmcv-full,然后再使用pip install openmmlab安装OpenMMLab。 2.下载数据集 本文使用的是PASCAL VOC2012数据集,可以在官网上下载。 3.配置环境变量 为了方便使用,可以将数据集路径添加到环境变量中,使用时直接调用。 二、数据预处理 1.将数据集转换为COCO格式 由于OpenMMLab使用的是COCO格式的数据集,因此需要将PASCAL VOC格式的数据集转换为COCO格式。可以使用官方提供的脚本进行转换。 python tools/datasets/voc_convert.py --voc-dir /path/to/voc --json-dir /path/to/save/json 其中,--voc-dir表示PASCAL VOC格式的数据集路径,--json-dir表示将要保存COCO格式的数据集路径。 2.数据增强 使用数据增强可以使模型更具有泛化能力,常用的增强方法包括随机旋转、随机裁剪、随机翻转等。可以使用OpenMMLab提供的数据增强模块进行处理。 from mmcv import Config from mmcv.runner import obj_from_dict cfg = Config.fromfile('configs/deeplabv3_r50-d8_512x512_40k_voc12aug.py') train_pipeline = obj_from_dict(cfg.data.train.pipeline) 其中,train_pipeline为数据增强的流程,可以根据需要进行修改。 三、模型训练 使用OpenMMLab提供的训练脚本进行训练。 python tools/train.py ${CONFIG_FILE} 其中,${CONFIG_FILE}为配置文件路径,可以在configs文件夹中选择合适的配置文件进行训练。 四、模型测试 使用OpenMMLab提供的测试脚本进行测试。 python tools/test.py ${CONFIG_FILE} ${CHECKPOINT_FILE} [--out ${RESULT_FILE}] [--eval ${EVAL_METRICS}] [--show] 其中,${CONFIG_FILE}为配置文件路径,${CHECKPOINT_FILE}为训练好的模型文件路径,${RESULT_FILE}为结果保存路径,${EVAL_METRICS}为评价指标,--show表示显示结果。 五、模型部署 使用OpenMMLab提供的导出模型脚本将模型导出为ONNX格式或TorchScript格式,以便在C++或Python中使用。 python tools/export_model.py ${CONFIG_FILE} ${CHECKPOINT_FILE} ${EXPORT_TYPE} [--out ${EXPORT_FILE}] [--input-img ${INPUT_IMG}] [--shape ${INPUT_SHAPE}] 其中,${EXPORT_TYPE}为导出模型格式,可以选择onnx或torchscript,${EXPORT_FILE}为导出模型路径,${INPUT_IMG}为输入图片路径,${INPUT_SHAPE}为输入图片大小。 六、总结 通过以上实战操作,我们可以使用OpenMMLab框架进行语义分割模型的训练、测试和部署。OpenMMLab框架提供了丰富的模型和数据增强模块,使得模型训练更加便捷。同时,OpenMMLab框架也支持模型导出为ONNX或TorchScript格式,方便在C++或Python中使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不菜不菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值