Simple image classification (persons, animals, other) on raspberry pi using custom model tflite (output to terminal), using TensorFlow Lite

Alex G.
2 min readDec 12, 2020
Simple image classification (persons, animals, other) on raspberry pi using custom model tflite (output to terminal) (Photo,GIF by Author) https://github.com/oleksandr-g-rock/image_lassify_tflite_simple/blob/main/demo_cat.gif

Short summary:

In this article, I will explain how to create a solution for simple image classification (persons, animals, others) on raspberry pi using a custom model tflite (output to terminal).
I will use a custom model tflite which I converted from h5.
And all results will be shown in the terminal. Code for this article is available here.

Note before you start:

So, let’s start :)

Hardware preparation:

Software preparation:

1. Create a neural network model to predict 3 classes persons, animals, others.

I have already done it in the article below. So in this article, you do not need to do this.

2 Convert h5 model to tflite model

I have already done it in the article below. So in this article, you do not need to do this.

3 So, let’s implement our model to Simple image classification (persons, animals, other) on raspberry pi using custom model tflite (output to terminal)

For that, you need to run the next code:

#clone my repo
git clone https://github.com/oleksandr-g-rock/image_lassify_tflite_simple.git
#go to folder
cd image_lassify_tflite_simple
#download tflite model
wget https://github.com/oleksandr-g-rock/how_to_convert_h5_model_to_tflite/raw/main/animall_person_other_v2_fine_tuned.tflite
#run script
python3 classify_image_used_tflite.py

4 You should see something like that.

Simple image classification (persons, animals, other) on raspberry pi using custom model tflite (output to terminal) (Photo,GIF by Author) https://github.com/oleksandr-g-rock/image_lassify_tflite_simple/blob/main/demo_cat.gif

Result:

In this article, we created a solution for simple image classification (persons, animals, others) on raspberry pi using custom model tflite (output to terminal).
I using a custom model tflite which I converted from h5.
And all results will be shown in the terminal. Code for this article is available here.

--

--

Alex G.

ML DevOps engineer. 🙂 I am always open to new opportunities and offers. 🖖 I trying to help the world 🌏 with machine learning.