mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 11:52:50 +08:00
path_manager in obj_io
Summary: Use PathManager for checking file existence, rather than assuming the path is a local file, in a couple of cases. Reviewed By: patricklabatut Differential Revision: D29734621 fbshipit-source-id: e2236a7c2c50ba6916936a4d786abd601205b519
This commit is contained in:
parent
9e8d91ebf9
commit
1872e0249c
@ -398,7 +398,7 @@ TextureImages = Dict[str, torch.Tensor]
|
||||
|
||||
|
||||
def _parse_mtl(
|
||||
f, path_manager: PathManager, device: Device = "cpu"
|
||||
f: str, path_manager: PathManager, device: Device = "cpu"
|
||||
) -> Tuple[MaterialProperties, TextureFiles]:
|
||||
material_properties = {}
|
||||
texture_files = {}
|
||||
@ -456,7 +456,7 @@ def _load_texture_images(
|
||||
if material_name in texture_files:
|
||||
# Load the texture image.
|
||||
path = os.path.join(data_dir, texture_files[material_name])
|
||||
if os.path.isfile(path):
|
||||
if path_manager.exists(path):
|
||||
image = (
|
||||
_read_image(path, path_manager=path_manager, format="RGB") / 255.0
|
||||
)
|
||||
@ -475,7 +475,7 @@ def _load_texture_images(
|
||||
|
||||
|
||||
def load_mtl(
|
||||
f,
|
||||
f: str,
|
||||
*,
|
||||
material_names: List[str],
|
||||
data_dir: str,
|
||||
@ -487,7 +487,7 @@ def load_mtl(
|
||||
and specular light (Ka, Kd, Ks, Ns).
|
||||
|
||||
Args:
|
||||
f: a file-like object of the material information.
|
||||
f: path to the material information.
|
||||
material_names: a list of the material names found in the .obj file.
|
||||
data_dir: the directory where the material texture files are located.
|
||||
device: Device (as str or torch.tensor) on which to return the new tensors.
|
||||
|
@ -499,7 +499,7 @@ def _parse_obj(f, data_dir: str):
|
||||
|
||||
def _load_materials(
|
||||
material_names: List[str],
|
||||
f,
|
||||
f: Optional[str],
|
||||
*,
|
||||
data_dir: str,
|
||||
load_textures: bool,
|
||||
@ -511,7 +511,7 @@ def _load_materials(
|
||||
|
||||
Args:
|
||||
material_names: a list of the material names found in the .obj file.
|
||||
f: a file-like object of the material information.
|
||||
f: path to the material information.
|
||||
data_dir: the directory where the material texture files are located.
|
||||
load_textures: whether textures should be loaded.
|
||||
device: Device (as str or torch.device) on which to return the new tensors.
|
||||
@ -529,7 +529,7 @@ def _load_materials(
|
||||
warnings.warn("No mtl file provided")
|
||||
return None, None
|
||||
|
||||
if not os.path.isfile(f):
|
||||
if not path_manager.exists(f):
|
||||
warnings.warn(f"Mtl file does not exist: {f}")
|
||||
return None, None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user