-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf10cec
commit f303cc6
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h" | ||
#include "tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h" | ||
#include "tensorflow/lite/micro/micro_interpreter.h" | ||
#include "tensorflow/lite/schema/schema_generated.h" | ||
|
||
// Include your model data. Replace this with the header file for your model. | ||
#include "model.h" | ||
|
||
// Define the number of elements in the input tensor | ||
#define INPUT_SIZE 300*300 | ||
|
||
using MyOpResolver = tflite::MicroMutableOpResolver<10>; | ||
|
||
// Replace this with your model's input and output tensor sizes | ||
const int tensor_arena_size = 2 * 1024; | ||
uint8_t tensor_arena[tensor_arena_size] __align(16); | ||
|
||
void RunModel(int8_t* input_data) { | ||
tflite::MicroErrorReporter micro_error_reporter; | ||
tflite::ErrorReporter* error_reporter = µ_error_reporter; | ||
|
||
const tflite::Model* model = ::tflite::GetModel(g_model); | ||
|
||
MyOpResolver op_resolver; | ||
// Register your model's operations here | ||
|
||
tflite::MicroInterpreter interpreter(model, op_resolver, tensor_arena, | ||
tensor_arena_size, error_reporter); | ||
|
||
interpreter.AllocateTensors(); | ||
|
||
TfLiteTensor* input = interpreter.input(0); | ||
// Add checks for input tensor properties here if needed | ||
|
||
// Copy image data to model's input tensor | ||
for (int i = 0; i < INPUT_SIZE; ++i) { | ||
input->data.int8[i] = input_data[i]; | ||
} | ||
|
||
TfLiteStatus invoke_status = interpreter.Invoke(); | ||
// Add checks for successful inference here if needed | ||
|
||
TfLiteTensor* output = interpreter.output(0); | ||
// Add checks for output tensor properties here if needed | ||
|
||
// Process your output value here | ||
// For example, SSD models typically produce an array of bounding boxes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tensorflow/lite/micro/recording_micro_allocator.cpp |