1. 代码下载
git clone https://github.com/fundamentalvision/BEVFormer.git
2. 环境配置
使用conda创建环境
conda create -n open-mmlab python=3.8 -y
进入环境
conda activate open-mmlab
允许使用pip安装依赖库
export PIP_REQUIRE_VIRTUALENV=false
安装pytorch和torchvision
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
# Recommended torch>=1.9
Install gcc>=5 in conda env (optional).
conda install -c omgarcia gcc-6 # gcc-6.2
安装mmcv-full
pip install addict
pip install mmcv-full==1.4.0
# pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
安装mmdet和mmseg
pip install mmdet==2.14.0
pip install mmsegmentation==0.14.1
Install mmdet3d from source code.
git clone https://github.com/open-mmlab/mmdetection3d.git
cd mmdetection3d
git checkout v0.17.1 # Other versions may not be compatible.
python setup.py install
Install Detectron2 and Timm.
pip install einops fvcore seaborn iopath==0.1.9 timm==0.6.13 typing-extensions==4.5.0 pylint ipython==8.12 numpy==1.19.5 matplotlib==3.5.2 numba==0.48.0 pandas==1.4.4 scikit-image==0.19.3 setuptools==59.5.0
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
3. 准备数据
3.1. 下载数据
下载地址 https://www.nuscenes.org/download
从这里点击下载
3.1.1. 下载Mini数据
需要下载Mini, Test和can_bus,得到如下文件
v1.0-mini.tgz
v1.0-test_blobs.tgz
v1.0-test_meta.tgz
can_bus.zip
3.1.2. 下载全量数据
需要下载TrainVal, Test和can_bus,得到如下文件
v1.0-trainval01_blobs.tgz
v1.0-trainval02_blobs.tgz
v1.0-trainval03_blobs.tgz
v1.0-trainval04_blobs.tgz
v1.0-trainval05_blobs.tgz
v1.0-trainval06_blobs.tgz
v1.0-trainval07_blobs.tgz
v1.0-trainval08_blobs.tgz
v1.0-trainval09_blobs.tgz
v1.0-trainval10_blobs.tgz
v1.0-trainval_meta.tgzv1.0-test_blobs.tgz
v1.0-test_meta.tgz
can_bus.zip
3.2. 组织数据
3.2.1. 组织Mini数据
把Mini的压缩包都放在同一个目录,例如名为v1.0-mini,然后解压,解压的时候会有一些目录合并。
把v1.0-mini改名为v1.0-trainval,这样得到的目录是
maps
samples
sweeps
v1.0-test
v1.0-trainval
can_bus
3.2.2. 组织全量数据
把全量的压缩包都放在同一个目录,例如名为v1.0-full,然后解压,解压的时候会有一些目录合并。
maps
samples
sweeps
v1.0-test
v1.0-trainval
can_bus
3.3. 预处理数据
python tools/create_data.py nuscenes --root-path [your path]/v1.0-mini/ --out-dir [your path]/v1.0-mini/ --extra-tag nuscenes --version v1.0 --canbus [your path]
4. 训练
打开文件projects/configs/bevformer/bevformer_base.py,修改data_root.
./tools/dist_train.sh ./projects/configs/bevformer/bevformer_base.py 8
5. 评测
./tools/dist_test.sh ./projects/configs/bevformer/bevformer_base.py ./path/to/ckpts.pth 8
参考文献
https://github.com/fundamentalvision/BEVFormer/blob/master/docs/install.md
https://github.com/fundamentalvision/BEVFormer/blob/master/docs/getting_started.md