-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathmesh.py
More file actions
31 lines (23 loc) · 772 Bytes
/
Copy pathmesh.py
File metadata and controls
31 lines (23 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Mesh: encode a trimesh object, stream a Trimesh.
Needs trimesh. Path and raw bytes are stored as-is; mesh= encodes.
"""
import trimesh
from litdata import Mesh, StreamingDataset, optimize
def make_sample(index: int) -> dict:
mesh = trimesh.creation.box(extents=(1.0, 1.0, 1.0))
return {
"index": index,
# Mesh(path="m.glb")
"mesh": Mesh(mesh=mesh, file_type="glb"),
}
if __name__ == "__main__":
optimize(
fn=make_sample,
inputs=list(range(4)),
output_dir="example_optimize_dataset/mesh",
num_workers=2,
chunk_bytes="64MB",
)
sample = StreamingDataset("example_optimize_dataset/mesh")[0]
mesh = sample["mesh"] # Trimesh
print(mesh.vertices.shape, mesh.faces.shape)