Giter VIP home page Giter VIP logo

qengineering / tensorflow_lite_classification_rpi_64-bits Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 3.0 880 KB

TensorFlow Lite classification on a bare Raspberry Pi 4 with 64-bit OS at 23 FPS

Home Page: https://qengineering.eu/install-ubuntu-18.04-on-raspberry-pi-4.html

License: BSD 3-Clause "New" or "Revised" License

C++ 100.00%
tensorflow-lite tensorflow-examples raspberry-pi-4 ubuntu1804 deep-learning cpp high-fps aarch64 armv7 armv8

tensorflow_lite_classification_rpi_64-bits's Introduction

output image Find this example on our SD-image

TensorFlow_Lite_Classification_RPi_64-bits

output image

TensorFlow Lite classification running on a bare Raspberry Pi 4

License

A fast C++ implementation of TensorFlow Lite classification on a bare Raspberry Pi 4. The Raspberry Pi 64 bits version of Ubuntu is used as operating system. Once overclocked to 1925 MHz, your app runs at 23 FPS without any hardware accelerator. Special made for a bare Raspberry Pi see: https://qengineering.eu/install-ubuntu-18.04-on-raspberry-pi-4.html


Papers: https://arxiv.org/pdf/1712.05877.pdf
Training set: COCO with 1000 objects
Size: 224x224


Benchmark.

Model RPI 4 @1950 MHz - 64 OS
Mobile_V1 Lite 38.5 FPS
Mobile_V2 Lite 45.5 FPS
Inception_V2 Lite 10.0 FPS
Inception_V4 Lite 2.0 FPS

With a regular 32 bits Raspbian OS you get lower frame rates see: https://github.com/Qengineering/TensorFlow_Lite_Classification_RPi_32-bits


Dependencies.

To run the application, you have to:

  • A raspberry Pi 4 with a 64-bit operating system. It can be the Raspberry 64-bit OS, or Ubuntu 18.04 / 20.04. Install 64-bit OS
  • TensorFlow Lite framework installed. Install TensorFlow Lite
  • OpenCV 64 bit installed. Install OpenCV 4.5
  • Code::Blocks installed. ($ sudo apt-get install codeblocks)

Installing the app.

To extract and run the network in Code::Blocks
$ mkdir MyDir
$ cd MyDir
$ wget https://github.com/Qengineering/TensorFlow_Lite_Classification_RPi_64-bits/archive/refs/heads/master.zip
$ unzip -j master.zip
Remove master.zip and README.md as they are no longer needed.
$ rm master.zip
$ rm README.md

Your MyDir folder must now look like this:
tabby.jpeg
schoolbus.jpg
grace_hopper.bmp
Labels.txt
TensorFlow_Lite_Mobile.cpb
TensorFlow_Lite_Class.cpp

Next, choose your model from TensorFlow: https://www.tensorflow.org/lite/guide/hosted_models
Download a quantized model, extract the .tflite from the tarball and place it in your MyDir.

Now your MyDir folder may contain: mobilenet_v1_1.0_224_quant.tflite.
Or: inception_v4_299_quant.tflite. Or both of course.

Enter the .tflite file of your choice on line 54 in TensorFlow_Lite_Class.cpp
The image to be tested is given a line 84, also in TensorFlow_Lite_Class.cpp


Running the app.

Run TestTensorFlow_Lite.cpb with Code::Blocks. More info or
if you want to connect a camera to the app, follow the instructions at Hands-On.


paypal

tensorflow_lite_classification_rpi_64-bits's People

Contributors

qengineering avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tensorflow_lite_classification_rpi_64-bits's Issues

Compile errors TensorFlow_Lite_Class.cpp

switch (interpreter->tensor(output)->type) {
case kTfLiteFloat32:
tflite::label_image::get_top_n(interpreter->typed_output_tensor(0), output_size,
5, threshold, &top_results, true);
break;
case kTfLiteUInt8:
tflite::label_image::get_top_n<uint8_t>(interpreter->typed_output_tensor<uint8_t>(0), output_size,
5, threshold, &top_results, false);
break;

/root/TensorFlow_Lite_RPi_64-bits/TensorFlow_Lite_Class.cpp|118|error: cannot convert ‘bool’ to ‘TfLiteType’|
/root/tensorflow/tensorflow/lite/examples/label_image/get_top_n_impl.h|35|note: initializing argument 6 of ‘void tflite::label_image::get_top_n(T*, int, size_t, float, std::vector<std::pair<float, int> >*, TfLiteType) [with T = float; size_t = long unsigned int]’|

Using Ubuntu 20.04 or RaspiOS 64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.