broadinstitute / keras-rcnn

Keras package for region-based convolutional neural networks (RCNNs)
Other
552 stars 224 forks source link

Import failed #193

Open dberma15 opened 6 years ago

dberma15 commented 6 years ago

Hi,

I'm having trouble implementing the model. The problem is I'm running it on a VM without an internet connection, so everything either has to be presaved to a file or loaded from code. If I try to run the code specifying a backbone:

backbone=keras_rcnn.I models.backbone.VGG16 model = keras_rcnn.models.RCNN((img_size,img_size,3),['cell'],backbone=backbone)

I have problems loading VGG16.

If I save run that code on my computer, save it to "untrained_RCNN_VGG16.h5", and try to load that with

from keras_rcnn.models import RCNN
from keras_rcnn.layers import Anchor
model=load_model("untrained_RCNN_VGG16.h5",{'RCNN':keras_rcnn.models.RCNN,'Anchor':Anchor})

I get the error


> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/models.py", line 240, in load_model
>     model = model_from_config(model_config, custom_objects=custom_objects)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/models.py", line 314, in model_from_config
>     return layer_module.deserialize(config, custom_objects=custom_objects)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
>     printable_module_name='layer')
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 140, in deserialize_keras_object
>     list(custom_objects.items())))
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2490, in from_config
>     process_layer(layer_data)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2476, in process_layer
>     custom_objects=custom_objects)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
>     printable_module_name='layer')
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 142, in deserialize_keras_object
>     return cls.from_config(config['config'])
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 1253, in from_config
>     return cls(**config)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras_rcnn/layers/object_detection/_anchor.py", line 52, in __init__
>     super(Anchor, self).__init__(**kwargs)
>   File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 280, in __init__
>     raise TypeError('Keyword argument not understood:', kwarg)
> TypeError: ('Keyword argument not understood:', 'allowed_border')
> 

I'm not sure how to proceed, as there are no functions or classes "allowed_border". Can anyone help?

jhung0 commented 6 years ago

Did you try saving weights instead of model?

On Thu, Mar 15, 2018 at 2:35 PM, dberma15 notifications@github.com wrote:

Hi,

I'm having trouble implementing the model. The problem is I'm running it on a VM without an internet connection, so everything either has to be presaved to a file or loaded from code. If I try to run the code specifying a backbone:

backbone=keras_rcnn.I models.backbone.VGG16 model = keras_rcnn.models.RCNN((img_size,img_size,3),['cell'], backbone=backbone)

I have problems loading VGG16.

If I save run that code on my computer, save it to "untrained_RCNN_VGG16.h5", and try to load that with

from keras_rcnn.models import RCNN from keras_rcnn.layers import Anchor model=load_model("untrained_RCNN_VGG16.h5",{'RCNN':keras_rcnn.models.RCNN,'Anchor':Anchor})

I get the error

Traceback (most recent call last): File "", line 1, in File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/models.py", line 240, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/models.py", line 314, in model_from_config return layer_module.deserialize(config, custom_objects=custom_objects) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 140, in deserialize_keras_object list(custom_objects.items()))) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2490, in from_config process_layer(layer_data) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2476, in process_layer custom_objects=custom_objects) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 142, in deserialize_keras_object return cls.from_config(config['config']) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 1253, in from_config return cls(config) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras_rcnn/layers/object_detection/_anchor.py", line 52, in init super(Anchor, self).init(kwargs) File "/home/bermads1/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 280, in init raise TypeError('Keyword argument not understood:', kwarg) TypeError: ('Keyword argument not understood:', 'allowed_border')

I'm not sure how to proceed, as there are no functions or classes "allowed_border". Can anyone help?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/broadinstitute/keras-rcnn/issues/193, or mute the thread https://github.com/notifications/unsubscribe-auth/AJJbgihzvi6G2wBA-ZmlzIyHNcj5Kbl-ks5terRlgaJpZM4SsrP5 .

dberma15 commented 6 years ago

Shouldn't saving the model save the weights? Also, I can't train the model on the computer that I saved it because it would take too long.