Spconv1.0安装与CLOCs复现
1.Spconv1.0安装
anaconda3中安装的虚拟环境为Pytorch1.1 cuda=10.0 python=3.6。
其中电脑上安装的cuda版本应与pytorch上安装的cuda版本一致。
下面的有些依赖是CLOCs中的。
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0 -c pytorch
# 配置second运行环境-----
pip install cmake==3.14.3
conda install scikit-image scipy numba pillow matplotlib shapely
pip install fire tensorboardX protobuf opencv-python pccm
#--------
sudo apt-get install libboost-all-dev
git clone https://github.com/traveller59/spconv
cd spconv
git reset --hard 8da6f967fb9a054d8870c3515b1b44eca2103634
cd third_party/
rm pybind11/
git clone https://github.com/pybind/pybind11.git
cd pybind11/
git reset --hard 085a2943
cd ../../ #进入到spconv目录下
python setup.py bdist_wheel
python -m pip install dist/*.whl
#安装成功
如果上述的git reset --hard 085a2943不可行的话,就不要执行git clone https://github.com/pybind/pybind11.git这一步,进入下面的链接
https://github.com/traveller59/spconv/tree/8da6f967fb9a054d8870c3515b1b44eca2103634,进入到third_party里面的pybind11进行下载。
2.CLOCs复现
git clone https://github.com/pangsu0613/CLOCs.git
mkdir CLOCs/d2_detection_data
mkdir CLOCs/model_dir
2.1构建KITTI数据集
└── KITTI_DATASET_ROOT
├── training <-- 7481 train data
| ├── image_2 <-- for visualization
| ├── calib
| ├── label_2
| ├── velodyne
| └── velodyne_reduced <-- empty directory
└── testing <-- 7518 test data
| ├── image_2 <-- for visualization
| ├── calib
| ├── velodyne
| └── velodyne_reduced <-- empty directory
└── kitti_dbinfos_train.pkl
├── kitti_infos_train.pkl
├── kitti_infos_test.pkl
├── kitti_infos_val.pkl
└── kitti_infos_trainval.pkl
上面的test数据集没有安装,因此需要进入到second/create_data.py中注释掉跟test有关的代码。KITTI_DATASET_ROOT需要自建立
2.2初始化数据索引
# 进入到second文件夹下
python create_data.py create_kitti_info_file --data_path=../KITTI_DATASET_ROOT
python create_data.py create_reduced_point_cloud --data_path=../KITTI_DATASET_ROOT
python create_data.py create_groundtruth_database --data_path=../KITTI_DATASET_ROOT
如果在运行上述代码时出现No module named 'second’的相关字样,可以在second.core的上面一行引入路径
import sys
sys.path.append('这里面放入绝对路径,second的上一级目录,这里应该是CLOCs')
3.2导入模型
将作者提供的三维检测模型second_model.zip导入到model_dir中,将二维检测目标结果cascade_rcnn_sigmoid_data导入到d2_detection_data中,源文件下载地址CLOCs_related_files - Google 云端硬盘。
3.3运行文件路径修改
修改训练配置文件CLOCs/second/configs/car.fhd.config
,cyclist和pedestrian同理。
train_input_reader: {
...
database_sampler {
database_info_path: "/dir/to/your/kitti_dbinfos_train.pkl"
...
}
kitti_info_path: "/dir/to/your/kitti_infos_train.pkl"
kitti_root_path: "/dir/to/your/KITTI_DATASET_ROOT"
}
...
train_config: {
...
detection_2d_path: "/dir/to/2d_detection/data"
}
...
eval_input_reader: {
...
kitti_info_path: "/dir/to/your/kitti_infos_val.pkl"
kitti_root_path: "/dir/to/your/KITTI_DATASET_ROOT"
}
3.4 CLOCs训练
python ./pytorch/train.py train --config_path=./configs/car.fhd.config --model_dir=../model_dir
训练时出现no module named 'torchplus’的问题,处理方法同上面的second。
3.5CLOCs算法评估
python ./pytorch/train.py evaluate --config_path=./configs/car.fhd.config --model_dir=../model_dir --measure_time=True --batch_size=1
使用的是作者给的预训练模型,将CLOCs_SecCas_pretrained.zip解压到model_dir中,再将second_model.zip解压到model_dir中进行评估训练,这里我注释了train.py中的两行代码,这两行是输出2D检测结果,我只需要3D结果,故不影响。
result = get_coco_eval_result(gt_annos, dt_annos, class_names)
print(result)
最终的评估结果如下,(自己训练的结果删了,所以拿作者的结果贴出来了):