From caa83aa0404bba2a5d97218cc79358d0f633f059 Mon Sep 17 00:00:00 2001 From: Ashim Dahal Date: Sun, 6 Oct 2024 10:37:50 -0500 Subject: [PATCH 1/3] added texture mode on load_obj ShapeNetCore throws error texture UV coordinates are outside the range [0,1], this fixes it by clamping it with the clamp texture mode. --- pytorch3d/datasets/shapenet_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytorch3d/datasets/shapenet_base.py b/pytorch3d/datasets/shapenet_base.py index d90bea67..642dfe24 100644 --- a/pytorch3d/datasets/shapenet_base.py +++ b/pytorch3d/datasets/shapenet_base.py @@ -45,6 +45,7 @@ def __init__(self) -> None: self.model_dir = "model.obj" self.load_textures = True self.texture_resolution = 4 + self.texture_mode = "clamp" def __len__(self) -> int: """ @@ -90,6 +91,7 @@ def _load_mesh(self, model_path) -> Tuple: create_texture_atlas=self.load_textures, load_textures=self.load_textures, texture_atlas_size=self.texture_resolution, + texture_mode = self.texture_mode ) if self.load_textures: textures = aux.texture_atlas From d13de4db85a4675fbd7ae39c3357d0e4411b37cd Mon Sep 17 00:00:00 2001 From: Ashim Dahal Date: Sun, 6 Oct 2024 16:30:24 -0500 Subject: [PATCH 2/3] [fix] fixed the texture_mode to texture wrap --- pytorch3d/datasets/shapenet_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch3d/datasets/shapenet_base.py b/pytorch3d/datasets/shapenet_base.py index 642dfe24..54e41b92 100644 --- a/pytorch3d/datasets/shapenet_base.py +++ b/pytorch3d/datasets/shapenet_base.py @@ -45,7 +45,7 @@ def __init__(self) -> None: self.model_dir = "model.obj" self.load_textures = True self.texture_resolution = 4 - self.texture_mode = "clamp" + self.texture_wrap = "clamp" def __len__(self) -> int: """ @@ -91,7 +91,7 @@ def _load_mesh(self, model_path) -> Tuple: create_texture_atlas=self.load_textures, load_textures=self.load_textures, texture_atlas_size=self.texture_resolution, - texture_mode = self.texture_mode + texture_wrap = self.texture_wrap ) if self.load_textures: textures = aux.texture_atlas From e5c63f2de8cae2ca5dab61a99742b01c6e4167d4 Mon Sep 17 00:00:00 2001 From: Ashim Dahal Date: Sun, 6 Oct 2024 21:35:44 +0000 Subject: [PATCH 3/3] feat: changed the docstring to match texture_wrap --- pytorch3d/io/obj_io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index 3cc29794..49bf4387 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -148,9 +148,9 @@ def load_obj( map is created per face. texture_wrap: string, one of ["repeat", "clamp"]. This applies when computing the texture atlas. - If `texture_mode="repeat"`, for uv values outside the range [0, 1] the integer part + If `texture_wrap="repeat"`, for uv values outside the range [0, 1] the integer part is ignored and a repeating pattern is formed. - If `texture_mode="clamp"` the values are clamped to the range [0, 1]. + If `texture_wrap="clamp"` the values are clamped to the range [0, 1]. If None, then there is no transformation of the texture values. device: Device (as str or torch.device) on which to return the new tensors. path_manager: optionally a PathManager object to interpret paths.