Reputation: 2712
I'm having trouble trying to list the operations of a TFLite model. I know operations can be listed given a frozen graph, but what about a TFLite .tflite
model? Can operations be listed?
Upvotes: 4
Views: 4210
Reputation: 5050
We can use netron to visualize the operators and the constants in a .tflite
model. We can use it from web or install it with pip or install binaries and use it as a local app on windows, linux or mac. The netron app looks like this:
Upvotes: 0
Reputation: 365
You can get a list of all used Tensorflow Lite Operations with the visualization script.
wget -O tflite_visualize.py https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/lite/tools/visualize.py
Assuming your model is saved in model.tflite
create the html file using the downloaded script.
python tflite_visualize.py model.tflite model_visualization.html
Right in the section labled Ops.
Upvotes: 4
Reputation: 4289
As mentioned in the TensorFlow Lite docs, you need to use a tf.lite.Interpreter
to parse a .tflite
model.
# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()
Then use the get_tensor_details method to get the list of Tensors.
interpreter.get_tensor_details()
As per the docs,
Gets tensor details for every tensor with valid tensor details. Tensors where required information about the tensor is not found are not added to the list. This includes temporary tensors without a name.
Returns: A list of dictionaries containing tensor information.
Upvotes: 2