io
File reading and writing for point cloud data: JSON, OFF meshes, PLY, and safetensors.
Functions:
-
load_jsonβRead a JSON file.
-
load_offβRead an OFF mesh, triangulating its quadrilateral faces.
-
load_plyβRead a PLY file into one structured array per element.
-
save_plyβWrite structured arrays as the elements of a PLY file.
-
save_safetensorsβWrite a mapping to a safetensors file, storing its string entries as metadata.
-
load_safetensorsβRead a safetensors file, merging its metadata back into the tensor mapping.
load_json [source] ΒΆ
Read a JSON file.
Parameters:
-
file_path(PathLike) βPath to the JSON file.
Returns:
-
Dict[str, Any]βThe decoded JSON object.
load_off [source] ΒΆ
Read an OFF mesh, triangulating its quadrilateral faces.
Parameters:
-
file_path(PathLike) βPath to the OFF file.
Returns:
-
Tuple[ndarray, ndarray]βThe vertices \((V, 3)\) and the triangle indices \((F, 3)\).
load_ply [source] ΒΆ
Read a PLY file into one structured array per element.
Reads the ASCII and both binary encodings. A scalar property is a field of its element's array. A list property whose length is the same on every row is a field of shape \((k,)\); one whose length varies is an object field holding one array per row.
Parameters:
-
file_path(PathLike) βPath to the PLY file.
Returns:
-
Dict[str, ndarray]βThe elements keyed by name, in file order, each a structured array with one field per property.
save_ply [source] ΒΆ
Write structured arrays as the elements of a PLY file.
A scalar field becomes a scalar property and a field with a sub-array shape \((k,)\) a list uchar property of \(k\) items. The binary encoding is little endian.
Parameters:
-
file_path(PathLike) βPath to the PLY file to write.
-
elements(Mapping[str, ndarray]) βThe elements keyed by name, written in that order, each a structured array.
-
text(bool, default:False) βWrite the ASCII encoding instead of the binary one.
save_safetensors [source] ΒΆ
Write a mapping to a safetensors file, storing its string entries as metadata.
Parameters:
-
file_path(PathLike) βPath to the safetensors file to write.
-
data(Mapping[str, Any]) βMapping of names to tensors, scalars (wrapped in a tensor) or strings.