NVlabs / PoseCNN-PyTorch

PyTorch implementation of the PoseCNN framework
Other
186 stars 47 forks source link

IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed #4

Closed dandmetal closed 3 years ago

dandmetal commented 3 years ago

Hi, When i execute the demo script i'm getting the following error:

loading 3D models libEGL warning: DRI2: failed to create dri screen libEGL warning: DRI2: failed to create dri screen Unable to initialize EGL Command '['/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/build/test_device', '1']' returned non-zero exit status 1. number of devices found 3 Loaded EGL 1.5 after reload. Traceback (most recent call last): File "./tools/test_images.py", line 183, in cfg.renderer.load_objects(model_mesh_paths, model_texture_paths, model_colors) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 396, in load_objects self.load_object(obj_paths[i], texture_paths[i], scale[i]) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 236, in load_object vertices, faces, materials, texture_paths = self.load_mesh(obj_path, scale) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 344, in load_mesh return self.recursive_load(scene.rootnode, [], [], [], [], offset, scale, [[], [], []]) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 387, in recursive_load self.recursive_load(child, vertices, faces, materials, texture_paths, offset, scale, repeated) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 363, in recursive_load print(np.array(mat.properties['diffuse'])[:3]) IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed

When priting model_mesh_paths, model_texture_paths and model_colors they show the correct path from the models. When i change the lines in ycb_renderer.py

mat_diffuse = np.array(mat.properties['diffuse'])[:3] mat_specular = np.array(mat.properties['specular'])[:3] mat_ambient = np.array(mat.properties['ambient'])[:3] #phong shader

to

mat_diffuse = np.array(mat.properties['diffuse'])#[:3] mat_specular = np.array(mat.properties['specular'])#[:3] mat_ambient = np.array(mat.properties['ambient'])#[:3] #phong shader

it bypass the problem, but gives another error:

finished loading sdf ! data/demo/000002-color.png data/demo/000002-depth.png /home/daniel/anaconda3/envs/posecnn/lib/python3.6/site-packages/torch/nn/functional.py:3063: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode)) Traceback (most recent call last): File "./tools/test_images.py", line 215, in im_pose, im_pose_refined, im_label, labels, rois, poses, poses_refined = test_image(network, dataset, im, depth) File "/home/daniel/PoseCNN-PyTorch/tools/../lib/fcn/test_imageset.py", line 86, in test_image poses_refined = refine_pose(labels, depth_tensor, rois, poses, meta_data, dataset) File "/home/daniel/PoseCNN-PyTorch/tools/../lib/fcn/test_common.py", line 68, in refine_pose cfg.renderer.render(cls_indexes, image_tensor, seg_tensor, pc2_tensor=pcloud_tensor) File "/home/daniel/PoseCNN-PyTorch/tools/../ycb_render/ycb_renderer.py", line 488, in render GL.glUniform3f(GL.glGetUniformLocation(shader, 'mat_specular'), *self.materials[index][idx][3:6]) TypeError: this function takes at least 4 arguments (2 given)

yuxng commented 3 years ago

I saw this in your message: Unable to initialize EGL It seems something wrong with EGL. You can pull the latest code, go to the ycb renderer fold and run 'python ycb_renderer.py'. Make sure you can run the renderer first.

dandmetal commented 3 years ago

Same error.

libEGL warning: DRI2: failed to create dri screen libEGL warning: DRI2: failed to create dri screen Unable to initialize EGL Command '['/home/daniel/PoseCNN-PyTorch/ycb_render/build/test_device', '1']' returned non-zero exit status 1. number of devices found 3 Loaded EGL 1.5 after reload. ['../data/models/003_cracker_box/textured_simple.obj', '../data/models/002_master_chef_can/textured_simple.obj', '../data/models/011_banana/textured_simple.obj'] Traceback (most recent call last): File "ycb_renderer.py", line 870, in renderer.load_objects(obj_paths, texture_paths, colors) File "ycb_renderer.py", line 396, in load_objects self.load_object(obj_paths[i], texture_paths[i], scale[i]) File "ycb_renderer.py", line 237, in load_object vertices, faces, materials, texture_paths = self.load_mesh(obj_path, scale) File "ycb_renderer.py", line 345, in load_mesh return self.recursive_load(scene.rootnode, [], [], [], [], offset, scale, [[], [], []]) File "ycb_renderer.py", line 387, in recursive_load self.recursive_load(child, vertices, faces, materials, texture_paths, offset, scale, repeated) File "ycb_renderer.py", line 364, in recursive_load mat_diffuse = np.array(mat.properties['diffuse'])[:3] IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed

