keras_to_tensorflow
keras_to_tensorflow copied to clipboard
Error: ('Keyword argument not understood:', 'freeze') while trying to convert RetinaNet (.h5) --> (.pb)
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')
Have the same error. Does any one have the idea to fix?
Your model has custom layers. You need to pass the custom objects to the load_model command. Check this issue: https://github.com/fizyr/keras-retinanet/issues/86
Thanks a lot! I will try and let you know:-)
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
I am facing the same issue, where should I pass this and how?
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")
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!!!!