Automate testing of TensorFlow Lite model implementation

Testing TensorFlow Lite model with Espresso and instrumentation tests on Android

Making sure that your ML model works correctly on mobile app (part 2)

This is the 2nd article about testing machine learning models created for mobile. In the previous post – Testing TensorFlow Lite image classification model, we built a notebook that exports TensorFlow model to TensorFlow Lite and compares them side by side. But because the conversion process is mostly automatic, there are not many places to break something. We can find differences between quantized and non-quantized models or ensure that TensorFlow Lite works similarily to TensorFlow, but the real issues can come up somewhere else – on the client side implementation.
In this article, I will suggest some solutions for testing TensorFlow Lite model with Android instrumentation tests.

Continue reading

Testing TensorFlow Lite image classification model

Testing TensorFlow Lite classification model

Make sure that your ML model works correctly on mobile app (part 1)

Looking for how to automatically test TensorFlow Lite model on a mobile device? Check the 2nd part of this article.

Building TensorFlow Lite models and deploying them on mobile applications is getting simpler over time. But even with easier to implement libraries and APIs, there are still at least three major steps to accomplish:

  1. Build TensorFlow model,
  2. Convert it to TensorFlow Lite model,
  3. Implement in on the mobile app.

There is a set of information that needs to be passed between those steps – model input/output shape, values format, etc. If you know them (e.g. thanks to visualizing techniques and tools described in this blog post), there is another problem, many software engineers struggle with.

Why the model implemented on a mobile app works differently than its counterpart in a python environment?

Software engineer

In this post, we will try to visualize differences between TensorFlow, TensorFlow Lite and quantized TensorFlow Lite (with post-training quantization) models. This should help us with early models debugging when something goes really wrong.
Here, we will focus only on TensorFlow side. It’s worth to remember, that it doesn’t cover mobile app implementation correctness (e.g. bitmap preprocessing and data transformation). This will be described in one of the future posts.

Continue reading