ONE - On-device Neural Engine
Loading...
Searching...
No Matches
model_runner_onnx.py
Go to the documentation of this file.
1
from
common_place
import
*
2
3
import
onnx
4
import
caffe2.python.onnx.backend
5
6
7
def
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
24
if
__name__ ==
'__main__'
:
25
args =
regular_step
()
26
27
run_onnx
(args.model[0], args.input, args.output_path)
common_place.regular_step
regular_step()
Definition
common_place.py:6
common_place.read_input
read_input(input_path)
Definition
common_place.py:64
common_place.save_result
save_result(output_path, output_data)
Definition
common_place.py:50
model_runner_onnx.run_onnx
run_onnx(model, input_path, output_path='')
Definition
model_runner_onnx.py:7
compiler
nnc
utils
model_runner
model_runner_onnx.py
Generated by
1.9.8