rasake commented 3 years ago

Hey,

I get the same error when running the demo on a NVIDIA Jetson Xavier, python 3.6.9.

Adding some print statements shows that mat.properties['diffuse']=169, so it is an int and not a list, maybe that's a clue?

Well, I should add that there is nothing about being "Unable to initialize EG" in my case.

brieder commented 3 years ago

I had to go back to assimp 4.1.x to get it to work using pyassimp 4.1.3.

I'm on Ubuntu 20.04 which has libassimp-dev 5.0.1 so I built the v4.1.0 from github.com/assimp/assimp.

dandmetal commented 3 years ago

I had to go back to assimp 4.1.x to get it to work using pyassimp 4.1.3.

I'm on Ubuntu 20.04 which has libassimp-dev 5.0.1 so I built the v4.1.0 from github.com/assimp/assimp.

Thanks. Using:

pip install pyassimp==4.1.3

fixed it for me.

smoothumut commented 2 years ago

I had to go back to assimp 4.1.x to get it to work using pyassimp 4.1.3.

I'm on Ubuntu 20.04 which has libassimp-dev 5.0.1 so I built the v4.1.0 from github.com/assimp/assimp.

Thank you my friend, I thank you with all my soul. I also hada Ubuntu 20.04 and the trick for me was uninstalling libassimp-dev (If you have already) then building and installing libassimp-dev v4.1.0 with cmake from the source as mentioned above. (building instructions for assimp with cmake is in explained in their github page, then install using "make install")

Thank you,

l2yDec commented 1 year ago

I have already using assimp 4.1.3 (python 3.8.13), but still failed.

$ python ycb_renderer.py libEGL warning: DRI2: failed to create dri screen libEGL warning: DRI2: failed to create dri screen Unable to initialize EGL Command '['/home/rakuli/3dTracking/PoseCNN-PyTorch/ycb_render/build/test_device', '1']' returned non-zero exit status 1. number of devices found 3 Loaded EGL 1.5 after reload. ['../data/models/003_cracker_box/textured_simple.obj', '../data/models/002_master_chef_can/textured_simple.obj', '../data/models/011_banana/textured_simple.obj'] Traceback (most recent call last): File "ycb_renderer.py", line 870, in renderer.load_objects(obj_paths, texture_paths, colors) File "ycb_renderer.py", line 396, in load_objects self.load_object(obj_paths[i], texture_paths[i], scale[i]) File "ycb_renderer.py", line 237, in load_object vertices, faces, materials, texture_paths = self.load_mesh(obj_path, scale) File "ycb_renderer.py", line 345, in load_mesh return self.recursive_load(scene.rootnode, [], [], [], [], offset, scale, [[], [], []]) File "ycb_renderer.py", line 387, in recursive_load self.recursive_load(child, vertices, faces, materials, texture_paths, offset, scale, repeated) File "ycb_renderer.py", line 364, in recursive_load mat_diffuse = np.array(mat.properties['diffuse'])[:3] IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed

s-tian commented 1 year ago

If you're using a conda environment and are also running into this issue: conda install -c conda-forge assimp==4.1.0 followed by reinstalling pyassimp==4.1.3 resolved it for me.

tsrobcvai commented 1 year ago

As the above comments, if you are on ubantu 20.04, first uninstall libassimp-dev 5.0.1, then install the v4.1.0. This would solve the problem.