Skip to content

Commit d131b42

Browse files
authored
3D Lidar(KITTI) Detection using PointPillars (#1027)
* zhulf0804/PointPillars * update .gitignore * update readme to cite zhulf0804/PointPillars repo * ov extension This extension will run on CPUs * pytorch CPP extension * ov export and e2e inference, test, eval scripts * Kitti pcd support * containerised environment setup * Enable nn model to run on GPU * cleanup * moved pointPillars under 3d * converted xml/bin, extension library still needs to be built * Remove LICENSE * Update READMEs * Sample docker compose yaml * Third Party license for PointPillars * Third Party licenses for PointPillars
1 parent 0d51353 commit d131b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+37327
-21
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This list gives an overview of all modules available inside the contrib reposito
1616
* [**OpenVINO Code**](./modules/openvino_code): VSCode extension for AI code completion with OpenVINO.
1717
* [**Ollama-OpenVINO**](./modules/ollama_openvino): OpenVINO GenAI empowered Ollama which accelerate LLM on Intel platforms(including CPU, iGPU/dGPU, NPU).
1818
* [**ov_training_kit**](./modules/ov_training_kit): Training Kit Python library -- provides scikit-learn, PyTorch and Tensorflow wrappers for training, optimization, and deployment with OpenVINO on AI PCs.
19+
* [**3D Point Pillars**](./modules/3d/pointPillars): Use OpenVINO to perform 3D object detection with PointPillars model.
1920

2021
## How to build OpenVINO with extra modules
2122
You can build OpenVINO, so it will include the modules from this repository. Contrib modules are under constant development and it is recommended to use them alongside the master branch or latest releases of OpenVINO.
@@ -40,6 +41,7 @@ Additional build instructions are available for the following modules:
4041
* [**custom_operations**](./modules/custom_operations/README.md)
4142
* [**ollama_OpenVINO**](./modules/ollama_openvino)
4243
* [**openvino-langchain**](./modules/openvino-langchain): LangChain.js integrations for OpenVINO™
44+
* [**3D Point Pillars**](./modules/3d/pointPillars): Check the [README](./modules/3d/pointPillars/README.md) for detailed usage and build instructions.
4345

4446
## Update the repository documentation
4547
In order to keep a clean overview containing all contributed modules, the following files need to be created/adapted:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Git files
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# Python cache
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
12+
# Build artifacts
13+
build/
14+
dist/
15+
*.egg-info/
16+
.eggs/
17+
18+
# IDE
19+
.vscode/
20+
.idea/
21+
*.swp
22+
*.swo
23+
*~
24+
25+
# OS files
26+
.DS_Store
27+
Thumbs.db
28+
29+
# Documentation
30+
*.md
31+
!README.md
32+
figures/
33+
misc/
34+
35+
# Docker files
36+
devops/

modules/3d/pointPillars/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__
2+
build/
3+
*.egg-info
4+
*.so
5+
*_logs*
6+
tmp/
7+
results/
8+
.idea

modules/3d/pointPillars/README.md

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# Note
2+
3+
_This directory is a fork from [PointPillars](https://github.com/zhulf0804/PointPillars) (commit 620e6b0)._
4+
-----------------------
5+
6+
<details>
7+
<summary style="font-size:2em; font-weight:600">OpenVino Model Export and Inference</summary>
8+
9+
```bash
10+
# Install the required packages
11+
sudo apt update && sudo apt install -y \
12+
software-properties-common \
13+
build-essential \
14+
cmake \
15+
git \
16+
libx11-6 \
17+
libgl1
18+
```
19+
20+
Tested over python 3.10:
21+
```bash
22+
conda install python=3.10
23+
conda create -n ovpp310 python=3.10
24+
conda activate ovpp310
25+
```
26+
Considering the `REPO_ROOT` variable points to the `pointPillars` directory:
27+
28+
```bash
29+
REPO_ROOT=/path/to/3d/pointPillars
30+
```
31+
32+
Install the required python packages:
33+
```bash
34+
# Install the required pip packages
35+
python -m pip install -r "${REPO_ROOT}/requirements-ov.txt"
36+
```
37+
38+
Build the pytorch extension required for exporting the model:
39+
```bash
40+
# Build the pytorch extensions (will be used only to export the model)
41+
cd ${REPO_ROOT}
42+
CPU_BUILD=1 python setup.py build_ext --inplace
43+
cd ..
44+
```
45+
46+
Build the OpenVino Extension required for inference:
47+
```bash
48+
# Build the openvino extension
49+
cd "${REPO_ROOT}/ov_extensions" && rm -rf build/ && bash build.sh && cd ..
50+
```
51+
52+
Exporting the model:
53+
```bash
54+
# Export the PointPillars .pth model to OpenVINO format
55+
python "${REPO_ROOT}/export_ov_e2e.py" --checkpoint "${REPO_ROOT}/pretrained/epoch_160.pth" --output "${REPO_ROOT}/pretrained/pointpillars_ov"
56+
```
57+
The above command will generate the following five files:
58+
- pointpillars_ov_config.json
59+
- pointpillars_ov_nn.bin
60+
- pointpillars_ov_nn.xml
61+
- pointpillars_ov_pillar_layer.xml
62+
- pointpillars_ov_postproc.xml
63+
64+
Running inference using OpenVINO over a single pc data:
65+
```bash
66+
# Run inference with OpenVINO
67+
python "${REPO_ROOT}/e2eOVInference.py" --config "${REPO_ROOT}/pretrained/pointpillars_ov_config.json" --pc_path "${REPO_ROOT}/pointpillars/dataset/demo_data/test/000002.bin"
68+
```
69+
The Kitti dataset Download and Preprocess steps are described in [this section](#datasets). Say, it is stored in `${REPO_ROOT}/Datasets`.
70+
71+
Evaluate model over the KITTI val set:
72+
```bash
73+
python "${REPO_ROOT}/evaluate-e2eOV.py" --device CPU --data_root "${REPO_ROOT}/Datasets" --config "${REPO_ROOT}/pretrained/pointpillars_full_config.json" --saved_path "${REPO_ROOT}/profiles/evals-e2eov-cpu"
74+
```
75+
76+
</details>
77+
78+
79+
# [PointPillars: Fast Encoders for Object Detection from Point Clouds](https://arxiv.org/abs/1812.05784)
80+
81+
A Simple PointPillars PyTorch Implenmentation for 3D Lidar(KITTI) Detection. [[Zhihu](https://zhuanlan.zhihu.com/p/521277176)]
82+
83+
- It can be run without installing [Spconv](https://github.com/traveller59/spconv), [mmdet](https://github.com/open-mmlab/mmdetection) or [mmdet3d](https://github.com/open-mmlab/mmdetection3d).
84+
- Only one detection network (PointPillars) was implemented in this repo, so the code may be more easy to read.
85+
- Sincere thanks for the great open-source architectures [mmcv](https://github.com/open-mmlab/mmcv), [mmdet](https://github.com/open-mmlab/mmdetection) and [mmdet3d](https://github.com/open-mmlab/mmdetection3d), which helps me to learn 3D detetion and implement this repo.
86+
87+
## News
88+
89+
- **2025-02** Making PointPillars a python package out of the code is supported.
90+
- **2024-04** Exporting PointPillars to ONNX & TensorRT is supported on branch [feature/deployment](https://github.com/zhulf0804/PointPillars/tree/feature/deployment).
91+
92+
![](./figures/pytorch_trt.png)
93+
94+
## mAP on KITTI validation set (Easy, Moderate, Hard)
95+
96+
| Repo | Metric | Overall | Pedestrian | Cyclist | Car |
97+
| :---: | :---: | :---: | :---: | :---: | :---: |
98+
| this repo | 3D-BBox | 73.3259 62.7834 59.6278 | 51.4642 47.9446 43.8040 | 81.8677 63.6617 60.9126 | 86.6456 76.7439 74.1668 |
99+
| [mmdet3d v0.18.1](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1) | 3D-BBox | 72.0537, 60.1114, 55.8320 | 52.0263, 46.4037, 42.4841 | 78.7231, 59.9526, 57.2489 | 85.4118, 73.9780, 67.7630 |
100+
| this repo | BEV | 77.8540 69.8003 66.6699 | 59.1687 54.3456 50.5023 | 84.4268 67.1409 63.7409 | 89.9664 87.9145 85.7664 |
101+
| [mmdet3d v0.18.1](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1) | BEV | 76.6485, 67.7609, 64.5605 | 59.0778, 53.3638, 48.4230 | 80.9328, 63.3447, 60.0618 | 89.9348, 86.5743, 85.1967 |
102+
| this repo | 2D-BBox | 80.5097 74.6120 71.4758 | 64.6249 61.4201 57.5965 | 86.2569 73.0828 70.1726 | 90.6471 89.3330 86.6583 |
103+
| [mmdet3d v0.18.1](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1) | 2D-BBox | 78.4938, 73.4781, 70.3613 | 62.2413, 58.9157, 55.3660 | 82.6460, 72.3547, 68.4669 | 90.5939, 89.1638, 87.2511 |
104+
| this repo | AOS | 74.9647 68.1712 65.2817 | 49.3777 46.7284 43.8352 | 85.0412 69.1024 66.2801 | 90.4752 88.6828 85.7298 |
105+
| [mmdet3d v0.18.1](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1) | AOS | 72.41, 66.23, 63.55 | 46.00, 43.22, 40.94 | 80.85, 67.20, 63.63 | 90.37, 88.27, 86.07 |
106+
107+
- **Note: Here, we report [mmdet3d v0.18.1](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1) (2022/02/09-2022/03/01) performance based on the officially provided [checkpoint](https://github.com/open-mmlab/mmdetection3d/tree/v0.18.1/configs/pointpillars#kitti). Much improvements were made in the [mmdet3d v1.0.0rc1](https://github.com/open-mmlab/mmdetection3d/tree/v1.0.0rc1)**.
108+
109+
## Detection Visualization
110+
111+
![](./figures/pc_pred_000134.png)
112+
![](./figures/img_3dbbox_000134.png)
113+
114+
## [Install]
115+
116+
Install PointPillars as a python package and all its dependencies as follows:
117+
118+
```
119+
cd PointPillars/
120+
pip install -r requirements.txt
121+
python setup.py build_ext --inplace
122+
pip install .
123+
```
124+
125+
## [Datasets]
126+
127+
1. Download
128+
129+
Download [point cloud](https://s3.eu-central-1.amazonaws.com/avg-kitti/data_object_velodyne.zip)(29GB), [images](https://s3.eu-central-1.amazonaws.com/avg-kitti/data_object_image_2.zip)(12 GB), [calibration files](https://s3.eu-central-1.amazonaws.com/avg-kitti/data_object_calib.zip)(16 MB)和[labels](https://s3.eu-central-1.amazonaws.com/avg-kitti/data_object_label_2.zip)(5 MB)。Format the datasets as follows:
130+
```
131+
kitti
132+
|- training
133+
|- calib (#7481 .txt)
134+
|- image_2 (#7481 .png)
135+
|- label_2 (#7481 .txt)
136+
|- velodyne (#7481 .bin)
137+
|- testing
138+
|- calib (#7518 .txt)
139+
|- image_2 (#7518 .png)
140+
|- velodyne (#7518 .bin)
141+
```
142+
143+
2. Pre-process KITTI datasets First
144+
145+
```
146+
cd PointPillars/
147+
python pre_process_kitti.py --data_root your_path_to_kitti
148+
```
149+
150+
Now, we have datasets as follows:
151+
```
152+
kitti
153+
|- training
154+
|- calib (#7481 .txt)
155+
|- image_2 (#7481 .png)
156+
|- label_2 (#7481 .txt)
157+
|- velodyne (#7481 .bin)
158+
|- velodyne_reduced (#7481 .bin)
159+
|- testing
160+
|- calib (#7518 .txt)
161+
|- image_2 (#7518 .png)
162+
|- velodyne (#7518 .bin)
163+
|- velodyne_reduced (#7518 .bin)
164+
|- kitti_gt_database (# 19700 .bin)
165+
|- kitti_infos_train.pkl
166+
|- kitti_infos_val.pkl
167+
|- kitti_infos_trainval.pkl
168+
|- kitti_infos_test.pkl
169+
|- kitti_dbinfos_train.pkl
170+
```
171+
172+
## [Training]
173+
174+
```
175+
cd PointPillars/
176+
python train.py --data_root your_path_to_kitti
177+
```
178+
179+
## [Evaluation]
180+
181+
```
182+
cd PointPillars/
183+
python evaluate.py --ckpt pretrained/epoch_160.pth --data_root your_path_to_kitti
184+
```
185+
186+
## [Test]
187+
188+
```
189+
cd PointPillars/
190+
191+
# 1. infer and visualize point cloud detection
192+
python test.py --ckpt pretrained/epoch_160.pth --pc_path your_pc_path
193+
194+
# 2. infer and visualize point cloud detection and gound truth.
195+
python test.py --ckpt pretrained/epoch_160.pth --pc_path your_pc_path --calib_path your_calib_path --gt_path your_gt_path
196+
197+
# 3. infer and visualize point cloud & image detection
198+
python test.py --ckpt pretrained/epoch_160.pth --pc_path your_pc_path --calib_path your_calib_path --img_path your_img_path
199+
200+
201+
e.g.
202+
a. [infer on val set 000134]
203+
204+
python test.py --ckpt pretrained/epoch_160.pth --pc_path pointpillars/dataset/demo_data/val/000134.bin
205+
206+
or
207+
208+
python test.py --ckpt pretrained/epoch_160.pth --pc_path pointpillars/dataset/demo_data/val/000134.bin \
209+
--calib_path pointpillars/dataset/demo_data/val/000134.txt \
210+
--img_path pointpillars/dataset/demo_data/val/000134.png \
211+
--gt_path pointpillars/dataset/demo_data/val/000134_gt.txt
212+
213+
b. [infer on test set 000002]
214+
215+
python test.py --ckpt pretrained/epoch_160.pth --pc_path pointpillars/dataset/demo_data/test/000002.bin
216+
217+
or
218+
219+
python test.py --ckpt pretrained/epoch_160.pth --pc_path pointpillars/dataset/demo_data/test/000002.bin \
220+
--calib_path pointpillars/dataset/demo_data/test/000002.txt \
221+
--img_path pointpillars/dataset/demo_data/test/000002.png
222+
```
223+
224+
## Acknowledements
225+
226+
Thanks for the open source code [mmcv](https://github.com/open-mmlab/mmcv), [mmdet](https://github.com/open-mmlab/mmdetection) and [mmdet3d](https://github.com/open-mmlab/mmdetection3d).
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
ARG PYTHON_VERSION=3.10
2+
ARG UBUNTU_VERSION=24.04
3+
4+
ARG http_proxy
5+
ARG https_proxy
6+
ARG no_proxy
7+
8+
FROM ubuntu:${UBUNTU_VERSION} AS base-selected
9+
10+
# Set environment variables
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
ENV LANG=C.UTF-8
13+
ENV LC_ALL=C.UTF-8
14+
15+
# Install system dependencies
16+
RUN apt update && \
17+
apt install -y --no-install-recommends \
18+
software-properties-common \
19+
cmake \
20+
build-essential \
21+
libx11-6 \
22+
libgl1
23+
24+
# Install Python and pip
25+
ARG PYTHON_VERSION
26+
RUN add-apt-repository -y ppa:deadsnakes/ppa
27+
RUN apt-get update && \
28+
apt-get install -y --no-install-recommends \
29+
python${PYTHON_VERSION} \
30+
python${PYTHON_VERSION}-dev \
31+
python${PYTHON_VERSION}-distutils \
32+
python3-pip \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Create symbolic links for python
36+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
37+
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1
38+
39+
# Upgrade pip, setuptools, wheel, blinker
40+
RUN python -m pip install --no-cache-dir --upgrade --ignore-installed pip setuptools wheel blinker
41+
42+
# intel GPU
43+
RUN cd /usr/lib/python3/dist-packages/ && \
44+
ln -s apt_pkg.cpython-312-x86_64-linux-gnu.so apt_pkg.so
45+
46+
RUN add-apt-repository -y ppa:kobuk-team/intel-graphics || true
47+
RUN apt update && \
48+
apt install -y --no-install-recommends \
49+
libze-intel-gpu1 \
50+
intel-opencl-icd
51+
52+
53+
54+
55+
# Set working directory
56+
WORKDIR /workspace
57+
58+
# Install Python packages
59+
COPY requirements.txt .
60+
RUN python -m pip install --no-cache-dir -r requirements.txt
61+
62+
# Building torch extensions...
63+
COPY pointpillars/ ./pointpillars/
64+
COPY setup.py .
65+
RUN CPU_BUILD=1 python setup.py build_ext --inplace
66+
67+
# Building OpenVINO extensions...
68+
COPY ov_extensions ./ov_extensions
69+
RUN cd ov_extensions && rm -rf build && bash build.sh && cd ..
70+
71+
# Exporting OpenVINO model
72+
COPY export_ov_e2e.py .
73+
COPY pretrained ./pretrained
74+
# python export_ov_e2e.py --checkpoint pretrained/epoch_160.pth --output pretrained/pointpillars_ov
75+
76+
# Test
77+
COPY e2eOVInference.py .
78+
COPY test-e2eOV.py .
79+
# python test-e2eOV.py --device CPU
80+
# python test-e2eOV.py --device GPU
81+
82+
# Evaluation Kitti
83+
COPY evaluate-e2eOV.py .
84+
# python evaluate-e2eOV.py --data_root /Datasets --nsamples 10

0 commit comments

Comments
 (0)