ONE - On-device Neural Engine
Loading...
Searching...
No Matches
model_runner_caffe2.py
Go to the documentation of this file.
1from common_place import *
2
3from caffe2.python import workspace
4
5
6def run_caffe2(init_net, predict_net, input_path, output_path=''):
7 x = read_input(input_path)
8 with open(init_net, 'rb') as f:
9 init_net = f.read()
10
11 with open(predict_net, 'rb') as f:
12 predict_net = f.read()
13 p = workspace.Predictor(init_net, predict_net)
14 # TODO get 'data' parameter more universal, blobs contain other names
15 results = p.run({'data': x})
16 print(results)
17 save_result(output_path, results)
18
19
20if __name__ == '__main__':
21 args = regular_step()
22
23 run_caffe2(args.model[0], args.model[1], args.input, args.output_path)
read_input(input_path)
save_result(output_path, output_data)
run_caffe2(init_net, predict_net, input_path, output_path='')