Skip to content

Commit a8f12e7

Browse files
authored
[Add]add paddle version code of IJACA 2024 (#959)
* [Add]add paddle version code of IJACA 2024 * update README.txt * update command of README.txt and some hints
1 parent 260bc0f commit a8f12e7

Some content is hidden

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

66 files changed

+12672
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# IJACA_Code
2+
The paddle version of the top three in each track of the IJACA 2024 competition.
3+
4+
Inference codes only now.
5+
6+
## Dataset
7+
Please refer to the .ipynb files in each directory to download the data and set the corresponding parameters.
8+
9+
## Checkpoint
10+
Donwload checkpoints:
11+
``` sh
12+
cd PaddleScience/jointContribution/IJACA_2024
13+
# linux
14+
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJACA_2024_ckpts.tar.gz
15+
# windows
16+
# curl https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJACA_2024_ckpts.tar.gz
17+
```
18+
19+
Unzip the checkpoints and move them to the corresponding directory:
20+
``` sh
21+
tar -xvzf IJACA_2024_ckpts.tar.gz
22+
23+
# aminos
24+
mkdir -p ./aminos/Logger/states/
25+
mv ./ckpts/aminos/90.pdparams ./aminos/Logger/states/90.pdparams
26+
27+
# tenfeng
28+
mkdir -p ./results/
29+
mv ./ckpts/tenfeng/checkpoint.pdparams ./tenfeng/results/checkpoint.pdparams
30+
31+
# leejt
32+
mv ./ckpts/leejt/model.pdparams ./leejt/model.pdparams
33+
34+
# bju
35+
mv ./ckpts/bju/geom/ckpt ./bju/geom/
36+
mv ./ckpts/bju/pretrained_checkpoint.pdparams ./bju/pretrained_checkpoint.pdparams
37+
38+
# zhongzaicanyu
39+
# No pretrained checkpoint yet.
40+
```
41+
42+
## Inference
43+
First enter the corresponding directory. For example "aminos":
44+
``` sh
45+
cd aminos
46+
```
47+
48+
Install requirements:
49+
``` sh
50+
pip install -r requirements.txt
51+
```
52+
53+
Run Inference:
54+
``` py
55+
### aminos
56+
python infer.py --dataset_dir "./Datasets" --load_index="90"
57+
58+
### tenfeng
59+
python infer.py --epochs 69 --milestones 40 50 60 65 68 --gpu_id 0 --depth 5 --hidden_dim 256 --num_slices 32 --batch_size 4 --loss_type 'rl2' --submit --log_dir "./results" --training_data_dir "./Dataset/train_track_B_e" --testing_data_dir "./Dataset/Testset_track_B_e"
60+
61+
### leejt
62+
python infer.py
63+
64+
### bju
65+
python infer.py --train_data_dir "./Dataset/Trainset_track_B" --test_data_dir "./Dataset/Testset_track_B/Inference" --info_dir "./Dataset/Testset_track_B/Auxiliary" --ulip_ckpt "./geom/ckpt/checkpoint_pointbert.pdparams"
66+
67+
### zhongzaicanyu
68+
python infer.py # not work yet.
69+
```

jointContribution/IJACA_2024/aminos/Extract_mesh/__init__.py

Whitespace-only changes.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import argparse
2+
import os
3+
4+
import h5py
5+
import numpy as np
6+
import paddle
7+
8+
9+
def load_ds_trackA_info(file_path, key_list):
10+
path_trackA_ds = file_path
11+
key_list = np.sort([int(key) for key in key_list])
12+
key_list = [str(key) for key in key_list]
13+
bounds = np.loadtxt(path_trackA_ds + "/watertight_global_bounds.txt")
14+
pressure_mean_std = paddle.to_tensor(
15+
data=np.loadtxt(path_trackA_ds + "/train_pressure_min_std.txt")
16+
).to("float32")
17+
voxel_mean_std = paddle.to_tensor(
18+
data=np.loadtxt(path_trackA_ds + "/voxel_mean_std.txt")
19+
).to("float32")
20+
pos_mean_std = np.loadtxt(path_trackA_ds + "/pos_mean_std.txt")
21+
normal_mean_std = np.loadtxt(path_trackA_ds + "/normal_mean_std.txt")
22+
PN_mean_std = paddle.to_tensor(
23+
data=np.concatenate([pos_mean_std, normal_mean_std], axis=-1)
24+
).to("float32")
25+
physics_info = {
26+
"key_list": key_list,
27+
"bounds": bounds,
28+
"voxel_mean_std": voxel_mean_std,
29+
"pressure_mean_std": pressure_mean_std,
30+
"PN_mean_std": PN_mean_std,
31+
}
32+
return physics_info
33+
34+
35+
def load_ds_trackB_info(file_path, key_list):
36+
path_trackB_ds = file_path
37+
key_list = np.sort([int(key) for key in key_list])
38+
key_list = [str(key) for key in key_list]
39+
pressure_mean_std = paddle.to_tensor(
40+
data=np.loadtxt(path_trackB_ds + "/train_pressure_mean_std.txt")
41+
).to("float32")
42+
bounds = np.loadtxt(path_trackB_ds + "/global_bounds.txt")
43+
voxel_mean_std = paddle.to_tensor(
44+
data=np.loadtxt(path_trackB_ds + "/voxel_mean_std.txt")
45+
).to("float32")
46+
PNA_mean_std = paddle.to_tensor(
47+
data=np.loadtxt(path_trackB_ds + "/PosNormalArea_mean_std.txt")
48+
).to("float32")
49+
PN_mean_std = PNA_mean_std[:, :6]
50+
physics_info = {
51+
"key_list": key_list,
52+
"bounds": bounds,
53+
"voxel_mean_std": voxel_mean_std,
54+
"pressure_mean_std": pressure_mean_std,
55+
"PN_mean_std": PN_mean_std,
56+
}
57+
return physics_info
58+
59+
60+
def load_extra_info(file_path, key_list, track_type="A"):
61+
if track_type == "A":
62+
physics_info = load_ds_trackA_info(file_path, key_list)
63+
else:
64+
physics_info = load_ds_trackB_info(file_path, key_list)
65+
return physics_info
66+
67+
68+
def add_physics_info_to_group(group, physics_info):
69+
for key, value in physics_info.items():
70+
group.create_dataset(key, data=value)
71+
72+
73+
def merge_h5_files(fileA_path, fileB_path, merged_file_path):
74+
with h5py.File(fileA_path, "r") as fileA, h5py.File(
75+
fileB_path, "r"
76+
) as fileB, h5py.File(merged_file_path, "w") as merged_file:
77+
key_list_A = list(fileA.keys())
78+
key_list_B = list(fileB.keys())
79+
physics_info_A = load_extra_info(
80+
os.path.dirname(fileA_path), key_list_A, track_type="A"
81+
)
82+
physics_info_B = load_extra_info(
83+
os.path.dirname(fileB_path), key_list_B, track_type="B"
84+
)
85+
for key in fileA.keys():
86+
group = fileA[key]
87+
new_key = "A_" + key
88+
merged_file.copy(group, new_key)
89+
add_physics_info_to_group(merged_file[new_key], physics_info_A)
90+
for key in fileB.keys():
91+
group = fileB[key]
92+
new_key = "B_" + key
93+
merged_file.copy(group, new_key)
94+
add_physics_info_to_group(merged_file[new_key], physics_info_B)
95+
96+
97+
if __name__ == "__main__":
98+
parser = argparse.ArgumentParser(
99+
description="train / test a paddle model to predict frames"
100+
)
101+
parser.add_argument(
102+
"--A_dir",
103+
default="/home/xiaoli/project/3D-ShapeNet-car/src/Dataset/converted_dataset/trackA/test.h5",
104+
type=str,
105+
help="",
106+
)
107+
parser.add_argument(
108+
"--B_dir",
109+
default="/home/xiaoli/project/3D-ShapeNet-car/src/Dataset/converted_dataset/trackB/test.h5",
110+
type=str,
111+
help="",
112+
)
113+
parser.add_argument(
114+
"--C_dir",
115+
default="/home/xiaoli/project/3D-ShapeNet-car/src/Dataset/converted_dataset/trackC/k1.h5",
116+
type=str,
117+
help="",
118+
)
119+
params = parser.parse_args()
120+
merge_h5_files(params.A_dir, params.B_dir, params.C_dir)
121+
print("done")

0 commit comments

Comments
 (0)