【发布时间】:2021-12-09 17:54:23
【问题描述】:
converter = tf.lite.TFLiteConverter.from_keras_model( './signet.h5')
tflite_model = converter.convert()
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2464/3288577076.py in <module>
1 converter = tf.lite.TFLiteConverter.from_keras_model( './signet.h5')
----> 2 tflite_model = converter.convert()
3 # Save the model.
4 with open('model.tflite', 'wb') as f:
5 f.write(tflite_model)
~\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\lite\python\lite.py in convert(self)
795 # to None.
796 # Once we have better support for dynamic shapes, we can remove this.
--> 797 if not isinstance(self._keras_model.call, _def_function.Function):
798 # Pass `keep_original_batch_size=True` will ensure that we get an input
799 # signature including the batch dimension specified by the user.
AttributeError: 'str' object has no attribute 'call'
我正在尝试将 h5 keras 模型转换为 tflite 以用于反应本机应用程序,但显示此错误。 我在论坛上尝试了一些解决方案,其中一个在 github 上,但没有奏效。 有没有办法将我的 h5 模型转换为 tflite。
【问题讨论】:
标签: python tensorflow keras deep-learning tensorflow-lite