简体   繁体   中英

Not able to convert tf model into tflite model

I tried many ways but I am not able to converter saved model file into tf lite model , i get different error ever time i run new code. Satrting from shape error to error listed below.

 File "C:\\models\py\lib\site-packages\tensorflow\python\eager\monitoring.py", line 407, in __del__
AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets'

I am using this code:

 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)

can anyone tell me how can i convert into tf lite model, i am stuck here for few days

I faced the same issue recently, it seems like a bug in the recent tf-nightly version. For example, you can reproduce the bug as follows.

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'

Please try version 2.4.0.dev20200901. The bug will be gone with this version. Hope it will help everyone, thanks.

It seems that your model contains more than built-in TFLite ops. Can you try using SELECT_TF_OPS?

https://www.tensorflow.org/lite/guide/ops_select

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM