ONE - On-device Neural Engine
Loading...
Searching...
No Matches
model_runner_tflite.py
Go to the documentation of this file.
1from common_place import *
2import tensorflow as tf
3
4
5def run_tflite(model, input_path, output_path=''):
6 input = read_input(input_path)
7
8 interpreter = tf.contrib.lite.Interpreter(model_path=model)
9 interpreter.allocate_tensors()
10
11 input_details = interpreter.get_input_details()
12 output_details = interpreter.get_output_details()
13 input_data = input
14 interpreter.set_tensor(input_details[0]['index'], input_data)
15
16 interpreter.invoke()
17 output_data = interpreter.get_tensor(output_details[0]['index'])
18 print(output_data)
19 save_result(output_path, output_data)
20
21
22if __name__ == '__main__':
23 args = regular_step()
24
25 run_tflite(args.model[0], args.input, args.output_path)
read_input(input_path)
save_result(output_path, output_data)
run_tflite(model, input_path, output_path='')