加强心理咨询网站的建设,wordpress图片博客插件,能先做网站再绑定域名吗,南昌企业制作网站设计mmdetection 学习目录1 mmdetection 学习建议1.1 mmdetection 学习的第一件事1.2 mmdetection学习路线图1.2.1 优先看的两个库1.2.2 阅读代码1.2.3 代码学习步骤1.2.4 建议优先学习的两个目标检测模型代码1.2.5 loss计算流程的攻坚克难1.3 遇到问题如何求助2 Anaconda3下的安装…
mmdetection 学习目录1 mmdetection 学习建议1.1 mmdetection 学习的第一件事1.2 mmdetection学习路线图1.2.1 优先看的两个库1.2.2 阅读代码1.2.3 代码学习步骤1.2.4 建议优先学习的两个目标检测模型代码1.2.5 loss计算流程的攻坚克难1.3 遇到问题如何求助2 Anaconda3下的安装教程mmdetmmdet3d1.1 Anaconda虚拟环境搭建1.2 Pytorch安装1.3 MMCV安装1.4 MMDetection安装1.5 MMDetection3D安装1 mmdetection 学习建议 1.1 mmdetection 学习的第一件事
对于任何一个开源框架找到 GitHub 地址后第一件事情应该是阅读 docs。
MMDetection 2.26.0 文档中文版https://mmdetection.readthedocs.io/zh_CN/latest/index.html
Tip目前 MMDetection 实现的算法中主要包括 one-stage 和 two-stage 算法而 two-stage 算法可以简单认为是 one-stage pool one-stage 步骤。
1.2 mmdetection学习路线图
1.2.1 优先看的两个库
简单来说学习 MMDetection 主要是学习两个库MMCV 和 MMDectection MMCV 是面向整个OpenMMLab所有的开源库均为通用类和工具类方便下游各个 codebase 复用 1.2.2 阅读代码
在打好基础后下一步就是深入阅读源码。
由于模型训练过程涉及的内容比较复杂建议按照如下顺序进行学习
1.2.3 代码学习步骤
先选择经典算法对前向过程进行深入分析阅读部分主要包括 DataLoader 构建过程、数据前处理流程、Backbone、Neck、Head 和后处理模块。重点是理解网络输出形式以及后处理的具体步骤暂时忽略 loss 计算部分。
1.2.4 建议优先学习的两个目标检测模型代码
本阶段目标充分理解 RetinaNet 和 Faster R-CNN 的前向推理流程 ① 优先阅读one-stage模型RetinaNet多看几遍 RetinaNet 算法后对 MMDetection 算法的实现方式就会有一个非常清晰的认识。 链接地址https://zhuanlan.zhihu.com/p/346198300 ② 深入阅读 Faster R-CNN 算法 以上两个经典算法可以说是后续所有算法的 baseline后续大部分算法都或多或少的继承了这个算法同时实现方式也是非常类似。 1.2.5 loss计算流程的攻坚克难
充分理解前向推理流程后下一步深入阅读训练过程中 loss 计算流程了重点关注正负样本定义规则、bbox 编解码规则和 loss 计算函数。
阅读顺序深入理解 RetinaNet 后再看 Faster R-CNN。
1.3 遇到问题如何求助
①在阅读过程中可以再次去查看知乎相关源码解读文章对照看多看几遍应该会加快理解。
②存在问题去github的issue查找
③如果在阅读过程中有疑问可以在社区中提问
2 Anaconda3下的安装教程mmdetmmdet3d
MMDetection是MMLab家族的一员是由香港中文大学和商汤科技共同推出的以一个统一的架构支撑了15个大方向的研究领域。MMDetection依赖Pytorch和MMCV因此安装之前需要先安装这两个库。 1.1 Anaconda虚拟环境搭建
conda create -n mmlab python3.6
# 然后切换到该环境下
activate mmlab1.2 Pytorch安装
# 注意根据自己电脑的CUDA版本选择。在命令行运行nvcc -V查看当前cuda版本
nvcc -V
# 当前2021.10.23MMCV最新仅支持到pytorch-1.9安装最新的pytorch1.10会导致MMDetection无法使用因此安装的时候需要指定pytorch版本为1.9。
conda install pytorch1.9.1 torchvision torchaudio cudatoolkit10.2 -c pytorch
# 验证pytorch安装成功
python1.3 MMCV安装
MMCV有两mmcv-full和mmcv两个版本两者差别在于是否包含CUDA操作如果不需要使用CUDA可以安装mmcv不过官方还是推荐安装完整版的mmcv-full。
pip install mmcv-full# 如果处于服务器这类无法联网的环境可以参照官方说明使用源码安装
# https://mmcv.readthedocs.io/en/latest/get_started/build.html1.4 MMDetection安装
# ①首先从github上下载mmdetection的源码然后根据requirements.txt安装所需的依赖库最后执行setup.py安装mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements.txt
python setup.py develop# 使用官方Demo验证安装是否成功位于./demo文件夹下。
# 先新建一个demo_test工程下载预训练模型下载链接放至test_demo\checkpoints文件下新建main.py并运行main.py
import osfrom mmdet.apis import init_detector, inference_detectordef demo_mmdet():base_dir rD:\Program Files\Third_Part_Lib\mmdetection # mmdetection的安装目录config_file os.path.join(base_dir, rconfigs\faster_rcnn\faster_rcnn_r50_fpn_1x_coco.py)# download the checkpoint from model zoo and put it in checkpoints/# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pthcheckpoint_file rcheckpoints\faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth# 根据配置文件和 checkpoint 文件构建模型model init_detector(config_file, checkpoint_file, devicecuda:0)# 测试单张图片并展示结果img os.path.join(base_dir, rdemo\demo.jpg) # 或者 img mmcv.imread(img)这样图片仅会被读一次result inference_detector(model, img)# 在一个新的窗口中将结果可视化model.show_result(img, result, out_fileNone, showTrue)if __name__ __main__:demo_mmdet()运行成功效果如下 1.5 MMDetection3D安装
MMDetection3D依赖MMSegmentation先安装MMSegmentation
git clone https://github.com/open-mmlab/mmsegmentation.git
cd mmsegmentation
pip install -r requirements.txt
python setup.py develop然后再安装MMDetection3D这一步编译时间可能会久一点
git clone https://github.com/open-mmlab/mmdetection3d.git
cd mmdetection3d
pip install -r requirements.txt
python setup.py develop最后再利用官方提供的Demo先下载预训练模型下载链接放至test_demo\checkpoints文件下然后运行下面代码
import os
from mmdet3d.apis import inference_detector, init_model, show_result_meshlabdef demo_mmdet3d():base_dir rD:\Program Files\Third_Part_Lib\mmdetection3d # mmdetection3d的安装目录config_file os.path.join(base_dir, rconfigs\second/hv_second_secfpn_6x8_80e_kitti-3d-car.py)# download the checkpoint from model zoo and put it in checkpoints/# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pthcheckpoint_file rcheckpoints\hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth# build the model from a config file and a checkpoint filemodel init_model(config_file, checkpoint_file, devicecuda:0)# test a single binpcd os.path.join(base_dir, rdemo/data/kitti/kitti_000008.bin)result, data inference_detector(model, pcd)# show the resultsshow_result_meshlab(data,result,,0,showTrue,snapshotFalse,taskdet)if __name__ __main__:demo_mmdet3d()运行成功效果如下