amir-abdi / keras_to_tensorflow

General code to convert a trained keras model into an inference tensorflow model
MIT License
1.67k stars 539 forks source link

TypeError: ('Keyword argument not understood:', 'interpolation') #75

Open globalmaster opened 5 years ago

globalmaster commented 5 years ago

Hi, I'm trying to convert AdvancedEAST model "east_model_3T256.h5" to .pb file and get this error. How can I solve it? Can you help @amir-abdi @anujanegi @AswathKiruba

Using TensorFlow backend. Traceback (most recent call last): File "keras_to_tensorflow.py", line 182, in app.run(main) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 300, in run _run_main(main, args) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "keras_to_tensorflow.py", line 128, in main model = load_model(FLAGS.input_model, FLAGS.input_model_json, FLAGS.input_model_yaml) File "keras_to_tensorflow.py", line 63, in load_model model = keras.models.load_model(input_model_path) File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 260, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 334, in model_from_config return deserialize(config, custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "/usr/local/lib/python3.5/dist-packages/keras/engine/network.py", line 1017, in from_config process_layer(layer_data) File "/usr/local/lib/python3.5/dist-packages/keras/engine/network.py", line 1003, in process_layer custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 147, in deserialize_keras_object return cls.from_config(config['config']) File "/usr/local/lib/python3.5/dist-packages/keras/engine/base_layer.py", line 1109, in from_config return cls(*config) File "/usr/local/lib/python3.5/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(args, kwargs) File "/usr/local/lib/python3.5/dist-packages/keras/layers/convolutional.py", line 1936, in init super(UpSampling2D, self).init(kwargs) File "/usr/local/lib/python3.5/dist-packages/keras/engine/base_layer.py", line 128, in init raise TypeError('Keyword argument not understood:', kwarg) TypeError: ('Keyword argument not understood:', 'interpolation')

anujanegi commented 5 years ago

Use python instead of python3 in your command.

globalmaster commented 5 years ago

Use python instead of python3 in your command.

Hi, Thank you for your replay. I tried run: python2 keras_to_tensorflow.py --input_model="/media/jack/code/clion_kdevelop/OCR/keras_to_tensorflow/east_model_3T736.h5" --output_model="/media/jack/code/clion_kdevelop/OCR/keras_to_tensorflow/east_model__3T736.pb"

I meet this error: File "keras_to_tensorflow.py", line 122, in main Path(output_model).parent.mkdir(parents=True, exist_ok=True) TypeError: mkdir() got an unexpected keyword argument 'exist_ok' I fixed it: Path(output_model).parent.mkdir(parents=True)

Then I meet this error: File "keras_to_tensorflow.py", line 183, in app.run(main) File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 300, in run _run_main(main, args) File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "keras_to_tensorflow.py", line 121, in main Path(output_model).parent.mkdir(parents=True) File "/usr/local/lib/python2.7/dist-packages/pathlib.py", line 1106, in mkdir self._accessor.mkdir(self, mode) File "/usr/local/lib/python2.7/dist-packages/pathlib.py", line 346, in wrapped return strfunc(str(pathobj), *args) OSError: [Errno 17] File exists: '/media/jack/code/clion_kdevelop/OCR/keras_to_tensorflow' I set: #if name == "main":

app.run(main)

main

Than this script can run, but no output. How can I solve this error?

clippingforlove commented 5 years ago

Hi, have you succeed in solving the problem , and how? I have the same error. thanks

HienTran1997 commented 4 years ago

I have the same error when run the code on gg colab, II had install the tensorflow 1.12.0 and keras 2.2.4 but it not working :(