Spaces:
Runtime error
Runtime error
Commit
·
87b89de
1
Parent(s):
d77ac81
bug fix
Browse files
app.py
CHANGED
|
@@ -145,7 +145,7 @@ with st.sidebar:
|
|
| 145 |
############### Pre-Download & instantiate objects for sentiment analysis *********************** START **********************
|
| 146 |
|
| 147 |
# #create model/token dir for sentiment classification for faster inference
|
| 148 |
-
create_model_dir(chkpt=sent_chkpt, model_dir=sent_mdl_dir,task_type='classification')
|
| 149 |
|
| 150 |
|
| 151 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
|
@@ -156,11 +156,11 @@ def sentiment_task_selected(task,
|
|
| 156 |
sent_onnx_mdl_name=sent_onnx_mdl_name,
|
| 157 |
sent_onnx_quant_mdl_name=sent_onnx_quant_mdl_name):
|
| 158 |
##model & tokenizer initialization for normal sentiment classification
|
| 159 |
-
model_sentiment=AutoModelForSequenceClassification.from_pretrained(sent_mdl_dir)
|
| 160 |
tokenizer_sentiment = AutoTokenizer.from_pretrained(sent_mdl_dir)
|
| 161 |
|
| 162 |
-
# # create onnx model for sentiment classification but once created in your local app comment this out
|
| 163 |
-
create_onnx_model_sentiment(_model=model_sentiment, _tokenizer=tokenizer_sentiment)
|
| 164 |
|
| 165 |
#create inference session
|
| 166 |
sentiment_session = ort.InferenceSession(f"{sent_onnx_mdl_dir}/{sent_onnx_mdl_name}",sess_options=session_options_ort)
|
|
@@ -173,8 +173,8 @@ def sentiment_task_selected(task,
|
|
| 173 |
|
| 174 |
############### Pre-Download & instantiate objects for Zero shot clf NLI *********************** START **********************
|
| 175 |
|
| 176 |
-
# create model/token dir for zeroshot clf -- already created so not required
|
| 177 |
-
create_model_dir(chkpt=zs_chkpt, model_dir=zs_mdl_dir,task_type='classification')
|
| 178 |
|
| 179 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 180 |
def zs_nli_task_selected(task,
|
|
@@ -189,8 +189,8 @@ def zs_nli_task_selected(task,
|
|
| 189 |
# tokenizer_zs=AutoTokenizer.from_pretrained(zs_chkpt)
|
| 190 |
tokenizer_zs = AutoTokenizer.from_pretrained(zs_mdl_dir)
|
| 191 |
|
| 192 |
-
## create onnx model for zeroshot but once created locally comment it out.
|
| 193 |
-
create_onnx_model_zs_nli(zs_chkpt=zs_chkpt,zs_onnx_mdl_dir=zs_onnx_mdl_dir)
|
| 194 |
|
| 195 |
#create inference session from onnx model
|
| 196 |
zs_session = ort.InferenceSession(f"{zs_onnx_mdl_dir}/{zs_onnx_mdl_name}",sess_options=session_options_ort)
|
|
@@ -201,8 +201,9 @@ def zs_nli_task_selected(task,
|
|
| 201 |
|
| 202 |
|
| 203 |
############### Pre-Download & instantiate objects for Zero shot clf NLI *********************** START **********************
|
|
|
|
| 204 |
## create model/token dir for zeroshot clf -- already created so not required
|
| 205 |
-
create_model_dir(chkpt=zs_mlm_chkpt, model_dir=zs_mlm_mdl_dir, task_type='mlm')
|
| 206 |
|
| 207 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 208 |
def zs_mlm_task_selected(task,
|
|
@@ -216,8 +217,8 @@ def zs_mlm_task_selected(task,
|
|
| 216 |
# tokenizer_zs_mlm=AutoTokenizer.from_pretrained(zs_mlm_chkpt)
|
| 217 |
tokenizer_zs_mlm = AutoTokenizer.from_pretrained(zs_mlm_mdl_dir)
|
| 218 |
|
| 219 |
-
# # create onnx model for zeroshot but once created locally comment it out.
|
| 220 |
-
create_onnx_model_zs_mlm(zs_mlm_chkpt=zs_mlm_chkpt,zs_mlm_onnx_mdl_dir=zs_mlm_onnx_mdl_dir)
|
| 221 |
|
| 222 |
# create inference session from onnx model
|
| 223 |
zs_session_mlm = ort.InferenceSession(f"{zs_mlm_onnx_mdl_dir}/{zs_mlm_onnx_mdl_name}", sess_options=session_options_ort)
|
|
|
|
| 145 |
############### Pre-Download & instantiate objects for sentiment analysis *********************** START **********************
|
| 146 |
|
| 147 |
# #create model/token dir for sentiment classification for faster inference
|
| 148 |
+
# create_model_dir(chkpt=sent_chkpt, model_dir=sent_mdl_dir,task_type='classification')
|
| 149 |
|
| 150 |
|
| 151 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
|
|
|
| 156 |
sent_onnx_mdl_name=sent_onnx_mdl_name,
|
| 157 |
sent_onnx_quant_mdl_name=sent_onnx_quant_mdl_name):
|
| 158 |
##model & tokenizer initialization for normal sentiment classification
|
| 159 |
+
# model_sentiment=AutoModelForSequenceClassification.from_pretrained(sent_mdl_dir)
|
| 160 |
tokenizer_sentiment = AutoTokenizer.from_pretrained(sent_mdl_dir)
|
| 161 |
|
| 162 |
+
# # # create onnx model for sentiment classification but once created in your local app comment this out
|
| 163 |
+
# create_onnx_model_sentiment(_model=model_sentiment, _tokenizer=tokenizer_sentiment)
|
| 164 |
|
| 165 |
#create inference session
|
| 166 |
sentiment_session = ort.InferenceSession(f"{sent_onnx_mdl_dir}/{sent_onnx_mdl_name}",sess_options=session_options_ort)
|
|
|
|
| 173 |
|
| 174 |
############### Pre-Download & instantiate objects for Zero shot clf NLI *********************** START **********************
|
| 175 |
|
| 176 |
+
# # create model/token dir for zeroshot clf -- already created so not required
|
| 177 |
+
# create_model_dir(chkpt=zs_chkpt, model_dir=zs_mdl_dir,task_type='classification')
|
| 178 |
|
| 179 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 180 |
def zs_nli_task_selected(task,
|
|
|
|
| 189 |
# tokenizer_zs=AutoTokenizer.from_pretrained(zs_chkpt)
|
| 190 |
tokenizer_zs = AutoTokenizer.from_pretrained(zs_mdl_dir)
|
| 191 |
|
| 192 |
+
# ## create onnx model for zeroshot but once created locally comment it out.
|
| 193 |
+
# create_onnx_model_zs_nli(zs_chkpt=zs_chkpt,zs_onnx_mdl_dir=zs_onnx_mdl_dir)
|
| 194 |
|
| 195 |
#create inference session from onnx model
|
| 196 |
zs_session = ort.InferenceSession(f"{zs_onnx_mdl_dir}/{zs_onnx_mdl_name}",sess_options=session_options_ort)
|
|
|
|
| 201 |
|
| 202 |
|
| 203 |
############### Pre-Download & instantiate objects for Zero shot clf NLI *********************** START **********************
|
| 204 |
+
|
| 205 |
## create model/token dir for zeroshot clf -- already created so not required
|
| 206 |
+
# create_model_dir(chkpt=zs_mlm_chkpt, model_dir=zs_mlm_mdl_dir, task_type='mlm')
|
| 207 |
|
| 208 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True, max_entries=None, ttl=None)
|
| 209 |
def zs_mlm_task_selected(task,
|
|
|
|
| 217 |
# tokenizer_zs_mlm=AutoTokenizer.from_pretrained(zs_mlm_chkpt)
|
| 218 |
tokenizer_zs_mlm = AutoTokenizer.from_pretrained(zs_mlm_mdl_dir)
|
| 219 |
|
| 220 |
+
# # # create onnx model for zeroshot but once created locally comment it out.
|
| 221 |
+
# create_onnx_model_zs_mlm(zs_mlm_chkpt=zs_mlm_chkpt,zs_mlm_onnx_mdl_dir=zs_mlm_onnx_mdl_dir)
|
| 222 |
|
| 223 |
# create inference session from onnx model
|
| 224 |
zs_session_mlm = ort.InferenceSession(f"{zs_mlm_onnx_mdl_dir}/{zs_mlm_onnx_mdl_name}", sess_options=session_options_ort)
|