Skip to content

Commit bd989ff

Browse files
committed
[Add]add paddle version code of IJACA 2024
1 parent be0802f commit bd989ff

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

+14368
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# IJACA_Code
2+
The paddle version of the top three in each track of the IJACA 2024 competition.
3+
Inference codes only now.
4+
5+
## Dataset(To be added)
6+
Please refer to the .ipynb files in each directory to download the data and set the corresponding parameters.
7+
8+
## Checkpoint(To be added)
9+
10+
## Inference commands
11+
### aminos
12+
python infer.py --dataset_dir /your_path/Datasets
13+
14+
### tenfeng
15+
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 your_path --training_data_dir /your_path/Dataset/train_track_B_e --testing_data_dir /your_path/Dataset/Testset_track_B_e
16+
17+
### leejt
18+
python infer.py
19+
20+
### bju
21+
python infer.py
22+
23+
### zhongzaicanyu
24+
python infer.py

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 pytorch 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)