Skip to content

Commit d9475f7

Browse files
committed
chore: refactor structure and updates latest best model for all.
Merge branch 'SeFlow' into DeFlow
2 parents 9222ffe + 3bf1121 commit d9475f7

44 files changed

Lines changed: 401 additions & 979 deletions

Some content is hidden

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

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Check usage in [2. Evaluation](#2-evaluation) or [3. Visualization](#3-visualiza
2121
- `dataprocess/extract_*.py` : pre-process data before training to speed up the whole training time.
2222
[Dataset we included now: Argoverse 2 and Waymo, more on the way: Nuscenes, custom data.]
2323

24-
- `1_train.py`: Train the model and get model checkpoints. Pls remember to check the config.
24+
- `train.py`: Train the model and get model checkpoints. Pls remember to check the config.
2525

26-
- `2_eval.py` : Evaluate the model on the validation/test set. And also upload to online leaderboard.
26+
- `eval.py` : Evaluate the model on the validation/test set. And also output the zip file to upload to online leaderboard.
2727

28-
- `3_vis.py` : For visualization of the results with a video.
28+
- `save.py` : Will save result into h5py file, using [tool/visualization.py] to show results with interactive window.
2929

3030

3131
<details> <summary>🎁 <b>One repository, All methods!</b> </summary>
@@ -105,8 +105,8 @@ All local benchmarking methods and ablation studies can be done through command
105105
Best fine-tuned model train with following command by other default config in [conf/config.yaml](conf/config.yaml) and [conf/model/deflow.yaml](conf/model/deflow.yaml), if you will set wandb_mode=online, maybe change all `entity="kth-rpl"` to your own account name.
106106

107107
```bash
108-
python 1_train.py model=deflow lr=2e-4 epochs=20 batch_size=16 loss_fn=deflowLoss
109-
python 1_train.py model=fastflow3d lr=2e-4 epochs=20 batch_size=16 loss_fn=ff3dLoss
108+
python train.py model=deflow lr=2e-4 epochs=20 batch_size=16 loss_fn=deflowLoss
109+
python train.py model=fastflow3d lr=4e-5 epochs=20 batch_size=16 loss_fn=ff3dLoss
110110
```
111111

112112
> [!NOTE]
@@ -126,10 +126,10 @@ Since in training, we save all hyper-parameters and model checkpoints, the only
126126
# downloaded pre-trained weight, or train by yourself
127127
wget https://zenodo.org/records/12751363/files/deflow_best.ckpt
128128

129-
python 2_eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=val # it will directly prints all metric
129+
python eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=val # it will directly prints all metric
130130
# it will output a command with absolute path of a zip file for you to submit to leaderboard
131-
python 2_eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=test leaderboard_version=1
132-
python 2_eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=test leaderboard_version=2
131+
python eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=test leaderboard_version=1
132+
python eval.py checkpoint=/home/kin/deflow_best.ckpt av2_mode=test leaderboard_version=2
133133
```
134134

135135
Check all detailed result files (presented in our paper Table 1) in [this discussion](https://github.com/KTH-RPL/DeFlow/discussions/2).
@@ -159,16 +159,16 @@ We provide a script to visualize the results of the model. You can specify the c
159159
# downloaded pre-trained weight, or train by yourself
160160
wget https://zenodo.org/records/12751363/files/deflow_best.ckpt
161161

162-
python 3_vis.py checkpoint=/home/kin/deflow_best.ckpt dataset_path=/home/kin/data/av2/preprocess/sensor/vis
162+
python save.py checkpoint=/home/kin/deflow_best.ckpt dataset_path=/home/kin/data/av2/preprocess/sensor/vis
163163

164164
# Then terminal will tell you the command you need run. For example here is the output of the above:
165165
Model: DeFlow, Checkpoint from: /home/kin/deflow_best.ckpt
166166
We already write the estimate flow: deflow_best into the dataset, please run following commend to visualize the flow. Copy and paste it to your terminal:
167-
python tools/scene_flow.py --flow_mode 'deflow_best' --data_dir /home/kin/data/av2/preprocess/sensor/mini
167+
python tools/visualization.py --flow_mode 'deflow_best' --data_dir /home/kin/data/av2/preprocess/sensor/mini
168168
Enjoy! ^v^ ------
169169

170170
# Then run the command in the terminal:
171-
python tools/scene_flow.py --flow_mode 'deflow_best' --data_dir /home/kin/data/av2/preprocess/sensor/mini
171+
python tools/visualization.py --res_name 'deflow_best' --data_dir /home/kin/data/av2/preprocess_v2/sensor/mini
172172
```
173173

174174
https://github.com/KTH-RPL/DeFlow/assets/35365764/9b265d56-06a9-4300-899c-96047a0da505

assets/README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,16 @@ cd DeFlow && git submodule update --init --recursive
7676
mamba env create -f assets/environment.yml
7777
```
7878

79-
Install mmcv lite version from us: [~5 mins] needed CUDA inside the env, echo ${PATH}
80-
79+
CUDA package (nvcc compiler already installed through conda), the compile time is around 1-5 minutes:
8180
```bash
82-
# change it if you use different cuda version (I tested 11.3, 11.4, 11.7, 11.8 all works)
83-
export PATH=/usr/local/cuda-11.7/bin:$PATH
84-
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH
85-
81+
mamba activate seflow
8682
cd assets/cuda/mmcv && python ./setup.py install && cd ../../..
8783
```
8884

8985

9086
Checking the environment:
9187
```bash
92-
mamba activate deflow
88+
mamba activate seflow
9389
python -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(torch.version.cuda)"
9490
python -c "import lightning.pytorch as pl"
9591
python -c "from assets.cuda.mmcv import Voxelization, DynamicScatter;print('success test on mmcv package')"
@@ -115,8 +111,8 @@ python -c "from assets.cuda.mmcv import Voxelization, DynamicScatter;print('succ
115111

116112
If you want to contribute to new model, here are tips you can follow:
117113
1. Dataloader: we believe all data could be process to `.h5`, we named as different scene and inside a scene, the key of each data is timestamp. Check [dataprocess/README.md](../dataprocess/README.md#process) for more details.
118-
2. Model: All model files can be found [here: scripts/network/models](../scripts/network/models). You can view deflow and fastflow3d to know how to implement a new model.
119-
3. Loss: All loss files can be found [here: scripts/network/loss_func.py](../scripts/network/loss_func.py). There are three loss functions already inside the file, you can add a new one following the same pattern.
120-
4. Training: Once you have implemented the model, you can add the model to the config file [here: conf/model](../conf/model) and train the model using the command `python 1_train.py model=your_model_name`. One more note here may: if your res_dict from model output is different, you may need add one pattern in `def training_step` and `def validation_step`.
114+
2. Model: All model files can be found [here: src/models](../src/models). You can view deflow and fastflow3d to know how to implement a new model. Don't forget to add to the `__init__.py` [file to import class](../src/models/__init__.py).
115+
3. Loss: All loss files can be found [here: src/lossfuncs.py](../src/lossfuncs.py). There are three loss functions already inside the file, you can add a new one following the same pattern.
116+
4. Training: Once you have implemented the model, you can add the model to the config file [here: conf/model](../conf/model) and train the model using the command `python train.py model=your_model_name`. One more note here may: if your res_dict from model output is different, you may need add one pattern in `def training_step` and `def validation_step`.
121117

122118
All others like eval and vis will be changed according to the model you implemented as you follow the above steps.

assets/slurm/1_train.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ echo "Copy ${SOURCE} to ${DEST} Total time: ${elapsed} seconds"
2525
echo "Start training..."
2626

2727
# ====> leaderboard model = [fastflow3d, deflow]
28-
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python 1_train.py \
28+
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python train.py \
2929
# slurm_id=$SLURM_JOB_ID wandb_mode=online train_data=/scratch/local/av2/sensor/train val_data=/scratch/local/av2/sensor/val \
3030
# num_workers=16 model=deflow lr=2e-6 epochs=50 batch_size=10 loss_fn=deflowLoss
3131

32-
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python 1_train.py \
32+
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python train.py \
3333
# slurm_id=$SLURM_JOB_ID wandb_mode=online train_data=/scratch/local/av2/sensor/train val_data=/scratch/local/av2/sensor/val \
3434
# num_workers=16 model=fastflow3d lr=2e-6 epochs=50 batch_size=16 loss_fn=ff3dLoss
3535

assets/slurm/2_eval.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ echo "Start training..."
3030
# av2_mode=test save_res=True
3131

3232

33-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python 2_eval.py \
33+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python eval.py \
3434
wandb_mode=online dataset_path=/scratch/local/av2/sensor av2_mode=val \
3535
checkpoint=/proj/berzelius-2023-154/users/x_qinzh/deflow/logs/wandb/fastflow3d-10086990/checkpoints/epoch_49_fastflow3d.ckpt
3636

37-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python 2_eval.py \
37+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python eval.py \
3838
wandb_mode=online dataset_path=/scratch/local/av2/sensor av2_mode=val \
3939
checkpoint=/proj/berzelius-2023-154/users/x_qinzh/deflow/logs/wandb/fastflow3d-10088873/checkpoints/epoch_49_fastflow3d.ckpt
4040

41-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python 2_eval.py \
41+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/deflow/bin/python eval.py \
4242
wandb_mode=online dataset_path=/scratch/local/av2/sensor av2_mode=val \
4343
checkpoint=/proj/berzelius-2023-154/users/x_qinzh/deflow/logs/wandb/fastflow3d-10088874/checkpoints/epoch_49_fastflow3d.ckpt

assets/slurm/dufolabel_sbatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def main(
4040
cd /proj/berzelius-2023-154/users/x_qinzh/seflow
4141
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/proj/berzelius-2023-154/users/x_qinzh/mambaforge/lib
4242
43-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python 0_process.py \\
43+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python process.py \\
4444
--data_dir {data_dir} \\
4545
--interval {interval} \\
4646
--scene_range {scene_range[0]},{scene_range[1]}

assets/tests/chamferdis_speed_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def faiss_knn(pc1, pc2):
7272

7373
if PYTORCH3D_TEST:
7474
print("------ START Pytorch3d Chamfer Distance Cal ------")
75-
from scripts.network.models.unsfp.model import my_chamfer_fn
75+
from src.models.basic.nsfp_module import my_chamfer_fn
7676
start_time = time.time()
7777
loss0, _ = my_chamfer_fn(pc0.unsqueeze(0), pc1.unsqueeze(0), truncate_dist=False)
7878

assets/tests/hdbscan_speed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from sklearn.cluster import HDBSCAN
1919
import hdbscan as cpu_hdbscan
2020

21-
from scripts.utils.o3d_view import MyVisualizer, color_map
21+
from src.utils.o3d_view import MyVisualizer, color_map
2222
import open3d as o3d
2323

2424
MAX_AXIS_RANGE = 60

conf/model/deflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: deflow
22

33
target:
4-
_target_: scripts.network.models.deflow.DeFlow
4+
_target_: src.models.DeFlow
55
decoder_option: gru # choices: [linear, gru]
66
num_iters: 4
77
voxel_size: ${voxel_size}

conf/model/fastflow3d.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: fastflow3d
22

33
target:
4-
_target_: scripts.network.models.fastflow3d.FastFlow3D
5-
bottleneck_head: False
4+
_target_: src.models.FastFlow3D
65
voxel_size: ${voxel_size}
76
point_cloud_range: ${point_cloud_range}
87

conf/model/nsfp.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)