kbrodt commited on
Commit
38e46a7
1 Parent(s): 5bd9834

Upload utils.py

Browse files
Files changed (1) hide show
  1. src/utils.py +33 -0
src/utils.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import pickle
3
+
4
+ import trimesh
5
+
6
+
7
+ def load_json(path):
8
+ with open(path) as f:
9
+ return json.load(f)
10
+
11
+
12
+ def save_json(o, path):
13
+ with open(path, "w") as f:
14
+ json.dump(o, f)
15
+
16
+
17
+ def load_pkl(path):
18
+ with open(path, "rb") as f:
19
+ return pickle.load(f)
20
+
21
+
22
+ def save_pkl(o, path):
23
+ with open(path, "wb") as f:
24
+ pickle.dump(o, f)
25
+
26
+
27
+ def save_mesh_with_colors(vertices, faces, save_path):
28
+ mesh = trimesh.Trimesh(
29
+ vertices=vertices,
30
+ faces=faces,
31
+ process=False,
32
+ )
33
+ mesh.export(save_path)