back to ort, more options used
Browse files
app.py
CHANGED
@@ -45,10 +45,12 @@ def load_model(model: str, activation: bool=True):
|
|
45 |
if activation:
|
46 |
model += '_w_activation'
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
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 |
-
|
62 |
-
|
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]
|