JeVoisBase
1.18
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
Share this page: |
|
|
|
 |
 |
|
Go to the documentation of this file.
26 #include <tensorflow/lite/model.h>
27 #include <tensorflow/lite/interpreter.h>
35 "directory within JEVOIS:/share/tensorflow/ which should contain two files: "
36 "model.tflite and labels.txt",
37 "mobilenet_v1_224_android_quant_2017_11_08", ParamCateg);
41 "If empty, use the module's path.",
42 JEVOIS_SHARE_PATH
"/tensorflow", ParamCateg);
45 JEVOIS_DECLARE_PARAMETER(top,
unsigned int,
"Max number of top-scoring predictions that score above thresh to return",
49 JEVOIS_DECLARE_PARAMETER(thresh,
float,
"Threshold (in percent confidence) above which predictions will be reported",
74 public jevois::Parameter<tflow::netdir, tflow::dataroot, tflow::top, tflow::thresh, tflow::threads,
96 float predict(cv::Mat
const & cvimg, std::vector<jevois::ObjReco> &
results);
105 std::unique_ptr<tflite::FlatBufferModel>
model;
109 void onParamChange(tflow::netdir
const & param, std::string
const & newval)
override;
115 void get_top_n(T * prediction,
int prediction_size, std::vector<jevois::ObjReco> & top_results,
116 bool input_floating);
124 int Report(
char const * format, va_list
args)
override;
virtual ~TensorFlow()
Virtual destructor for safe inheritance.
JEVOIS_DECLARE_PARAMETER(thresh1, double, "First threshold for hysteresis", 50.0, ParamCateg)
TensorFlow(std::string const &instance)
Constructor.
std::unique_ptr< tflite::FlatBufferModel > model
void postUninit() override
Un-initialize and free resources.
std::vector< std::string > labels
Identify an object using TensorFlow deep neural network.
float predict(cv::Mat const &cvimg, std::vector< jevois::ObjReco > &results)
Processing function, results are stored internally in the underlying TensorFlow network object.
void readLabelsFile(std::string const &fname)
void postInit() override
Initialize, configure and load the network in a thread.
void onParamChange(tflow::netdir const ¶m, std::string const &newval) override
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(l2grad, bool, "Use more accurate L2 gradient norm if true, L1 if false", false, ParamCateg)
int Report(char const *format, va_list args) override
std::atomic< bool > itsNeedReload
Network to load This meta parameter sets parameters dataroot
std::atomic< bool > itsReady
std::unique_ptr< tflite::Interpreter > interpreter
void getInDims(int &w, int &h, int &c)
Get input width, height, channels.
JeVoisReporter itsErrorReporter
void get_top_n(T *prediction, int prediction_size, std::vector< jevois::ObjReco > &top_results, bool input_floating)
std::future< void > itsReadyFut