imvoxelnet 复现


直接从第1步开始即可!!!

0、题外话(安装mmdetection3d)【不用看这步】

参考https://www.yuque.com/huangzhongqing/hre6tf/cqhuv1y0hhuibi2u?singleDoc#
可以成功配置mmdetection3d的环境。我这里的显卡是RTX3080,CUDA版本是11.6。

# 虚拟环境(mmdet3d0.17)
conda create --name mmdet3d0.17 python=3.8 -y
conda activate mmdet3d0.17
# CUDA 11.3
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge

之后需要手动安装以下几个包:可以新建一个requirement.txt文件,复制以下

packaging
ipywidgets
pygments==2.4.1
defusedxml
entrypoints==0.2.2
nbformat
matplotlib==3.4    # 建议也限制一下版本
opencv-python==4.6.0.66   # 建议限制一下版本,否则会安装最新版
pycocotools==2.0.2           # 这里默认安装的话是2.0.1,但是后续验证numpy会报错,尝试了2.0.2版本就没问题了
tqdm
protobuf
distro
click
oauthlib==3.0.0
requests>=2.0.0

安装mmcv、mmdet、mmdetection3d

pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.1/index.html
pip install mmdet==2.14.0
pip install mmsegmentation==0.14.1
pip install spconv-cu113 
git clone https://github.com/open-mmlab/mmdetection3d.git
cd mmdetection3d
# 切换到0.17分支
git checkout v0.17.0
pip install -v -e .

验证安装

# 查看mmlab各个库的版本
python mmdet3d/utils/collect_env.py

# 跑一个点云的demo,可视化需要安装open3d
pip install open3d
python demo/pcd_demo.py \
	demo/data/kitti/kitti_000008.bin \ 
	configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py \ 
	checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth \
	--show

demo权重下载地址:https://download.openmmlab.com/mmdetection3d/v0.1.0_models/second/hv_second_secfpn_6x8_80e_kitti-3d-car/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth
新建一个checkpoints文件夹,并把权重放在这里。
在这里插入图片描述
在这里插入图片描述
跑demo时,一般来说出现红框圈住的语句时,说明环境配置成功,并且会生成点云的可视化显示。
在这里插入图片描述

1、重新配置imvoxelnet环境

基本与配置mmdetection3d环境类似,只不过git clone的时候选择对应的库即可,但是我按照上一步的环境配置后仍然存在一些问题。好在在官方issue中找到了对应的环境配置。https://github.com/SamsungLabs/imvoxelnet/issues/16

# RTX30系显卡需要安装cuda11以上的版本,因此这里与参考链接不同
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

# Install MMCV
pip install mmcv-full==1.2.7 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
pip install mmdet==2.10.0

# Install MMDetection
git clone https://github.com/saic-vul/imvoxelnet.git
cd imvoxelnet
pip install -r requirements/build.txt
pip install --no-cache-dir -e .

# Uninstall pycocotools installed by nuscenes-devkit and reinstall mmpycocotools
pip uninstall pycocotools --no-cache-dir -y
pip install mmpycocotools==12.0.3 --no-cache-dir --force --no-deps

# Install differentiable IoU
cd ..
git clone https://github.com/lilanxiao/Rotated_IoU
cp -r Rotated_IoU/cuda_op imvoxelnet/mmdet3d/ops/rotated_iou
cd imvoxelnet/mmdet3d/ops/rotated_iou/cuda_op
python setup.py install

按照这个链接基本没有问题,如果遇到缺少其他包的,就缺什么装什么,或者可以按照我之前写的那个requirement.txt pip install一下。特别注意自动装的库matplotlibopencv-python默认都是安装最新版,和有些库不兼容,建议手动降级。如果遇到numpy版本问题,建议降到1.19.5。

最后验证安装
在这里插入图片描述

1.2 可能遇到的问题及解决办法

1.2.1 缺少库

在这里插入图片描述
在这里插入图片描述
按照上面的requirement.txt,装一下

pip install -r requirement.txt

1.2.2 库的版本冲突

常见冲突

  • opencv-python 建议4.6.0.66
  • matplotlib 建议3.7以下,我用3.4没问题
  • numpy 强烈推荐1.19.5

可忽略冲突
画绿框的这几个,如果有需要再更改环境
在这里插入图片描述

1.2.3 pycocotool相关错误

在这里插入图片描述
反复尝试了下面两行代码,然后莫名其妙就没问题了,非常玄学。

pip uninstall pycocotools --no-cache-dir -y
pip install mmpycocotools==12.0.3 --no-cache-dir --force --no-deps

但是有新的问题出现了,这里暂时还没解决,不过不影响后续复现imvoxelnet,这里可能是因为mmlab各个库前后代码有变化,至少我在配置mmdetection3d-0.17时没有问题。。。
在这里插入图片描述

2、Getting Started

目前只跑通了https://github.com/SamsungLabs/imvoxelnet#datasetsVisualization部分,下面开始细说。

2.1 准备数据集

参照https://github.com/SamsungLabs/imvoxelnet/blob/master/docs/getting_started.md准备Kitti数据集
最后的格式如下图所示,不需要点云。
在这里插入图片描述
修改配置文件imvoxelnet/configs/imvoxelnet/imvoxelnet_kitti.py,根据自己的情况修改置信度和数据集的位置。
在这里插入图片描述

2.2 复现

2.2.1 跑可视化的demo

首先需要修改一点代码imvoxelnet/mmdet3d/datasets/kitti_monocular_dataset.py
在这里插入图片描述
可能是代码和mmlab版本不匹配的原因,在这个配置的环境下,这几个键是有问题的,具体修改如下,直接在代码里用Ctrl+H替换一下即可。

info['image']['image_idx']    =>    info['image_idx']  
info['calib']['XXXX']    =>    info['calib/XXXX'] 
info['image']['image_path']    =>    info['img_path']
info['image']['image_shape']    =>    info['img_shape']

也可以在替换前直接跑一下demo,在这里输出一下,看看info具体的格式。
在这里插入图片描述
在这里插入图片描述

最后执行下面的命令行即可。主要需要修改权重路径图片输出路径,权重可以在Github上下载,https://github.com/SamsungLabs/imvoxelnet?tab=readme-ov-file#models

python tools/test.py \
	configs/imvoxelnet/imvoxelnet_kitti.py \
    PATH/TO/WEIGHTS/.pth \
    --show \
    --show-dir PATH/TO/OUTPUTS

运行成功的结果如下图所示,
在这里插入图片描述
打开输出路径,观察3d检测结果,看起来比smoke要好一些。
在这里插入图片描述

2.2.2 testing

需要修改imvoxelnet/mmdet3d/datasets/kitti_dataset.py
与2.2.1一样,将info对应的键修改。

info['image']['image_idx']    =>    info['image_idx']  
info['calib']['XXXX']    =>    info['calib/XXXX'] 

开始测试:

python tools/test.py \
	configs/imvoxelnet/imvoxelnet_kitti.py \
	checkpoints/20210503_214214.pth \
	--eval mAP

这里没有用github中的.sh文件,那个文件是用多卡进行推理的。

2.2.3 training

未完待续

  • 20
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值