【利用MMdetection3D框架进行单目3D目标检测(smoke算法】

利用MMdetection3D框架进行3D目标检测(smoke算法)

1.mmdetection3d

mmdetection3d是OpenMMLab开发的3D目标检测开源工具箱,里面包含了许多经典的3D目标检测算法,包含了单目3D目标检测、多目3D目标检测、点云3D目标检测、多模态3D目标检测等各个方向。我们只需要把相应的算法权重下载下来,并调用相应接口即可进行检测。

2.mmdetection3d安装

2.1 依赖

mmdetection3d的安装需要有以下的依赖:

Python 3.6+
PyTorch 1.3+
CUDA 9.2+ (如果你从源码编译 PyTorch, CUDA 9.0 也是兼容的。)
GCC 5+
MMCV

1. 创建虚拟环境,并安装需要的依赖

conda create -n mm3d python=3.8 -y  
conda install pytorch torchvision(具体的pytorch和torchvision版本可根据自己的CUDA版本来指定安装)

2. 安装mmdetection3d
若已安装cuda11.0,则可以按照下面方法安装:(不是CUDA11.0的话参考文档进行安装)

pip install openmim 
mim install mmcv-full
mim install mmdet
mim install mmsegmentation
git clone https://github.com/open-mmlab/mmdetection3d.git
cd mmdetection3d
pip install -e .

若下载速度很慢的话,可以在命令行后面加上 -i https://pypi.tuna.tsinghua.edu.cn/simple
通过清华源下载速度有很大提升。

3.进行单目3D目标检测

语法如下:

python demo/mono_det_demo.py ${IMAGE_FILE} ${ANNOTATION_FILE} ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${GPU_ID}] [--out-dir ${OUT_DIR}] [--show]

其中

${IMAGE_FILE} :     图像路径
${ANNOTATION_FILE} :相机内参矩阵的json文件
${CONFIG_FILE}:     配置文件
${CHECKPOINT_FILE} :模型权重文件
${GPU_ID}:          使用哪个GPU
${OUT_DIR}:         结果保存地址
--show:             结果可视化

例子如下:

python demo/mono_det_demo.py   
data/kitti/testing/image_2/000010.png  
data/kitti/testing/calib_json/000010.json   
configs/smoke/smoke_dla34_pytorch_dlaneck_gn-all_8x4_6x_kitti-mono3d.py       
checkpoints/smoke_dla34_pytorch_dlaneck_gn-all_8x4_6x_kitti-mono3d_20210929_015553-d46d9bb0.pth    
 --show

结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_51182466/article/details/129314358