Mask_rcnn: load_weights_from_hdf5_group_by_name unknown attribute in latest keras

Created on 16 May 2018  ·  12Comments  ·  Source: matterport/Mask_RCNN

In the demo notebook, the line below
model.load_weights(COCO_MODEL_PATH, by_name=True)
is used to load weights, this no longer works in Keras. I tried with the latest github pull, as well as the pip default install on ubuntu 16.04. I had to revert to Keras 2.0.8 specifically to get this to work. Looks like model.load_weights and model.save_weights is the way going forward in keras.

    if by_name:
        topology.load_weights_from_hdf5_group_by_name(f, layers)
    else:
        topology.load_weights_from_hdf5_group(f, layers)

Most helpful comment

@tanzf

  1. Type git checkout -- . on your terminal to remove all changes.(or remove Mask_RCNN directory and then clone this repo again)
  2. Open mrcnn/model.py file.
  3. Replace all topology with saving.
  4. Save mrcnn/model.py file.
  5. Run sample/demo.ipynb(or something) on jupyter notebook.

All 12 comments

I made pull request. Until it merged, You can replace topology with saving. Topology engine will be deprecated :)

I made the change still I'm getting error.

Loading weights /home/pratibha/dl_semseg/Mask_RCNN/mask_rcnn_coco.h5
Traceback (most recent call last):
File "balloon.py", line 353, in
"mrcnn_bbox", "mrcnn_mask"])
File "/home/pratibha/anaconda3/lib/python3.5/site-packages/mask_rcnn-2.1-py3.5.egg/mrcnn/model.py", line 2119, in load_weights
AttributeError: module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name'

@PratibhaT After changing that, You have to rollback your ipynb file to original ipynb

@gtgalone You have to rollback your ipynb file to original ipynb?How to do the specific operation?

@tanzf

  1. Type git checkout -- . on your terminal to remove all changes.(or remove Mask_RCNN directory and then clone this repo again)
  2. Open mrcnn/model.py file.
  3. Replace all topology with saving.
  4. Save mrcnn/model.py file.
  5. Run sample/demo.ipynb(or something) on jupyter notebook.

@tanzf
After changing the model.py file don't forget to reinstall the maskrcnn package using python3 setup.py install that should make it work I used the same instructions mentioned by @gtgalone

@gtgalone @yshvrdhn thank you..it worked...but i'm not able to run it on my gpu...in config.py it says that put GPU_COUNT=1 for training on cpu, So, changed that to 2, and it raised an error. Which files did you change to run training on gpu.

@PratibhaT Well GPU_COUNT signifies the number of GPUs you have available i.e. if you have one let it be 1.

@yshvrdhn thank you. I figured out that my tensorflow-gpu was not installed properly that is why training was running on cpu.

excellent

verified working, so closing.

I've an issue when I applied your code on gray-scale images (2D dimesion) . Please I need help

Thanks

Was this page helpful?
0 / 5 - 0 ratings