Reputation: 9
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
Upvotes: 0
Views: 572
Reputation: 703
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.
Upvotes: 1
Reputation: 74
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
Upvotes: 0