Skip to content

Performance testing of 24 Machine Learning models on Raspberry Pi using TensorFlow Lite and Google Coral USB Accelerator

Notifications You must be signed in to change notification settings

jiteshsaini/model_garden

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Model Garden

Article: Watch the video on Yotube:

This project has been awarded TensorFlow Community Spotlight winner in June 2021. I am thankful for this Tweet by TensorFlow mentioning this achievement and gifting these TensorFlow souvenirs.

About the Project

Google has published a large number of Pre-trained Machine Learning Models for anyone to download and experiment. You can check the complete list of freely available models here https://coral.ai/models/all/. Some of the computer vision models have been packaged as canned models and can be downloaded from this link https://dl.google.com/coral/canned_models/all_models.tar.gz.
This repo contains the code for testing following canned models using a single python script.

Image Classification Models

inception_v1_224_quant_edgetpu.tflite, imagenet_labels.txt
inception_v2_224_quant_edgetpu.tflite, imagenet_labels.txt
inception_v3_299_quant_edgetpu.tflite, imagenet_labels.txt
inception_v4_299_quant_edgetpu.tflite, imagenet_labels.txt
mobilenet_v1_1.0_224_quant_edgetpu.tflite, imagenet_labels.txt
mobilenet_v2_1.0_224_quant_edgetpu.tflite, imagenet_labels.txt

mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite, inat_bird_labels.txt
mobilenet_v2_1.0_224_inat_insect_quant_edgetpu.tflite, inat_insect_labels.txt
mobilenet_v2_1.0_224_inat_plant_quant_edgetpu.tflite, inat_plant_labels.txt

Object Detection Models

mobilenet_ssd_v1_coco_quant_postprocess_edgetpu.tflite, coco_labels.txt
mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite, coco_labels.txt
mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite, coco_labels.txt

All you need is a Raspberry Pi and a Picamera or a USB Camera to run this project.

Configure your Raspberry Pi to Run this Project

Download this repo on your Raspberry Pi and run the bash script "install.sh" using command sudo sh install.sh. This bash script will download all the necessary packages/libraries required for this project. Also, the all the Models and the source code will be downloaded automatically and placed in the correct path.
You need to wait patiently as the script can take upto 20 minutes (depending on your internet speed) to complete the task.

The script perfoms following actions on your Raspberry Pi automatically:-

  • Update & upgrade Raspberry Pi OS
  • Install Apache Webserver and PHP
  • Install Tensorflow Lite and Google Coral USB Accelerator Libraries
  • Install OpenCV
  • Download pre-trained Models from google coral repository
  • Download the model_garden source code
  • Move the models and code to desired location in your Raspbrerry Pi and set permissions.

How to run the code

Open terminal in Raspberry Pi and type the following commands:-

cd /vars/www/html/model_garden

python3 model_garden.py

you should see the following message on terminal

  • check the ip of your Raspberry Pi using command hostname -I
  • For example, if it is 192.168.1.12, then using any Laptop/mobile open a browser and type the following URL:-
192.168.1.12/model_garden

Now, you should start seeing the camera video with overlays on the Web GUI. You can switch between the various models using the buttons provided on Web GUI. Based on your selection the respective model along with its label file gets loaded in the background during run time itself. This allows you to quickly change the models and appreciate the inferencing speeds

Attaching USB Coral Accelerator

If you have a USB Coral Accelerator, then attach it to Raspberry Pi. Now you can press the button at top right corner of Web GUI to run the models which are compiled to run on Coral Accelerator. These models have _edgetpu in their labels. Do not press this button if you haven't connected USB Coral Accelerator to Raspberry Pi. Otherwise the script will halt and you will have to restart the script.

Performance on Raspberry Pi 4

Performance on Raspberry Pi 3A +

About

Performance testing of 24 Machine Learning models on Raspberry Pi using TensorFlow Lite and Google Coral USB Accelerator

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published