CenterPoint简介、环境配置与安装
简介
三维对象通常表示为点云中的 3D Bbox,但3D 世界中的对象不遵循任何特定方向,并且anchor-based的检测器难以枚举所有方向或将轴对齐的边界框拟合到旋转的对象。
CenterPoint是一个center-based的二阶段方法,第一阶段预测物体中心点,并得到粗略3D bbox(包括大小、方向和速度),第二阶段回归得出score与精确的3D bbox,由于点没有方向,预测时极大地缩小了搜索空间,速度超过了以往的二阶段检测方法。在 CenterPoint 中,3D 对象跟踪简化为贪婪的最近点匹配。由此产生的检测和跟踪算法简单、高效且有效。
Centerpoint网络结构如下图所示:
环境配置与安装
博主在配置CenterPoint的环境时,按照原链接安装时采了很多坑,总会各种报错。
https://github.com/tianweiy/CenterPoint/blob/master/docs/INSTALL.md
下面是成功运行的安装教程:
Requirements
- Linux
- Python 3.6+
- PyTorch 1.1 or higher
- CUDA 10.0 or higher
- CMake 3.13.2 or higher
- spconv
- APEX
注意:
- spconv应该是与cuda相匹配的特定版本
- 经验法则是,你的pytorch cuda版本必须与你的系统的cuda版本匹配,其他cuda扩展才能正常工作。
我的硬件配置为:
- Linux(Ubuntu 18.04)
- NVIDIA GeForce RTX 2080TI
- NVIDIA显卡驱动版本:11.4
- CUDA version:10.2
Basic Installation
# 创建名为centerpoint的conda环境
conda create --name centerpoint python=3.7
conda activate centerpoint
# 安装pytorch
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0 -c pytorch
# 下载CenterPoint的Github库
git clone https://github.com/tianweiy/CenterPoint.git
cd CenterPoint
# 安装相关软件
pip install -r requirements.txt
# add CenterPoint to PYTHONPATH by adding the following line to ~/.bashrc (change the path accordingly)
export PYTHONPATH="${PYTHONPATH}:PATH_TO_CENTERPOINT"
Advanced Installation
nuScenes dev-kit
安装nuscenes数据集所需要的软件包:
git clone https://github.com/tianweiy/nuscenes-devkit
# add the following line to ~/.bashrc and reactivate bash (remember to change the PATH_TO_NUSCENES_DEVKIT value)
export PYTHONPATH="${PYTHONPATH}:PATH_TO_NUSCENES_DEVKIT/python-sdk"
Cuda Extensions
环境变量也可以添加到./bashrc
中:
# set the cuda path(change the path to your own cuda location)
export PATH=/usr/local/cuda-10.2/bin:$PATH
export CUDA_PATH=/usr/local/cuda-10.2
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
bash setup.sh
spconv
spconv的版本问题是报错最多的,但这里有一些奇怪。
sudo apt-get install libboost-all-dev
pip install spconv-cu113 # 自己硬件cuda版本是cuda10.2,但安装cu113却可以成功运行
APEX
APEX是PyTorch扩展包,它是一个为混合精度训练和分布式训练设计的工具包。
git clone https://github.com/NVIDIA/apex
cd apex
# 注意在此我使用的是master分支,如果后续有更新,新版本无法支持,可能需要切换到老版本
python3 setup.py install