facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.54k stars 1.28k forks source link

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

Open IAM-P-LP opened 8 months ago

IAM-P-LP commented 8 months ago

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

bottler commented 8 months ago

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.

IAM-P-LP commented 8 months ago

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.