jpterry commited on
Commit
7e083f8
1 Parent(s): 39370b9

back to ort, more options used

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -45,10 +45,12 @@ def load_model(model: str, activation: bool=True):
45
  if activation:
46
  model += '_w_activation'
47
 
48
- sess_options = ort.SessionOptions()
49
- sess_options.intra_op_num_threads = 1
50
- # ort_session = ort.InferenceSession(model_path + '%s.onnx' % (model), sess_options)
51
- ort_session = ORTModel(model_path + '%s.onnx' % (model))
 
 
52
 
53
  return ort_session
54
 
@@ -58,9 +60,9 @@ def get_activations(intermediate_model, image: list,
58
  '''Gets activations for a given input image'''
59
 
60
 
61
- # input_name = intermediate_model.get_inputs()[0].name
62
- # outputs = intermediate_model.run(None, {input_name: image})
63
- outputs = intermediate_model(image)
64
 
65
  output_1 = outputs[1]
66
  output_2 = outputs[2]
 
45
  if activation:
46
  model += '_w_activation'
47
 
48
+ options = ort.SessionOptions()
49
+ options.intra_op_num_threads = 1
50
+ options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
51
+ provider = "CPUExecutionProvider"
52
+ ort_session = ort.InferenceSession(model_path + '%s.onnx' % (model), options, providers=[provider])
53
+ # ort_session = ORTModel.load_model(model_path + '%s.onnx' % (model))
54
 
55
  return ort_session
56
 
 
60
  '''Gets activations for a given input image'''
61
 
62
 
63
+ input_name = intermediate_model.get_inputs()[0].name
64
+ outputs = intermediate_model.run(None, {input_name: image})
65
+ # outputs = intermediate_model(image)
66
 
67
  output_1 = outputs[1]
68
  output_2 = outputs[2]