TF Lite on Raspberry Pi 4b

48 views
Skip to first unread message

Simon Perales

unread,
Jan 30, 2023, 10:01:49 AM1/30/23
to TensorFlow Lite
Hi all,

I've been trying to set up tflite on a Raspberry Pi 4b 8gb, with Raspbian Bullseye 32 bit. I followed the instructions on this page: https://github.com/Qengineering/TensorFlow_Lite_Pose_RPi_32-bits.

Versions:
g++ (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110
Flatc - 23.1.21

These are the includes I use:

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <opencv2/core/ocl.hpp>
#include "tensorflow/lite/builtin_op_data.h"
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/string_util.h"
#include "tensorflow/lite/model.h"
#include <cmath>

When I try to build, I get these errors:


-------------- Build: Debug in FirstTFlite (compiler: GNU GCC Compiler)---------------

g++ -Wall -g -I/usr/local/include/opencv4 -I/home/pi/tensorflow -c /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp -o obj/Debug/firstMainTFL.o
g++  -o bin/Debug/FirstTFlite obj/Debug/firstMainTFL.o obj/Debug/hello_wrld.o  
In file included from /home/pi/tensorflow/tensorflow/lite/core/api/op_resolver.h:23,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:28,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h: In member function 'bool tflite::QuantizationParameters::Verify(flatbuffers::Verifier&) const':
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h:3310:58: error: no matching function for call to 'tflite::QuantizationParameters::VerifyField<uint8_t>(flatbuffers::Verifier&, tflite::QuantizationParameters::FlatBuffersVTableOffset) const'
 3310 |            VerifyField<uint8_t>(verifier, VT_DETAILS_TYPE) &&
      |                                                          ^
In file included from /usr/local/include/flatbuffers/flatbuffer_builder.h:33,
                 from /usr/local/include/flatbuffers/flatbuffers.h:29,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:24,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/usr/local/include/flatbuffers/table.h:115:8: note: candidate: 'bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const [with T = unsigned char; flatbuffers::voffset_t = short unsigned int; size_t = unsigned int]'
  115 |   bool VerifyField(const Verifier &verifier, voffset_t field,
      |        ^~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note:   candidate expects 3 arguments, 2 provided
In file included from /home/pi/tensorflow/tensorflow/lite/core/api/op_resolver.h:23,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:28,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h:3313:65: error: no matching function for call to 'tflite::QuantizationParameters::VerifyField<int32_t>(flatbuffers::Verifier&, tflite::QuantizationParameters::FlatBuffersVTableOffset) const'
 3313 |            VerifyField<int32_t>(verifier, VT_QUANTIZED_DIMENSION) &&
      |                                                                 ^
In file included from /usr/local/include/flatbuffers/flatbuffer_builder.h:33,
                 from /usr/local/include/flatbuffers/flatbuffers.h:29,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:24,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/usr/local/include/flatbuffers/table.h:115:8: note: candidate: 'bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const [with T = int; flatbuffers::voffset_t = short unsigned int; size_t = unsigned int]'
  115 |   bool VerifyField(const Verifier &verifier, voffset_t field,
      |        ^~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note:   candidate expects 3 arguments, 2 provided
In file included from /home/pi/tensorflow/tensorflow/lite/core/api/op_resolver.h:23,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:28,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h: In member function 'bool tflite::DimensionMetadata::Verify(flatbuffers::Verifier&) const':
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h:3660:51: error: no matching function for call to 'tflite::DimensionMetadata::VerifyField<int8_t>(flatbuffers::Verifier&, tflite::DimensionMetadata::FlatBuffersVTableOffset) const'
 3660 |            VerifyField<int8_t>(verifier, VT_FORMAT) &&
      |                                                   ^
In file included from /usr/local/include/flatbuffers/flatbuffer_builder.h:33,
                 from /usr/local/include/flatbuffers/flatbuffers.h:29,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:24,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/usr/local/include/flatbuffers/table.h:115:8: note: candidate: 'bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const [with T = signed char; flatbuffers::voffset_t = short unsigned int; size_t = unsigned int]'
  115 |   bool VerifyField(const Verifier &verifier, voffset_t field,
      |        ^~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note:   candidate expects 3 arguments, 2 provided
In file included from /home/pi/tensorflow/tensorflow/lite/core/api/op_resolver.h:23,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:28,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h:3661:56: error: no matching function for call to 'tflite::DimensionMetadata::VerifyField<int32_t>(flatbuffers::Verifier&, tflite::DimensionMetadata::FlatBuffersVTableOffset) const'
 3661 |            VerifyField<int32_t>(verifier, VT_DENSE_SIZE) &&
      |                                                        ^
In file included from /usr/local/include/flatbuffers/flatbuffer_builder.h:33,
                 from /usr/local/include/flatbuffers/flatbuffers.h:29,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:24,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/usr/local/include/flatbuffers/table.h:115:8: note: candidate: 'bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const [with T = int; flatbuffers::voffset_t = short unsigned int; size_t = unsigned int]'
  115 |   bool VerifyField(const Verifier &verifier, voffset_t field,
      |        ^~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note:   candidate expects 3 arguments, 2 provided
In file included from /home/pi/tensorflow/tensorflow/lite/core/api/op_resolver.h:23,
                 from /home/pi/tensorflow/tensorflow/lite/interpreter_builder.h:28,
                 from /home/pi/tensorflow/tensorflow/lite/model.h:21,
                 from /home/pi/tensorflow/tensorflow/lite/kernels/register.h:18,
                 from /home/pi/FirstTFL/FirstTFlite/firstMainTFL.cpp:9:
/home/pi/tensorflow/tensorflow/lite/schema/schema_generated.h:3662:65: error: no matching function for call to 'tflite::DimensionMetadata::VerifyField<uint8_t>(flatbuffers::Verifier&, tflite::DimensionMetadata::FlatBuffersVTableOffset) const'
 
 This continues with the same types of errors. 

I've found that I don't get these errors if I delete these includes:

#include "tensorflow/lite/kernels/register.h"

#include "tensorflow/lite/model.h"

From what I can find online, the people having similar problems are having these problems because they use an unsupported version of flatbuffers:


Thank you for your help,
Simon

Simon Perales

unread,
Jan 31, 2023, 12:46:27 PM1/31/23
to TensorFlow Lite, Simon Perales
Solved by using Flatbuffers 2.0.0
Reply all
Reply to author
Forward
0 new messages