Supported frameworks
The ARTPEC DLPUs require the TensorFlow Lite format, while the CV25 and CV75 DLPUs use a proprietary format. The CV25 format can be converted from either TensorFlow Lite or ONNX, while the CV75 format can only be converted from ONNX. When using a TFLite model for the ARTPEC DLPUs, keep in mind that only TFLite built-in int8 ops are supported to run on the DLPU tf.lite.OpsSet.TFLITE_BUILTINS_INT8. Custom ops or TensorFlow ops are not supported. However, it's still possible to use operations outside the TFLite dialect, but they will be offloaded to the CPU, as long as the CPU supports them. Most models Axis recommends have a post-processing layer that will do this.
The exact version of TensorFlow Lite on the device can change depending on the device model and AXIS OS version. You can find the exact TensorFlow Lite version in the Software Bill of Materials associated to the AXIS OS version of your specific device in the Download device software page.
Converting from TensorFlow or Keras to TensorFlow Lite
To convert a TensorFlow/Keras model to a TFLite model, you can use the TFLite converter. This is the most reliable way to convert a model to TFLite. Here is an example code snippet on how to convert a model to TFLite:
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = a_representative_datagenerator
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.uint8
converter.inference_output_type = tf.uint8
tflite_quant_model = converter.convert()
You can find the full code example here.
In the case of ARTPEC-8, if the script is based on TensorFlow 2, the following flag is also needed to achieve optimal performance.
converter._experimental_disable_per_channel = True
Converting between ONNX and TensorFlow Lite
Axis doesn't have any official tools to convert models between ONNX and Tensorflow Lite. However, you can try converting an ONNX model to a TFLite model using the unofficial onnx2tflite or onnx2tf tools.
For converting from TensorFlow Lite to ONNX, you can try following the Getting Started Converting TensorFlow to ONNX guide provided by ONNX Runtime.
Please note that these tools are not supported by Axis, and there is no guarantee that the conversion will work or that the converted model will run on the device. Debugging may be required to make the model run on the device.