使用卷積神經網絡進行激光雷達點雲目標檢測——SECOND
原創W_Tortoise 發布於2019-01-29 15:28:28 閱讀數 3033 收藏
展開
前言
現在出現了很多使用卷積神經網絡進行點雲目標檢測的工作,今天就分享一項這方面的工作,其最大優勢是推理速度快。
論文:https://www.mdpi.com/1424-8220/18/10/3337
Github:https://github.com/traveller59/second.pytorch
KITTI 3D Object Detection Ranking:http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d
注:
該工作剛發表時,曾是第一名,不過刷榜的人太多,出現了更優秀的算法,所以排名下降了,但這是前幾名中唯一開源的。
從作者簡介中可以看出,作者是重慶大學的研究生,其導師(猜測)和主線科技的員工。這應該是一名研究生在公司實習時完成的工作,好生敬佩與羡慕。
對於研究生來說,最好還是接觸實際的項目,盡量早點出去實習,但可能每個人都有各自的苦衷吧。
簡單翻譯一下摘要:
基於LiDAR或基於RGB-D的目標檢測應用於從自動駕駛到機器人視覺的各種應用。基於體素的3D卷積網絡已經使用了一段時間,以在處理LiDAR點雲數據時增強信息的保留。然而,問題仍然存在,包括推理速度慢和方位估計性能差。因此,我們研究了一種改進的稀疏卷積方法用於這種網絡,這顯着地增加了對於訓練和推理的速度。通過引入角度損失的方法來提高方向估計性能,以及一種新的能增強收斂速度和性能的數據增強方法。所提出的網絡在KITTI 3D物體檢測基准測試中產生最先進的結果,同時保持快速的推理速度。
主要貢獻:
We apply sparse convolution in LiDAR-based object detection, thereby greatly increasing the speeds of training and inference.
We propose an improved method of sparse convolution that allows it to run faster.
We propose a novel angle loss regression approach that demonstrates better orientation regression performance than - other methods do.
We introduce a novel data augmentation method for LiDAR-only learning problems that greatly increases the convergence speed and performance.
網絡架構:
檢測結果:
注:這里的圖像只是用來驗證點雲目標檢測的結果。
安裝
0.環境
Python 3.6+
pytorch 1.0.0+
Ubuntu 16.04/18.04
1.下載代碼
git clone https://github.com/traveller59/second.pytorch.git
cd ./second.pytorch/second
1
2
2.安裝Python依賴包
建議使用 Anaconda 包管理器。
pip install shapely fire pybind11 tensorboardX protobuf scikit-image numba pillow
1
如果你沒有Anaconda:
pip install numba
1
按照spconv中的說明安裝spconv。
3.為numba設置cuda
你需要為 numba.cuda 添加以下環境變量,你可以將它們添加到~/.bashrc:
export NUMBAPRO_CUDA_DRIVER=/usr/lib/x86_64-linux-gnu/libcuda.so
export NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so
export NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice
1
2
3
4.將 second.pytorch/ 添加到 PYTHONPATH
准備數據集
數據集准備
1.下載 KITTI 數據集並首先創建一些目錄:
└── KITTI_DATASET_ROOT
├── training <-- 7481 train data
| ├── image_2 <-- for visualization
| ├── calib
| ├── label_2
| ├── velodyne
| └── velodyne_reduced <-- empty directory
└── testing <-- 7580 test data
├── image_2 <-- for visualization
├── calib
├── velodyne
└── velodyne_reduced <-- empty directory
1
2
3
4
5
6
7
8
9
10
11
12
2.創建KITTI的相關信息:
python create_data.py create_kitti_info_file --data_path=KITTI_DATASET_ROOT
1
3.創建縮減點雲(reduced point cloud):
python create_data.py create_reduced_point_cloud --data_path=KITTI_DATASET_ROOT
1
4.創建真值數據庫(groundtruth-database)信息:
python create_data.py create_groundtruth_database --data_path=KITTI_DATASET_ROOT
1
5.修改配置文件
在配置文件中需要配置一些路徑:
train_input_reader: {
...
database_sampler {
database_info_path: "/path/to/kitti_dbinfos_train.pkl"
...
}
kitti_info_path: "/path/to/kitti_infos_train.pkl"
kitti_root_path: "KITTI_DATASET_ROOT"
}
...
eval_input_reader: {
...
kitti_info_path: "/path/to/kitti_infos_val.pkl"
kitti_root_path: "KITTI_DATASET_ROOT"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
用法
訓練
python ./pytorch/train.py train --config_path=./configs/car.fhd.config --model_dir=/path/to/model_dir
1
如果要訓練新模型,請確保/path/to/model_dir不存在。如果model_dir不存在,將創建一個新目錄,否則將讀取其中的檢查點(checkpoints)。
訓練過程使用batchsize = 6作為 1080Ti 的默認值,如果 GPU 內存較少,則需要減少 batchsize 的大小。
目前僅支持單GPU訓練,但在單個1080Ti中訓練模型僅需要20小時(165個epoch),並且僅需要50個epoch以達到78.3 AP,with super converge in car moderate 3D in Kitti validation dateset。
評估
python ./pytorch/train.py evaluate --config_path=./configs/car.fhd.config --model_dir=/path/to/model_dir --measure_time=True --batch_size=1
1
如果使用--pickle_result = False,檢測結果將保存為model_dir/eval_results/step_xxx中的result.pkl文件或保存為官方KITTI標簽格式。
預訓練模型
您可以在谷歌硬盤中下載預訓練模型。car_fhd模型對應於car.fhd.config。
請注意,此預訓練模型是在修復稀疏卷積的錯誤之前訓練的,因此評估結果可能稍差。
Docker(我沒時間為SECOND-V1.5構建docker)
你可以使用預構建的docker進行測試:
docker pull scrin/second-pytorch
1
然后運行:
nvidia-docker run -it --rm -v /media/yy/960evo/datasets/:/root/data -v $HOME/pretrained_models:/root/model --ipc=host second-pytorch:latest
python ./pytorch/train.py evaluate --config_path=./configs/car.config --model_dir=/root/model/car
1
2
試用Kitti Viewer Web
主要步驟
1.在你的server/local運行python ./kittiviewer/backend.py main --port = xxxx。
2.運行cd ./kittiviewer/frontend && python -m http.server,以啟動本地Web服務器。
3.打開瀏覽器並輸入你的前端URL(例如,默認是http//127.0.0.18000)
4.輸入后端網址(例如http://127.0.0.1:16666)
5.輸入root路徑,info路徑和det路徑(可選)
6.單擊load,loadDet(可選),在屏幕中央底部輸入圖像索引,然后按Enter鍵。
推理步驟
首先,必須單擊 load 按鈕並成功加載。
輸入checkpointPath和configPath
單擊buildNet
點擊inference
試用Kitti Viewer(已棄用)
在訓練前,你應該使用基於pyqt和pyqtgraph的kitti viewer檢查數據。
運行python ./kittiviewer/viewer.py,查看下面的圖片以使用kitti viewer:
概念
Kitti lidar box
kitti lidar box由7個元素組成:[x, y, z, w, l, h, rz],見下圖:
所有訓練和推理代碼均使用kitti box格式。所以我們需要在訓練之前將其他格式轉換為KITTI格式。
Kitti camera box
kitti camera box由7個元素組成:[x, y, z, l, h, w, ry]。
注:更詳盡的理論還是看論文,工程實現看代碼。
————————————————
版權聲明:本文為CSDN博主「W_Tortoise」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/learning_tortosie/article/details/86686007
