Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ('Keyword argument not understood:', 'freeze') while trying to convert RetinaNet (.h5) --> (.pb) #57

Open
rajanksin opened this issue Aug 2, 2018 · 7 comments

Comments

@rajanksin
Copy link

I downloaded a pre trained Keras model from:
https://github.com/fizyr/keras-retinanet/releases/download/0.4.1/resnet50_coco_best_v2.1.0.h5

Keras and Tensorflow version:

>>> import keras as k
Using TensorFlow backend.
>>> k.__version__
'2.2.0'

>>> import tensorflow as tf
>>> tf.__version__
'1.8.0'
>>>

I tried with keras version 2.1.0 too, get the same error.

I get the error with command:
python keras_to_tensorflow.py -input_model_file resnet50_coco_best_v2.1.0.h5

Traceback (most recent call last):
  File "keras_to_tensorflow.py", line 114, in <module>
    net_model = load_model(weight_file_path)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/saving.py", line 261, in load_model
    model = model_from_config(model_config, custom_objects=custom_objects)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/saving.py", line 335, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
    printable_module_name='layer')
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
    list(custom_objects.items())))
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/network.py", line 1036, in from_config
    process_layer(layer_data)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/network.py", line 1022, in process_layer
    custom_objects=custom_objects)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
    printable_module_name='layer')
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 147, in deserialize_keras_object
    return cls.from_config(config['config'])
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/base_layer.py", line 1124, in from_config
    return cls(**config)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/layers/normalization.py", line 75, in __init__
    super(BatchNormalization, self).__init__(**kwargs)
  File "/Users/srajanku/anaconda2/envs/retina-test/lib/python3.6/site-packages/keras/engine/base_layer.py", line 128, in __init__
    raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'freeze')
@zhoushuai123
Copy link

Have the same error. Does any one have the idea to fix?

@amir-abdi
Copy link
Owner

Your model has custom layers. You need to pass the custom objects to the load_model command.
Check this issue: fizyr/keras-retinanet#86

@zhoushuai123
Copy link

Thanks a lot! I will try and let you know:-)

@zhoushuai123
Copy link

Thanks:-) It works

Your model has custom layers. You need to pass the custom objects to the load_model command.
Check this issue: fizyr/keras-retinanet#86

@zubairahmed-ai
Copy link

I am facing the same issue, where should I pass this and how?

@zubairahmed-ai
Copy link

I figured in out, this is how its done

in keras_to_tensorflow.py
Add
from keras_retinanet import models

Then comment line 62
# model = keras.models.load_model(input_model_path)

and add the following like this
model = models.load_model(input_model_path, backbone_name="resnet50")

@wnov
Copy link

wnov commented Mar 6, 2019

I figured in out, this is how its done
in keras_to_tensorflow.py
Add
from keras_retinanet import models
Then comment line 62

model = keras.models.load_model(input_model_path)

and add the following like this
model = models.load_model(input_model_path, backbone_name="resnet50")

It works!!! thanks!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants