question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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')

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
zubairahmed-aicommented, Nov 22, 2018

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”)

0reactions
wnovcommented, 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!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError('Keyword argument not understood:', 'groups') in ...
I just downloaded both models (one using keras and one using tensorflow.keras ) and tried using from keras.models import load_model and from ...
Read more >
How to run Keras model on Jetson Nano - DLology
Step 1: Freeze Keras model and convert into TensorRT model​​ First lets loads a Keras model. For this tutorial, we use pre-trained MobileNetV2...
Read more >
Error while converting keras model to tensorflow saved model
Able to get keras model h5 format for masked RCNN. I have tried 2 approaches: 1.While trying to convert keras model to tensorflow ......
Read more >
keras-retinanet - Python Package Health Analysis - Snyk
load_weights(weights_path, by_name=True) and saving this model. If the change has been too significant, you should retrain your model (you can try to load...
Read more >
Full text of "Python Ebooks" - Internet Archive
Great online material like Fast.ai and DeepLearning.ai made understanding how to ... In this book, we want to equip you with the knowledge...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found