bendangnuksung / mrcnn_serving_ready

🛠 Mask R-CNN Keras to Tensorflow and TFX models + Serving models using TFX GRPC & RESTAPI
https://github.com/matterport/Mask_RCNN
MIT License
103 stars 35 forks source link

ValueError: Layer #391 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 4) dtype=float32_ref> has shape (1024, 4), but the saved weight has shape (1024, 8). #10

Open angyee opened 5 years ago

angyee commented 5 years ago

$ python3 main.py

Using TensorFlow backend. 2019-07-01 11:52:10.385753: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2019-07-01 11:52:10.408767: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3600000000 Hz 2019-07-01 11:52:10.409344: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x22d6a50 executing computations on platform Host. Devices: 2019-07-01 11:52:10.409356: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): , WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer. WARNING:tensorflow:From /home/deepedge/mask_rcnn-master/mrcnn_serving_ready-master/model.py:771: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. Traceback (most recent call last): File "main.py", line 108, in model.load_weights(H5_WEIGHT_PATH, by_name=True) File "/home/deepedge/mask_rcnn-master/mrcnn_serving_ready-master/model.py", line 2131, in load_weights saving.load_weights_from_hdf5_group_by_name(f, layers) File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 1149, 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, 4) dtype=float32_ref> has shape (1024, 4), but the saved weight has shape (1024, 8). @bendangnuksung

LeonSpark commented 5 years ago

I got the same error, and modify the NUM_CLASSES to actual num of classes. NOT actual number of classes + 1(background)

angyee commented 5 years ago

in my case is solved, do download complete clone and make change in user_config.py and use it, use config.py as it is.

vikiQiu commented 5 years ago

I got the same error, and modify the NUM_CLASSES to actual num of classes. NOT actual number of classes + 1(background)

If set NUM_CLASSES as actual num of classes, it will raise error while training. expected input_image_meta to have shape (44,) but got array with shape (45,) Here my num of classes is 32.

LeonSpark commented 5 years ago

@vikiQiu In the config.py in this repo. self.NUM_CLASSES = 1 + NUMBER_OF_CLASSES # Background + tags So you need to set NUM_CLASSES to the acutal one while you are exporting trained model for tf serving with this repo. NOT for training.

davidvirdeforshh commented 5 years ago

I got the same error, and modify the NUM_CLASSES to actual num of classes. NOT actual number of classes + 1(background)

This worked for me. Thank you!