Spaces:
Runtime error
Runtime error
Commit
·
3167459
1
Parent(s):
5a994f8
added cpu cores info
Browse files
app.py
CHANGED
|
@@ -14,6 +14,9 @@ _plotly_config={'displayModeBar': False}
|
|
| 14 |
from sentiment_clf_helper import classify_sentiment,create_onnx_model_sentiment,classify_sentiment_onnx
|
| 15 |
from zeroshot_clf_helper import zero_shot_classification,create_onnx_model_zs,zero_shot_classification_onnx
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
import yaml
|
| 18 |
def read_yaml(file_path):
|
| 19 |
with open(file_path, "r") as f:
|
|
@@ -88,13 +91,12 @@ hide_streamlit_style = """
|
|
| 88 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 89 |
|
| 90 |
#onnx runtime inference threading changes -- session options must be passed in session run
|
| 91 |
-
# os.environ["OMP_NUM_THREADS"] = "1"
|
| 92 |
session_options_ort = ort.SessionOptions()
|
| 93 |
session_options_ort.intra_op_num_threads=1
|
| 94 |
session_options_ort.inter_op_num_threads=1
|
| 95 |
# session_options_ort.execution_mode = session_options_ort.ExecutionMode.ORT_SEQUENTIAL
|
| 96 |
|
| 97 |
-
|
| 98 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 99 |
def create_model_dir(chkpt, model_dir):
|
| 100 |
if not os.path.exists(model_dir):
|
|
@@ -182,7 +184,7 @@ def zs_task_selected(task,
|
|
| 182 |
|
| 183 |
if select_task=='README':
|
| 184 |
st.header("NLP Summary")
|
| 185 |
-
|
| 186 |
|
| 187 |
if select_task == 'Detect Sentiment':
|
| 188 |
t1=time.time()
|
|
|
|
| 14 |
from sentiment_clf_helper import classify_sentiment,create_onnx_model_sentiment,classify_sentiment_onnx
|
| 15 |
from zeroshot_clf_helper import zero_shot_classification,create_onnx_model_zs,zero_shot_classification_onnx
|
| 16 |
|
| 17 |
+
import multiprocessing
|
| 18 |
+
total_threads=multiprocessing.cpu_count()#for ort inference
|
| 19 |
+
|
| 20 |
import yaml
|
| 21 |
def read_yaml(file_path):
|
| 22 |
with open(file_path, "r") as f:
|
|
|
|
| 91 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 92 |
|
| 93 |
#onnx runtime inference threading changes -- session options must be passed in session run
|
| 94 |
+
# os.environ["OMP_NUM_THREADS"] = "1" #use this before changing session options of onnx runtime
|
| 95 |
session_options_ort = ort.SessionOptions()
|
| 96 |
session_options_ort.intra_op_num_threads=1
|
| 97 |
session_options_ort.inter_op_num_threads=1
|
| 98 |
# session_options_ort.execution_mode = session_options_ort.ExecutionMode.ORT_SEQUENTIAL
|
| 99 |
|
|
|
|
| 100 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 101 |
def create_model_dir(chkpt, model_dir):
|
| 102 |
if not os.path.exists(model_dir):
|
|
|
|
| 184 |
|
| 185 |
if select_task=='README':
|
| 186 |
st.header("NLP Summary")
|
| 187 |
+
st.write(f"The current App deployed in Huggingface Space has {total_threads} CPU cores ")
|
| 188 |
|
| 189 |
if select_task == 'Detect Sentiment':
|
| 190 |
t1=time.time()
|