pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

IndexError: index -1 is out of bounds for axis 0 with size 0

Open IAM-P-LP opened this issue 2 years ago • 2 comments

I was trying to load a .obj file using load_obj() function of pytorch3d.I am getting the below error.Can you please advice on how to solve this?

Traceback (most recent call last): File "/home/synthetic_data_generator/main.py", line 119, in main() File "/home/synthetic_data_generator/main.py", line 115, in main dataset.get_images() File "/home/synthetic_data_generator/main.py", line 40, in get_images image = self.renger_obj.get_image(elev_angle, azim_angle) File "/home/synthetic_data_generator/render.py", line 218, in get_image mesh = self.get_mesh() File "/home/synthetic_data_generator/render.py", line 133, in get_mesh verts, faces, aux = load_obj( File "/home/miniconda3/envs/poseapp/lib/python3.9/site-packages/pytorch3d/io/obj_io.py", line 224, in load_obj return _load_obj( File "/home/miniconda3/envs/poseapp/lib/python3.9/site-packages/pytorch3d/io/obj_io.py", line 650, in _load_obj face_material_names = np.array(material_names)[idx] # (F,) IndexError: index -1 is out of bounds for axis 0 with size 0

IAM-P-LP avatar Nov 06 '23 05:11 IAM-P-LP

Could it be that our function load_obj is being called with create_texture_atlas=True on an obj file with no texture data? What do you get if you call it with create_texture_atlas=False on the same file?

Do you need texture data out of this file? And do you know if there is texture data in the file? Feel free to share the data.

bottler avatar Nov 06 '23 13:11 bottler

Hi, when I use create_texture_atlas=False, it throws this error File "/home/miniconda3/envs/poseapp/lib/python3.9/site-packages/pytorch3d/renderer/mesh/textures.py", line 379, in init raise ValueError(msg) ValueError: Expected atlas to be a list of tensors of shape (F, R, R, C) with the same value of R. I have attached the files.Please feel free to go through. https://drive.google.com/drive/folders/1y_12gEvObi2riuaDgE0i2nh3hHkX3Tus?usp=sharing

Regarding texture data , I obtained texture image file and material file as well along with the .obj.But that wasn't mentioned in the obj file.So I added mtllib elbow_connector_tex.mtl in the .obj file. Also, usemtl isnt explicitly mentioned in the .obj file .So its throwing that error. material_names is an empty list.

IAM-P-LP avatar Nov 07 '23 04:11 IAM-P-LP