kirumang / Pix2Pose

Original implementation of the paper "Pix2Pose: Pixel-Wise Coordinate Regression of Objects for 6D Pose Estimation", in ICCV 2019, https://arxiv.org/abs/1908.07433
MIT License
183 stars 34 forks source link

Layer #2 (named "conv1") expects 2 weight(s), but the saved weights have 1 element(s). #29

Open sanford87 opened 2 years ago

sanford87 commented 2 years ago

I apologize for the newbie question but I've been trying to get this code up and running on a dedicated machine but I can't seem to get past one error.

When running the command: python3 tools/5_evaluation_bop_basic.py 0 /home/taylor/Pix2Pose/cfg/cfg_bop2020.json tless

I get the error: Traceback (most recent call last): File "tools/5_evaluation_bop_basic.py", line 191, in model.load_weights(last_path, by_name=True) File "/home/taylor/tf_env/lib/python3.7/site-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py", line 2130, in load_weights File "/home/taylor/tf_env/lib/python3.7/site-packages/keras/engine/saving.py", line 1328, in load_weights_from_hdf5_group_by_name str(weight_values[i].shape) + '.') ValueError: Layer #391 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 116) dtype=float32> has shape (1024, 116), but the saved weight has shape (1024, 36).

I've believe the folder structures are correct and I downloaded the T-Less: 2D Mask R-CNN Detection + Pix2Pose weights from the link provided and placed them correctly.

As far as I understand it seems the error is caused by a difference in how Keras saves a model vs how Tensorflow does. It seems TensorFlow saves as [beta, gamma, running_mean, running_variance]. While Keras saves as [gamma, beta, running_mean, running_variance].

All that info to ask if anyone could verify that was the issue I'm running into and if there was a solution? Thank you for taking the time to read this and great work on this project!

sanford87 commented 2 years ago

So this doesn't seem to be an error with the TensorFlow/Keras versions.

It seems the number of classes defined for the mask rcnn model differs from that of the weight file. (116=28 vs. 36=9). It seems either the config/dataset definition or the weight file is wrong (e.g., a mask rcnn weight from a different dataset)

I've tested various datasets and the only one that works to a point is ITODD: 2D Mask R-CNN Detection + Pix2Pose weights .

However, I still encounter an which I believe is the script looking for more models than are present. Error as follows: Traceback (most recent call last): File "tools/5_evaluation_bop_basic.py", line 210, in model_param = model_params['{}'.format(model_id)] KeyError: '16'

I will continue to update and I resolve this issue.