PLY point-cloud I/O rejects pathlib.Path, unlike kornia.io (save/load_pointcloud_ply*, TypeError)
save_pointcloud_ply, save_pointcloud_ply_binary, load_pointcloud_ply and load_pointcloud_ply_binary raise TypeError for a pathlib.Path that names a valid .ply file. Their filename check is isinstance(filename, str) and filename.lower().endswith(".ply") (kornia/geometry/pointcloud.py:46, :96, :267). By contrast, kornia.io.load_image and kornia.io.write_image take path_file: str | Path, so a Path that works with kornia's image I/O fails with its point-cloud I/O.
Reproduction
import pathlib, tempfile
import torch
from kornia.geometry import load_pointcloud_ply, save_pointcloud_ply
d = pathlib.Path(tempfile.mkdtemp())
pts = torch.tensor([[1.0, 2.0, 3.0]])
save_pointcloud_ply(str(d / "a.ply"), pts) # works
load_pointcloud_ply(str(d / "a.ply")) # tensor([[1., 2., 3.]])
save_pointcloud_ply(d / "b.ply", pts) # TypeError: Input filename must be a string with the .ply extension. Got PosixPath(...)
load_pointcloud_ply(d / "a.ply") # TypeError, same messageObserved on main c27b2dac6 (kornia 0.9.0rc1, torch 2.14.0, macOS arm64). The check does not depend on torch.
Suggested fix
Accept str | os.PathLike in all four functions. Convert with os.fspath(filename) before the .ply suffix check, and keep the TypeError for other types and suffixes. The .ply check itself is kornia's deliberate validation and stays.
#5069 (convention batch 10b) currently pins the Path rejection in test_convention_ply_filename_is_str_ending_in_ply_any_case. That half of the pin will be recast as a test_wart_* that links here, so the fix can flip it.
Posted on behalf of @ducha-aiki by Claude (Opus 5.5).
Source: kornia/kornia