using optimum
Browse files- app.py +6 -3
- requirements.txt +3 -1
app.py
CHANGED
@@ -7,6 +7,7 @@ import numpy as np
|
|
7 |
# import onnx
|
8 |
import onnxruntime as ort
|
9 |
# from onnx import helper
|
|
|
10 |
|
11 |
import pandas as pd
|
12 |
|
@@ -46,7 +47,8 @@ def load_model(model: str, activation: bool=True):
|
|
46 |
|
47 |
sess_options = ort.SessionOptions()
|
48 |
sess_options.intra_op_num_threads = 1
|
49 |
-
ort_session = ort.InferenceSession(model_path + '%s.onnx' % (model), sess_options)
|
|
|
50 |
|
51 |
return ort_session
|
52 |
|
@@ -56,8 +58,9 @@ def get_activations(intermediate_model, image: list,
|
|
56 |
'''Gets activations for a given input image'''
|
57 |
|
58 |
|
59 |
-
input_name = intermediate_model.get_inputs()[0].name
|
60 |
-
outputs = intermediate_model.run(None, {input_name: image})
|
|
|
61 |
|
62 |
output_1 = outputs[1]
|
63 |
output_2 = outputs[2]
|
|
|
7 |
# import onnx
|
8 |
import onnxruntime as ort
|
9 |
# from onnx import helper
|
10 |
+
from optimum.onnxruntime import ORTModel
|
11 |
|
12 |
import pandas as pd
|
13 |
|
|
|
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 |
'''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]
|
requirements.txt
CHANGED
@@ -4,4 +4,6 @@ matplotlib
|
|
4 |
scipy
|
5 |
onnx
|
6 |
onnxruntime
|
7 |
-
streamlit
|
|
|
|
|
|
4 |
scipy
|
5 |
onnx
|
6 |
onnxruntime
|
7 |
+
streamlit
|
8 |
+
onnx2pytorch
|
9 |
+
optimum
|