[英]Not able to convert tf model into tflite model
我嘗試了很多方法,但我無法將保存的模型文件轉換為 tf lite 模型,每次運行新代碼時都會遇到不同的錯誤。 從形狀錯誤到下面列出的錯誤。
File "C:\\models\py\lib\site-packages\tensorflow\python\eager\monitoring.py", line 407, in __del__
AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets'
我正在使用此代碼:
import tensorflow as tf #Convert the model converter = tf.lite.TFLiteConverter.from_saved_model('new_graph/saved_model') # path to the SavedModel directory tflite_model = converter.convert() #Save the model. with open('facemask_model.tflite', 'wb') as f: tf.write(tflite_model)
誰能告訴我如何轉換成 tf lite 模型,我被困在這里幾天了
我最近遇到了同樣的問題,這似乎是最近 tf-nightly 版本中的一個錯誤。 例如,您可以按如下方式重現該錯誤。
Python 3.7.9 (default, Aug 31 2020, 12:42:55)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-10-21 13:48:47.162423: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
>>>
>>> exit()
Exception ignored in: <function Buckets.__del__ at 0x7f8b017e2830>
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py", line 407, in __del__
AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets'
請嘗試 2.4.0.dev20200901 版本。 該錯誤將在此版本中消失。 希望對大家有幫助,謝謝。
似乎您的模型包含的不僅僅是內置的 TFLite 操作。 您可以嘗試使用 SELECT_TF_OPS 嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.