I am trying to convert a frozen graph file (.pb) to a TensorFlow Lite FlatBuffer file (.tflite) in Raspberry Pi 3B+ Linux. TensorFlow was installed in Python using pip3; TensorFlow Lite was installed and built (static library) from source. TensorFlow version (installed in Python) is 1.11.0.
I am getting this error: Attributeerror: module 'tensorflow.contrib.lite.python.lite' has no attribute 'TFLiteConverter'.
Here is the Python code (derived from https://www.tensorflow.org/lite/convert/python_api):
#!/usr/bin/python3
import tensorflow as tf
print("tf version = " + tf.version)
graph_def_file = "/home/pi/sols/demo/src/image_classification/network/fruit_models/frozen_graph.pb"
input_arrays = ["X"]
output_arrays = ["softmax"]
converter = tf.contrib.lite.TFLiteConverter.from_frozen_graph(
graph_def_file, input_arrays, output_arrays)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
Please help!