tensorflow: Cant convert my model to tflite. Show the following error. (included code).
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Windows 10
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary):anaconda
- TensorFlow version (use command below):latest
- Python version:3.6.5
- Bazel version (if compiling from source):No
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version:No
- GPU model and memory:920m
code used to convert the file: from tensorflow.contrib import lite keras_file = “movie_classifier.h5” keras.models.save_model(model, keras_file) converter = lite.TocoConverter.from_keras_model_file(keras_file) tflite_model = converter.convert() open(“linear.h5” , wb).write(tflite_model)
Error is as follows:
RuntimeError: TOCO failed see console for info.
b’C:\ProgramData\Anaconda3\lib\site-packages\h5py\init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float
to np.floating
is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type
.\r\n from ._conv import register_converters as _register_converters\r\nTraceback (most recent call last):\r\n File “C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\contrib\lite\toco\python\tensorflow_wrap_toco.py”, line 18, in swig_import_helper\r\n fp, pathname, description = imp.find_module('_tensorflow_wrap_toco', [dirname(file)])\r\n File “C:\ProgramData\Anaconda3\lib\imp.py”, line 297, in find_module\r\n raise ImportError(_ERR_MSG.format(name), name=name)\r\nImportError: No module named '_tensorflow_wrap_toco'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File “C:\ProgramData\Anaconda3\Scripts\toco_from_protos-script.py”, line 6, in <module>\r\n from tensorflow.contrib.lite.toco.python.toco_from_protos import main\r\n File “C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\contrib\lite\toco\python\toco_from_protos.py”, line 22, in <module>\r\n from tensorflow.contrib.lite.toco.python import tensorflow_wrap_toco\r\n File “C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\contrib\lite\toco\python\tensorflow_wrap_toco.py”, line 28, in <module>\r\n _tensorflow_wrap_toco = swig_import_helper()\r\n File “C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\contrib\lite\toco\python\tensorflow_wrap_toco.py”, line 20, in swig_import_helper\r\n import _tensorflow_wrap_toco\r\nModuleNotFoundError: No module named '_tensorflow_wrap_toco'\r\n’
None
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (6 by maintainers)
Can you try like below
from tensorflow import lite
instead of
from tensorflow.contrib import lite
Can you try,
Try to follow the steps in below link: https://www.tensorflow.org/install/pip
I suspect because you are using Python 3.7, the package released does not support Python 3.7 yet.
Try to use respective versions and check once. Suggest try with Python 3.6. Please do let me know your outcomes.