1、安装
- 创建一个python3.7的虚拟环境
conda create --name polarstream python=3.7
- 激活虚拟环境
source activate polarstream
以下操作均在虚拟环境中进行
- 安装与cuda和python版本对应的torch版本,参考https://blog.csdn.net/didadifish/article/details/127487635
pip install torch-1.8.1+cu111-cp37-cp37m-linux_x86_64.whl
- 安装与torch版本对应的torchvision版本,参考https://wenku.csdn.net/answer/638aee6ce78a11edbcb5fa163eeb3507
pip install torchvision==0.9.1
- 拉取polarstream并进入
git clone https://github.com/qchenclaire/polarstream
cd polarstream
- 安装依赖环境
pip install -r requirements.txt
requirements.txt的内容如下:
numba
xlwt
fire
protobuf
opencv-python
opencv-contrib-python
pybind11 easydict
open3d-python
terminaltables
pytest-runner
addict
pycocotools
imagecorruptions
objgraph
cachetools
descartes
jupyter
matplotlib
motmetrics==1.1.3
numpy
pandas==0.24
Pillow==7.1.0
pyquaternion==0.9.5
scikit-learn
Shapely
tqdm
pyyaml
requests
detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.8/index.html
/home/user/tools/torch_cluster-1.5.9-cp37-cp37m-linux_x86_64.whl
/home/user/tools/torch_scatter-2.0.6-cp37-cp37m-linux_x86_64.whl
/home/user/tools/torch_sparse-0.6.10-cp37-cp37m-linux_x86_64.whl
/home/user/tools/torch_spline_conv-1.2.1-cp37-cp37m-linux_x86_64.whl
torchgeometry
- 添加polarstream的路径到PYTHONPATH,PYTHONPATH是Python搜索路径,默认我们import的模块都会从PYTHONPATH里面寻找。参考https://blog.csdn.net/m0_48134027/article/details/122153674
export PYTHONPATH="${PYTHONPATH}:/home/user/catkin_ws/polarstream"
- 安装nuscenes-devkit
git clone https://github.com/tianweiy/nuscenes-devkit
#添加到python搜索路经
export PYTHONPATH="${PYTHONPATH}:/home/user/catkin_ws/nuscenes-devkit/python-sdk"
- 安装Cuda扩展
bash setup.sh
- 安装APEX
Note: apex build is also gpu-specific.
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
- 安装spconv2.x
pip install spconv-cu114
2、基于nuScenes数据集训练
2.1 数据准备
- 数据组织
基于关键帧训练,数据集按以下结构组织,其中maps未使用,sweeps可以为空.
- 创建数据
将/home/user/catkin_ws/polarstream/det3d/datasets/nuscenes/nusc_common.py中399行的print(cnt / (nsweeps - 1))注释
将/home/mdj/catkin_ws/polarstream/tools/generate_instance_ids.py中62行改为info_path = ‘/home/user/data/nuSenses/v1.0-trainval01_blobs/infos_val_01sweeps_withvelo_filter_True.pkl’
执行以下两条命令:
python tools/create_data.py nuscenes_data_prep --root_path=/home/user/data/nuSenses/v1.0-trainval01_blobs --version="v1.0-trainval" --nsweeps=1
生成文件infos_train_01sweeps_withvelo_filter_True.pkl与infos_val_01sweeps_withvelo_filter_True.pkl
python tools/generate_instance_ids.py
生成instance_all
2.2 单GPU训练
将/home/user/catkin_ws/polarstream/configs/nusc/pp/polarstream_det_n_seg_1_sector.py中第5行设为nsweeps = 1,第120行设为data_root = “/home/user/data/nuSenses/v1.0-trainval01_blobs”
执行
python tools/train.py /home/user/catkin_ws/polarstream/configs/nusc/pp/polarstream_det_n_seg_1_sector.py --work_dir /home/user/catkin_ws/polarstream
开始训练
如图所示为训练过程