From 9acdd67b831f2d3d9db249b1c46d42139024cebf Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Fri, 13 Sep 2024 02:00:49 -0700 Subject: [PATCH] fix obj material indexing bug #1368 Summary: Make the negative index actually not an error fixes https://github.com/facebookresearch/pytorch3d/issues/1368 Reviewed By: das-intensity Differential Revision: D62177991 fbshipit-source-id: e5ed433bde1f54251c4d4b6db073c029cbe87343 --- pytorch3d/io/obj_io.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index 32083a5f..3cc29794 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -649,8 +649,7 @@ def _load_obj( # Create an array of strings of material names for each face. # If faces_materials_idx == -1 then that face doesn't have a material. idx = faces_materials_idx.cpu().numpy() - face_material_names = np.array(material_names)[idx] # (F,) - face_material_names[idx == -1] = "" + face_material_names = np.array([""] + material_names)[idx + 1] # (F,) # Construct the atlas. texture_atlas = make_mesh_texture_atlas(