推荐使用Anaconda创建虚拟环境,这样方便管理环境(比如重装):
conda create -n open-mmlab python=3.7 -y conda activate open-mmlab
先安装1.15.0-1.20.0版本的numpy,不然后面会和numba的版本不兼容:
pip install numpy==1.18.0
推荐安装1.5.0的pytorch和10.1的cuda,版本不要太高:
conda install pytorch==1.5.0 cudatoolkit=10.1 torchvision==0.6.0 -c pytorch
不高于1.4.0版本的mmcv-full:
pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html
2.14.0版本的mmdet:
pip install mmdet==2.14.0
0.14.1版本的mmsegmentation:
pip install mmsegmentation==0.14.1
下载MMDetection3D:
git clone https://github.com/open-mmlab/mmdetection3d.git cd mmdetection3d
编译:
pip install -v -e .
安装Open3D,方便可视化:
pip install open3d-python
数据集的制作形式推荐模仿常用数据集如:KITTI,Waymo:
KITTI文件形式如下,放入对于的自己的数据就好了:
mmdetection3d ├── mmdet3d ├── tools ├── configs ├── data │ ├── kitti │ │ ├── ImageSets │ │ ├── testing │ │ │ ├── calib │ │ │ ├── image_2 │ │ │ ├── velodyne │ │ ├── training │ │ │ ├── calib │ │ │ ├── image_2 │ │ │ ├── label_2 │ │ │ ├── velodyne
KITTI官网:http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d
训练
python tools/train.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py
注:训练的时候可能会出现“RuntimeError: CUDA out of memory”的错误,也就是显存泄漏了,所以需要根据自己的显卡的显存修改samples_per_gpu:
configs/_base_/datasets/kitti-3d-3class.py文件中99行改小sample_per_gpu测试
python tools/test.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py checkpoints/epoch_80.pth --eval mAP --options 'show=True' 'out_dir=./data/pointpillars/show_results'
'show=True’的选项需要保证Open3d的安装,提供一个Open3d直接可视化bin文件的脚本,修改路径就好了:
import os import numpy as np import struct import open3d def read_bin_velodyne(path): pc_list=[] with open(path,'rb') as f: content=f.read() pc_iter=struct.iter_unpack('ffff',content) for idx,point in enumerate(pc_iter): pc_list.append([point[0],point[1],point[2]]) return np.asarray(pc_list,dtype=np.float32) def main(): root_dir='/home/zhuzhengming/mmdetection3d/data/kitti/kitti_gt_database' filename=os.listdir(root_dir) file_number=len(filename) pcd=open3d.open3d.geometry.PointCloud() for i in range(file_number): path=os.path.join(root_dir, filename[i]) print(path) example=read_bin_velodyne(path) # From numpy to Open3D pcd.points= open3d.open3d.utility.Vector3dVector(example) open3d.open3d.visualization.draw_geometries([pcd]) if __name__=="__main__": main()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)