Skip to content

Commit 18bb0a4

Browse files
committed
Code release
0 parents  commit 18bb0a4

Some content is hidden

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

63 files changed

+6793
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode
2+
datasets
3+
output
4+
outputs
5+
**/__pycache__
6+
*.pyc
7+
**/.ipynb_checkpoints
8+
downstream/results
9+
checkpoints/
10+
*.pt

Dockerfile

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM pytorch/pytorch:1.12.0-cuda11.3-cudnn8-devel
2+
3+
# --------------------------------------------------------------------
4+
5+
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
6+
7+
RUN DEBIAN_FRONTEND=noninteractive apt-get update
8+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y openssh-server sudo
9+
10+
# -------------------------------------------------------------------
11+
12+
##############################################
13+
ENV TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6+PTX"
14+
##############################################
15+
16+
ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
17+
18+
# Install dependencies
19+
RUN apt-get update
20+
RUN apt-get install -y git ninja-build cmake build-essential libopenblas-dev \
21+
xterm xauth openssh-server tmux wget mate-desktop-environment-core
22+
23+
RUN apt-get clean
24+
RUN rm -rf /var/lib/apt/lists/*
25+
26+
# For faster build, use more jobs.
27+
ENV MAX_JOBS=4
28+
RUN pip install -U git+https://github.com/NVIDIA/MinkowskiEngine --install-option="--blas=openblas" --install-option="--force_cuda" -v --no-deps
29+
30+
RUN apt-get install libgl1-mesa-glx -y
31+
RUN pip install spconv-cu113
32+
33+
# Torchsparse
34+
RUN apt-get update
35+
RUN apt-get install libsparsehash-dev
36+
RUN FORCE_CUDA=1 pip install --upgrade git+https://github.com/mit-han-lab/[email protected]
37+
38+
# Torch Geometric
39+
RUN pip install torch_scatter -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
40+
RUN pip install torch-geometric hydra-core
41+
RUN pip install tqdm easydict tensorboardX
42+
43+
RUN pip install pytorch-lightning==1.6.5
44+
45+
RUN pip install nuscenes-devkit==1.1.9

LICENSE

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
BEVContrast
2+
3+
Copyright 2023 Valeo
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
18+
19+
Apache License
20+
Version 2.0, January 2004
21+
https://www.apache.org/licenses/
22+
23+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
24+
25+
1. Definitions.
26+
27+
"License" shall mean the terms and conditions for use, reproduction,
28+
and distribution as defined by Sections 1 through 9 of this document.
29+
30+
"Licensor" shall mean the copyright owner or entity authorized by
31+
the copyright owner that is granting the License.
32+
33+
"Legal Entity" shall mean the union of the acting entity and all
34+
other entities that control, are controlled by, or are under common
35+
control with that entity. For the purposes of this definition,
36+
"control" means (i) the power, direct or indirect, to cause the
37+
direction or management of such entity, whether by contract or
38+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
39+
outstanding shares, or (iii) beneficial ownership of such entity.
40+
41+
"You" (or "Your") shall mean an individual or Legal Entity
42+
exercising permissions granted by this License.
43+
44+
"Source" form shall mean the preferred form for making modifications,
45+
including but not limited to software source code, documentation
46+
source, and configuration files.
47+
48+
"Object" form shall mean any form resulting from mechanical
49+
transformation or translation of a Source form, including but
50+
not limited to compiled object code, generated documentation,
51+
and conversions to other media types.
52+
53+
"Work" shall mean the work of authorship, whether in Source or
54+
Object form, made available under the License, as indicated by a
55+
copyright notice that is included in or attached to the work
56+
(an example is provided in the Appendix below).
57+
58+
"Derivative Works" shall mean any work, whether in Source or Object
59+
form, that is based on (or derived from) the Work and for which the
60+
editorial revisions, annotations, elaborations, or other modifications
61+
represent, as a whole, an original work of authorship. For the purposes
62+
of this License, Derivative Works shall not include works that remain
63+
separable from, or merely link (or bind by name) to the interfaces of,
64+
the Work and Derivative Works thereof.
65+
66+
"Contribution" shall mean any work of authorship, including
67+
the original version of the Work and any modifications or additions
68+
to that Work or Derivative Works thereof, that is intentionally
69+
submitted to Licensor for inclusion in the Work by the copyright owner
70+
or by an individual or Legal Entity authorized to submit on behalf of
71+
the copyright owner. For the purposes of this definition, "submitted"
72+
means any form of electronic, verbal, or written communication sent
73+
to the Licensor or its representatives, including but not limited to
74+
communication on electronic mailing lists, source code control systems,
75+
and issue tracking systems that are managed by, or on behalf of, the
76+
Licensor for the purpose of discussing and improving the Work, but
77+
excluding communication that is conspicuously marked or otherwise
78+
designated in writing by the copyright owner as "Not a Contribution."
79+
80+
"Contributor" shall mean Licensor and any individual or Legal Entity
81+
on behalf of whom a Contribution has been received by Licensor and
82+
subsequently incorporated within the Work.
83+
84+
2. Grant of Copyright License. Subject to the terms and conditions of
85+
this License, each Contributor hereby grants to You a perpetual,
86+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
87+
copyright license to reproduce, prepare Derivative Works of,
88+
publicly display, publicly perform, sublicense, and distribute the
89+
Work and such Derivative Works in Source or Object form.
90+
91+
3. Grant of Patent License. Subject to the terms and conditions of
92+
this License, each Contributor hereby grants to You a perpetual,
93+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
94+
(except as stated in this section) patent license to make, have made,
95+
use, offer to sell, sell, import, and otherwise transfer the Work,
96+
where such license applies only to those patent claims licensable
97+
by such Contributor that are necessarily infringed by their
98+
Contribution(s) alone or by combination of their Contribution(s)
99+
with the Work to which such Contribution(s) was submitted. If You
100+
institute patent litigation against any entity (including a
101+
cross-claim or counterclaim in a lawsuit) alleging that the Work
102+
or a Contribution incorporated within the Work constitutes direct
103+
or contributory patent infringement, then any patent licenses
104+
granted to You under this License for that Work shall terminate
105+
as of the date such litigation is filed.
106+
107+
4. Redistribution. You may reproduce and distribute copies of the
108+
Work or Derivative Works thereof in any medium, with or without
109+
modifications, and in Source or Object form, provided that You
110+
meet the following conditions:
111+
112+
(a) You must give any other recipients of the Work or
113+
Derivative Works a copy of this License; and
114+
115+
(b) You must cause any modified files to carry prominent notices
116+
stating that You changed the files; and
117+
118+
(c) You must retain, in the Source form of any Derivative Works
119+
that You distribute, all copyright, patent, trademark, and
120+
attribution notices from the Source form of the Work,
121+
excluding those notices that do not pertain to any part of
122+
the Derivative Works; and
123+
124+
(d) If the Work includes a "NOTICE" text file as part of its
125+
distribution, then any Derivative Works that You distribute must
126+
include a readable copy of the attribution notices contained
127+
within such NOTICE file, excluding those notices that do not
128+
pertain to any part of the Derivative Works, in at least one
129+
of the following places: within a NOTICE text file distributed
130+
as part of the Derivative Works; within the Source form or
131+
documentation, if provided along with the Derivative Works; or,
132+
within a display generated by the Derivative Works, if and
133+
wherever such third-party notices normally appear. The contents
134+
of the NOTICE file are for informational purposes only and
135+
do not modify the License. You may add Your own attribution
136+
notices within Derivative Works that You distribute, alongside
137+
or as an addendum to the NOTICE text from the Work, provided
138+
that such additional attribution notices cannot be construed
139+
as modifying the License.
140+
141+
You may add Your own copyright statement to Your modifications and
142+
may provide additional or different license terms and conditions
143+
for use, reproduction, or distribution of Your modifications, or
144+
for any such Derivative Works as a whole, provided Your use,
145+
reproduction, and distribution of the Work otherwise complies with
146+
the conditions stated in this License.
147+
148+
5. Submission of Contributions. Unless You explicitly state otherwise,
149+
any Contribution intentionally submitted for inclusion in the Work
150+
by You to the Licensor shall be under the terms and conditions of
151+
this License, without any additional terms or conditions.
152+
Notwithstanding the above, nothing herein shall supersede or modify
153+
the terms of any separate license agreement you may have executed
154+
with Licensor regarding such Contributions.
155+
156+
6. Trademarks. This License does not grant permission to use the trade
157+
names, trademarks, service marks, or product names of the Licensor,
158+
except as required for reasonable and customary use in describing the
159+
origin of the Work and reproducing the content of the NOTICE file.
160+
161+
7. Disclaimer of Warranty. Unless required by applicable law or
162+
agreed to in writing, Licensor provides the Work (and each
163+
Contributor provides its Contributions) on an "AS IS" BASIS,
164+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
165+
implied, including, without limitation, any warranties or conditions
166+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
167+
PARTICULAR PURPOSE. You are solely responsible for determining the
168+
appropriateness of using or redistributing the Work and assume any
169+
risks associated with Your exercise of permissions under this License.
170+
171+
8. Limitation of Liability. In no event and under no legal theory,
172+
whether in tort (including negligence), contract, or otherwise,
173+
unless required by applicable law (such as deliberate and grossly
174+
negligent acts) or agreed to in writing, shall any Contributor be
175+
liable to You for damages, including any direct, indirect, special,
176+
incidental, or consequential damages of any character arising as a
177+
result of this License or out of the use or inability to use the
178+
Work (including but not limited to damages for loss of goodwill,
179+
work stoppage, computer failure or malfunction, or any and all
180+
other commercial damages or losses), even if such Contributor
181+
has been advised of the possibility of such damages.
182+
183+
9. Accepting Warranty or Additional Liability. While redistributing
184+
the Work or Derivative Works thereof, You may choose to offer,
185+
and charge a fee for, acceptance of support, warranty, indemnity,
186+
or other liability obligations and/or rights consistent with this
187+
License. However, in accepting such obligations, You may act only
188+
on Your own behalf and on Your sole responsibility, not on behalf
189+
of any other Contributor, and only if You agree to indemnify,
190+
defend, and hold each Contributor harmless for any liability
191+
incurred by, or claims asserted against, such Contributor by reason
192+
of your accepting any such warranty or additional liability.
193+
194+
END OF TERMS AND CONDITIONS

README.md

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# BEVContrast: Self-Supervision in BEV Space for Automotive Lidar Point Clouds
2+
3+
Official Pytorch implementation of the method **BEVContrast**. More details can be found in the paper:
4+
5+
**BEVContrast: Self-Supervision in BEV Space for Automotive Lidar Point Clouds**, TODO 2024 [[arXiv](TODO)]
6+
by *Corentin Sautier, Gilles Puy, Alexandre Boulch, Renaud Marlet, and Vincent Lepetit*
7+
8+
![Overview of the method](./assets/method.png)
9+
10+
If you use BEVContrast in your research, please cite:
11+
```
12+
@InProceedings{BEVContrast,
13+
author = {Sautier, Corentin and Puy, Gilles and Boulch, Alexandre and Marlet, Renaud and Lepetit, Vincent},
14+
title = {BEVContrast: Self-Supervision in BEV Space for Automotive Lidar Point Clouds},
15+
TODO
16+
}
17+
```
18+
19+
## Dependencies
20+
21+
To install the various dependencies, you can run ```pip install -r requirements.txt```.
22+
23+
24+
## Datasets
25+
26+
The code provided can be used with [nuScenes](https://www.nuscenes.org/lidar-segmentation), [SemanticKITTI](http://www.semantic-kitti.org/tasks.html#semseg), and [SemanticPOSS](http://www.poss.pku.edu.cn/semanticposs.html). Put the datasets you intend to use in the datasets folder (a symbolic link is accepted).
27+
28+
## Pre-trained models
29+
30+
### Minkowski SR-UNet
31+
[SR-UNet pre-trained on nuScenes](https://github.com/valeoai/BEVContrast/releases/download/v1.0/minkunet_bevcontrast_ns.pt)
32+
33+
[SR-UNet pre-trained on SemanticKITTI](https://github.com/valeoai/BEVContrast/releases/download/v1.0/minkunet_bevcontrast_sk.pt)
34+
35+
### SPconv VoxelNet
36+
[VoxelNet pre-trained on nuScenes](https://github.com/valeoai/BEVContrast/releases/download/v1.0/voxelnet_bevcontrast_ns.pt)
37+
38+
## Reproducing the results
39+
40+
*When using MinkowskiEngine (on SemanticKITTI), please set the OMP_NUM_THREADS environment variable to your number of CPU cores*
41+
42+
### Semantic segmentation's pre-training
43+
44+
Config file for SemanticKITTI is included for [MinkowskiEngine](https://github.com/NVIDIA/MinkowskiEngine) by default to keep retro-compatibility with previous work, while for nuScenes it uses [Torchsparse](https://github.com/mit-han-lab/torchsparse) which is generally faster. Switching between libraries in the config files is easy. While architectures are similar, weights from one library cannot easily be transferred to the other.
45+
46+
- On SemanticKITTI:
47+
48+
```python train.py --config_file cfgs/pretrain_sk_minkunet.yaml --name minkunet_bevcontrast_sk```
49+
50+
- On nuScenes:
51+
52+
```python train.py --config_file cfgs/pretrain_ns_minkunet.yaml --name minkunet_bevcontrast_ns```
53+
54+
### Semantic segmentation's downstream
55+
56+
The specific code for downstream semantic segmentation has been adapted from [ALSO](https://github.com/valeoai/ALSO).
57+
58+
#### Results on nuScenes' validation set using a Minkowski SR-Unet 34:
59+
Method | 0.1% | 1% | 10% | 50% | 100%
60+
--- |:-: |:-: |:-: |:-: |:-:
61+
Random init. | 21.6 | 35.0 | 57.3 | 69.0 | 71.2
62+
[PointContrast](https://arxiv.org/abs/2007.10985) |**27.1**| 37.0 | 58.9 | 69.4 | 71.1
63+
[DepthContrast](https://arxiv.org/abs/2101.02691) | 21.7 | 34.6 | 57.4 | 69.2 | 71.2
64+
[ALSO](https://arxiv.org/abs/2104.04687) | 26.2 | 37.4 |**59.0**| 69.8 | 71.8
65+
BEVContrast | 26.6 |**37.9**|**59.0**|**70.5**|**72.2**
66+
67+
To launch a downstream experiment, with a Torchsparse SR-Unet, you can use these commands in addition with `cfg.downstream.checkpoint_dir=[checkpoint directory] cfg.downstream.checkpoint_name=[checkpoint name]`
68+
69+
```bash
70+
cd downstream
71+
72+
# 100%
73+
python train_downstream_semseg.py cfg=nuscenes_torchsparse cfg.downstream.max_epochs=30 cfg.downstream.val_interval=5 cfg.downstream.skip_ratio=1
74+
75+
# 50%
76+
python train_downstream_semseg.py cfg=nuscenes_torchsparse cfg.downstream.max_epochs=50 cfg.downstream.val_interval=5 cfg.downstream.skip_ratio=2
77+
78+
# 10%
79+
python train_downstream_semseg.py cfg=nuscenes_torchsparse cfg.downstream.max_epochs=100 cfg.downstream.val_interval=10 cfg.downstream.skip_ratio=10
80+
81+
# 1%
82+
python train_downstream_semseg.py cfg=nuscenes_torchsparse cfg.downstream.max_epochs=500 cfg.downstream.val_interval=50 cfg.downstream.skip_ratio=100
83+
84+
# 0.1%
85+
python train_downstream_semseg.py cfg=nuscenes_torchsparse cfg.downstream.max_epochs=1000 cfg.downstream.val_interval=100 cfg.downstream.skip_ratio=1000
86+
```
87+
88+
89+
#### Results on SemanticKITTI' validation set using a Minkowski SR-Unet 18:
90+
Method | 0.1% | 1% | 10% | 50% | 100%
91+
--- |:-: |:-: |:-: |:-: |:-:
92+
Random init. | 30.0 | 46.2 | 57.6 | 61.8 | 62.7
93+
[PointContrast](https://arxiv.org/abs/2007.10985) | 32.4 | 47.9 | 59.7 | 62.7 | 63.4
94+
[SegContrast](http://www.ipb.uni-bonn.de/pdfs/nunes2022ral-icra.pdf) | 32.3 | 48.9 | 58.7 | 62.1 | 62.3
95+
[DepthContrast](https://arxiv.org/abs/2101.02691) | 32.5 | 49.0 | 60.3 | 62.9 | 63.9
96+
[STSSL](https://arxiv.org/abs/2303.16235) | 32.0 | 49.4 | 60.0 | 62.9 | 63.3
97+
[ALSO](https://arxiv.org/abs/2104.04687) | 35.0 | 50.0 | 60.5 |**63.4**| 63.6
98+
[TARL](http://www.ipb.uni-bonn.de/pdfs/nunes2023cvpr.pdf) | 37.9 | 52.5 | 61.2 |**63.4**| 63.7
99+
BEVContrast |**39.7**|**53.8**|**61.4**|**63.4**|**61.1**
100+
101+
To launch a downstream experiment, with a Minkowski SR-Unet, you can use these commands in addition with `cfg.downstream.checkpoint_dir=[checkpoint directory] cfg.downstream.checkpoint_name=[checkpoint name]`
102+
103+
```bash
104+
cd downstream
105+
106+
# 100%
107+
python train_downstream_semseg.py cfg=semantickitti_minkowski cfg.downstream.max_epochs=30 cfg.downstream.val_interval=5 cfg.downstream.skip_ratio=1
108+
109+
# 50%
110+
python train_downstream_semseg.py cfg=semantickitti_minkowski cfg.downstream.max_epochs=50 cfg.downstream.val_interval=5 cfg.downstream.skip_ratio=2
111+
112+
# 10%
113+
python train_downstream_semseg.py cfg=semantickitti_minkowski cfg.downstream.max_epochs=100 cfg.downstream.val_interval=10 cfg.downstream.skip_ratio=10
114+
115+
# 1%
116+
python train_downstream_semseg.py cfg=semantickitti_minkowski cfg.downstream.max_epochs=500 cfg.downstream.val_interval=50 cfg.downstream.skip_ratio=100
117+
118+
# 0.1%
119+
python train_downstream_semseg.py cfg=semantickitti_minkowski cfg.downstream.max_epochs=1000 cfg.downstream.val_interval=100 cfg.downstream.skip_ratio=1000
120+
```
121+
122+
### Object detection's pre-training
123+
124+
```python train.py --config_file cfgs/pretrain_ns_spconv.yaml --name voxelnet_bevcontrast_ns```
125+
126+
### Object detection's downstream
127+
128+
Please use the code of [OpenPCDet](https://github.com/open-mmlab/OpenPCDet) with default parameters for SECOND or PVRCNN and with no multiprocessing to retain compatibility with previous work and this one.
129+
130+
## Acknowledgment
131+
132+
Part of the codebase has been adapted from [OpenPCDet](https://github.com/open-mmlab/OpenPCDet), [ALSO](https://github.com/valeoai/ALSO), and [SLidR](https://github.com/valeoai/SLidR).
133+
134+
## License
135+
BEVContrast is released under the [Apache 2.0 license](./LICENSE).
136+

assets/method.png

109 KB
Loading

bevlab/__init__.py

Whitespace-only changes.

bevlab/backbones/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .spconv_backbone import BEVNet
2+
from .minkunet import MinkUNet34
3+
from .minkunet_segcontrast import SegContrastMinkUNet18
4+
5+
__all__ = ["BEVNet", "MinkUNet34", "SegContrastMinkUNet18"]

0 commit comments

Comments
 (0)