TensorFlowLite C++ API 分类模型
1、编写CMakeLists.txt
set(TFLITE_LIBS /home/surui/Downloads/software/tensorflow-master/tensorflow/lite/tools/make/gen/linux_x86_64/lib/libtensorflow-lite.a)
include_directories(/home/surui/Downloads/software/tensorflow-master/)
include_directories(/home/surui/Downloads/software/tensorflow-master/tensorflow/lite/tools/make/downloads/flatbuffers/include)
include_directories(/home/surui/Downloads/software/tensorflow-master/tensorflow/lite/tools/make/downloads/absl)
2、定义Settings
namespace tflite {
namespace label_image {
struct Settings {
bool verbose = false;
bool accel = false;
bool old_accel = false;
bool input_floating = false;
bool profiling = false;
bool allow_fp16 = false;
bool gl_backend = false;
int loop_count = 1;
float input_mean = 127.5f;
float input_std = 127.5f;
string model_name = "./mobilenet_quant_v1_224.tflite";
tflite::FlatBufferModel* model;
string input_bmp_name = "./grace_hopper.bmp";
string labels_file_name = "./labels.txt";
string input_layer_type = "uint8_t";
int number_of_threads = 4;
int number_of_results = 5;
int max_profiling_buffer_entries = 1024;
int number_of_warmup_runs = 2;
};
} // namespace label_image
} // namespace tflite
3、引入头文件
#include "tensorflow/lite/examples/label_image/label_image.h"
#include <f