Skip to content

Commit 1d0d26d

Browse files
committed
chore: refactor codes but it didn't compatible with previous pretrained weight
because of the model path is changed.
1 parent 498d877 commit 1d0d26d

40 files changed

Lines changed: 192 additions & 578 deletions

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ We directly follow our previous work [code structure](https://github.com/KTH-RPL
2020
- `dataprocess/extract_*.py` : pre-process data before training to speed up the whole training time.
2121
[Dataset we included now: Argoverse 2 and Waymo. more on the way: Nuscenes, custom data.]
2222

23-
- `0_process.py`: process data with save dufomap, cluster labels inside file. Only needed for training.
23+
- `process.py`: process data with save dufomap, cluster labels inside file. Only needed once for training.
2424

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

27-
- `2_eval.py` : Evaluate the model on the validation/test set. And also upload to online leaderboard.
27+
- `eval.py` : Evaluate the model on the validation/test set. And also upload to online leaderboard.
2828

29-
- `3_vis.py` : For visualization of the results with a video.
29+
- `save.py` : For visualization of the results with a video.
3030

3131
<details> <summary>🎁 <b>One repository, All methods!</b> </summary>
3232
<!-- <br> -->
@@ -101,15 +101,15 @@ python dataprocess/extract_av2.py --av2_type sensor --data_mode test --mask_dir
101101
Process train data for self-supervised learning. Only training data needs this step. [Runtime: Normally need 15 hours for my desktop, 3 hours for the cluster with five available nodes parallel running.]
102102

103103
```bash
104-
python 0_process.py --data_dir /home/kin/data/av2/preprocess_v2/sensor/train --scene_range 0,701
104+
python process.py --data_dir /home/kin/data/av2/preprocess_v2/sensor/train --scene_range 0,701
105105
```
106106

107107
### Train the model
108108

109109
Train SeFlow needed to specify the loss function, we set the config of our best model in the leaderboard. [Runtime: Around 11 hours in 4x A100 GPUs.]
110110

111111
```bash
112-
python 1_train.py model=deflow lr=2e-4 epochs=9 batch_size=16 loss_fn=seflowLoss "add_seloss={chamfer_dis: 1.0, static_flow_loss: 1.0, dynamic_chamfer_dis: 1.0, cluster_based_pc0pc1: 1.0}" "model.target.num_iters=2" "model.val_monitor=val/Dynamic/Mean"
112+
python train.py model=deflow lr=2e-4 epochs=9 batch_size=16 loss_fn=seflowLoss "add_seloss={chamfer_dis: 1.0, static_flow_loss: 1.0, dynamic_chamfer_dis: 1.0, cluster_based_pc0pc1: 1.0}" "model.target.num_iters=2" "model.val_monitor=val/Dynamic/Mean"
113113
```
114114

115115
Or you can directly download the pre-trained weight from [Zenodo](https://zenodo.org/records/12751363/files/seflow_best.ckpt) and skip the training step.
@@ -118,8 +118,8 @@ Or you can directly download the pre-trained weight from [Zenodo](https://zenodo
118118

119119
You can also train the supervised baseline model in our paper with the following command. [Runtime: Around 10 hours in 4x A100 GPUs.]
120120
```bash
121-
python 1_train.py model=fastflow3d lr=2e-4 epochs=20 batch_size=16 loss_fn=ff3dLoss
122-
python 1_train.py model=deflow lr=2e-4 epochs=20 batch_size=16 loss_fn=deflowLoss
121+
python train.py model=fastflow3d lr=2e-4 epochs=20 batch_size=16 loss_fn=ff3dLoss
122+
python train.py model=deflow lr=2e-4 epochs=20 batch_size=16 loss_fn=deflowLoss
123123
```
124124

125125
> [!NOTE]
@@ -138,11 +138,11 @@ Since in training, we save all hyper-parameters and model checkpoints, the only
138138
wget https://zenodo.org/records/12751363/files/seflow_best.ckpt
139139

140140
# it will directly prints all metric
141-
python 2_eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=val
141+
python eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=val
142142

143143
# it will output the av2_submit.zip or av2_submit_v2.zip for you to submit to leaderboard
144-
python 2_eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=test leaderboard_version=1
145-
python 2_eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=test leaderboard_version=2
144+
python eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=test leaderboard_version=1
145+
python eval.py checkpoint=/home/kin/seflow_best.ckpt av2_mode=test leaderboard_version=2
146146
```
147147

148148
And the terminal will output the command for you to submit the result to the online leaderboard. You can follow [this section for evalai](https://github.com/KTH-RPL/DeFlow?tab=readme-ov-file#2-evaluation).
@@ -154,7 +154,7 @@ Check all detailed result files (presented in our paper Table 1) in [this discus
154154
We provide a script to visualize the results of the model also. You can specify the checkpoint path and the data path to visualize the results. The step is quickly similar to evaluation.
155155

156156
```bash
157-
python 3_vis.py checkpoint=/home/kin/seflow_best.ckpt dataset_path=/home/kin/data/av2/preprocess_v2/sensor/vis
157+
python save.py checkpoint=/home/kin/seflow_best.ckpt dataset_path=/home/kin/data/av2/preprocess_v2/sensor/vis
158158

159159
# The output of above command will be like:
160160
Model: DeFlow, Checkpoint from: /home/kin/model_zoo/v2/seflow_best.ckpt

assets/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ If you want to contribute to new model, here are tips you can follow:
8080
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.
8181
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.
8282
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.
83-
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`.
83+
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`.
8484

8585
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,13 +25,13 @@ echo "Copy ${SOURCE} to ${DEST} Total time: ${elapsed} seconds"
2525
echo "Start training..."
2626

2727
# ====> paper model = seflow_official
28-
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python 1_train.py \
28+
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/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=20 "model.target.num_iters=2" "model.val_monitor=val/Dynamic/Mean" \
3131
# loss_fn=seflowLoss "add_seloss={chamfer_dis: 1.0, static_flow_loss: 1.0, dynamic_chamfer_dis: 1.0, cluster_based_pc0pc1: 1.0}"
3232

3333
# ====> leaderboard model = seflow_best
34-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python 1_train.py \
34+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python train.py \
3535
slurm_id=$SLURM_JOB_ID wandb_mode=online train_data=/scratch/local/av2/sensor/train val_data=/scratch/local/av2/sensor/val \
3636
num_workers=16 model=deflow lr=2e-4 epochs=9 batch_size=16 "model.target.num_iters=2" "model.val_monitor=val/Dynamic/Mean" \
3737
loss_fn=seflowLoss "add_seloss={chamfer_dis: 1.0, static_flow_loss: 1.0, dynamic_chamfer_dis: 1.0, cluster_based_pc0pc1: 1.0}"

assets/slurm/2_eval.sh

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

2525
# ====> leaderboard model
26-
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python 2_eval.py \
26+
# /proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python eval.py \
2727
# wandb_mode=online dataset_path=/scratch/local/av2/sensor \
2828
# checkpoint=/proj/berzelius-2023-154/users/x_qinzh/seflow/logs/wandb/seflow-10086990/checkpoints/epoch_19_seflow.ckpt \
2929
# av2_mode=test save_res=True
3030

31-
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python 2_eval.py \
31+
/proj/berzelius-2023-154/users/x_qinzh/mambaforge/envs/seflow/bin/python eval.py \
3232
wandb_mode=online dataset_path=/scratch/local/av2/sensor av2_mode=val \
3333
checkpoint=/proj/berzelius-2023-154/users/x_qinzh/seflow/logs/wandb/seflow-10086990/checkpoints/epoch_19_seflow.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.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.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)