Spaces:
Runtime error
Runtime error
Commit
·
90a2a07
1
Parent(s):
9276c0d
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,9 +108,6 @@ def get_pos_arr(input_text,display_area):
|
|
| 108 |
|
| 109 |
def perform_inference(text,display_area):
|
| 110 |
|
| 111 |
-
if (st.session_state['bio_model'] is None):
|
| 112 |
-
display_area.text("Loading model 1 of 3. Bio model...")
|
| 113 |
-
st.session_state['bio_model'] = bd.BatchInference("bio/desc_a100_config.json",'ajitrajasekharan/biomedical',False,False,DEFAULT_TOP_K,True,True, "bio/","bio/a100_labels.txt",False)
|
| 114 |
|
| 115 |
if (st.session_state['phi_model'] is None):
|
| 116 |
display_area.text("Loading model 2 of 3. PHI model...")
|
|
@@ -122,32 +119,22 @@ def perform_inference(text,display_area):
|
|
| 122 |
else:
|
| 123 |
pos_arr = None
|
| 124 |
|
| 125 |
-
if (st.session_state['ner_bio'] is None):
|
| 126 |
-
display_area.text("Initializing BIO module...")
|
| 127 |
-
st.session_state['ner_bio'] = ner.UnsupNER("bio/ner_a100_config.json")
|
| 128 |
|
| 129 |
if (st.session_state['ner_phi'] is None):
|
| 130 |
display_area.text("Initializing PHI module...")
|
| 131 |
st.session_state['ner_phi'] = ner.UnsupNER("bbc/ner_bbc_config.json")
|
| 132 |
|
| 133 |
-
if (st.session_state['aggr'] is None):
|
| 134 |
-
display_area.text("Initializing Aggregation modeule...")
|
| 135 |
-
st.session_state['aggr'] = aggr.AggregateNER("./ensemble_config.json")
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
-
|
| 140 |
-
bio_descs = st.session_state['bio_model'].get_descriptors(text,pos_arr)
|
| 141 |
display_area.text("Getting results from PHI model...")
|
| 142 |
phi_results = st.session_state['phi_model'].get_descriptors(text,pos_arr)
|
| 143 |
display_area.text("Aggregating BIO & PHI results...")
|
| 144 |
-
bio_ner = st.session_state['ner_bio'].tag_sentence_service(text,bio_descs)
|
| 145 |
-
phi_ner = st.session_state['ner_phi'].tag_sentence_service(text,phi_results)
|
| 146 |
|
| 147 |
-
|
| 148 |
|
| 149 |
-
|
| 150 |
-
return aggregate_results
|
| 151 |
|
| 152 |
|
| 153 |
sent_arr = [
|
|
@@ -212,19 +199,12 @@ def main():
|
|
| 212 |
|
| 213 |
init_session_states()
|
| 214 |
|
| 215 |
-
st.markdown("<h3 style='text-align: center;'>NER using pretrained models with <a href='https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html'>no fine tuning</a
|
| 216 |
-
|
| 217 |
-
#<h3 style="font-size:16px; color: #ff0000; text-align: center"><b>App under construction... (not in working condition yet)</b></h3>
|
| 218 |
-
#""", unsafe_allow_html=True)
|
| 219 |
|
| 220 |
|
| 221 |
-
st.markdown("""
|
| 222 |
-
<p style="text-align:center;"><img src="https://ajitrajasekharan.github.io/images/1.png" width="700"></p>
|
| 223 |
-
<br/>
|
| 224 |
-
<br/>
|
| 225 |
-
""", unsafe_allow_html=True)
|
| 226 |
|
| 227 |
-
st.write("This app uses
|
| 228 |
|
| 229 |
|
| 230 |
with st.form('my_form'):
|
|
@@ -254,7 +234,7 @@ def main():
|
|
| 254 |
# )
|
| 255 |
|
| 256 |
st.markdown("""
|
| 257 |
-
<small style="font-size:16px; color: #7f7f7f; text-align: left"><br/><br/>Models used: <br/>(1)
|
| 258 |
#""", unsafe_allow_html=True)
|
| 259 |
st.markdown("""
|
| 260 |
<h3 style="font-size:16px; color: #9f9f9f; text-align: center"><b> <a href='https://huggingface.co/spaces/ajitrajasekharan/Qualitative-pretrained-model-evaluation' target='_blank'>App link to examine pretrained models</a> used to perform NER without fine tuning</b></h3>
|
|
|
|
| 108 |
|
| 109 |
def perform_inference(text,display_area):
|
| 110 |
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
if (st.session_state['phi_model'] is None):
|
| 113 |
display_area.text("Loading model 2 of 3. PHI model...")
|
|
|
|
| 119 |
else:
|
| 120 |
pos_arr = None
|
| 121 |
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
if (st.session_state['ner_phi'] is None):
|
| 124 |
display_area.text("Initializing PHI module...")
|
| 125 |
st.session_state['ner_phi'] = ner.UnsupNER("bbc/ner_bbc_config.json")
|
| 126 |
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
+
|
|
|
|
| 131 |
display_area.text("Getting results from PHI model...")
|
| 132 |
phi_results = st.session_state['phi_model'].get_descriptors(text,pos_arr)
|
| 133 |
display_area.text("Aggregating BIO & PHI results...")
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
phi_ner = st.session_state['ner_phi'].tag_sentence_service(text,phi_results)
|
| 136 |
|
| 137 |
+
return phi_ner
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
sent_arr = [
|
|
|
|
| 199 |
|
| 200 |
init_session_states()
|
| 201 |
|
| 202 |
+
st.markdown("<h3 style='text-align: center;'>NER using pretrained models with <a href='https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html'>no fine tuning</a><br/><br/></h3>", unsafe_allow_html=True)
|
| 203 |
+
|
|
|
|
|
|
|
| 204 |
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
st.write("This app uses 2 models. Bert-base-cased(**no fine tuning**) and a POS tagger")
|
| 208 |
|
| 209 |
|
| 210 |
with st.form('my_form'):
|
|
|
|
| 234 |
# )
|
| 235 |
|
| 236 |
st.markdown("""
|
| 237 |
+
<small style="font-size:16px; color: #7f7f7f; text-align: left"><br/><br/>Models used: <br/>(1) Bert-base-cased (for PHI entities - Person/location/organization etc.)<br/>(2) Flair POS tagger</small>
|
| 238 |
#""", unsafe_allow_html=True)
|
| 239 |
st.markdown("""
|
| 240 |
<h3 style="font-size:16px; color: #9f9f9f; text-align: center"><b> <a href='https://huggingface.co/spaces/ajitrajasekharan/Qualitative-pretrained-model-evaluation' target='_blank'>App link to examine pretrained models</a> used to perform NER without fine tuning</b></h3>
|