ONE - On-device Neural Engine
Loading...
Searching...
No Matches
model_runner_onnx.py
Go to the documentation of this file.
1from common_place import *
2
3import onnx
4import caffe2.python.onnx.backend
5
6
7def run_onnx(model, input_path, output_path=''): #args.model[0] , args.input
8 path = model
9
10 #I'll leave it in case anyone needs to read the .pb file.
11 #proto_arr = onnx.TensorProto()
12 #with open(input_path, 'rb') as f:
13 # proto_arr.ParseFromString(f.read())
14 # input_arr = onnx.numpy_helper.to_array(proto_arr)
15
16 modelFile = onnx.load(path, 'rb')
17 input_arr = read_input(input_path)
18 output = caffe2.python.onnx.backend.run_model(modelFile, input_arr)
19
20 print(output)
21 save_result(output_path, output)
22
23
24if __name__ == '__main__':
25 args = regular_step()
26
27 run_onnx(args.model[0], args.input, args.output_path)
read_input(input_path)
save_result(output_path, output_data)
run_onnx(model, input_path, output_path='')