ajitrajasekharan commited on
Commit
d1357c0
·
1 Parent(s): 25d10c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -6,7 +6,7 @@ import string
6
  bert_tokenizer = None
7
  bert_model = None
8
  top_k = 20
9
- model_name = None
10
 
11
  from transformers import BertTokenizer, BertForMaskedLM
12
 
@@ -123,10 +123,9 @@ def on_model_change2():
123
  bert_tokenizer, bert_model = load_bert_model(model_name)
124
 
125
  def init_selectbox():
126
- option = st.selectbox(
127
  'Choose any of these sentences or type any text below',
128
  ('', "[MASK] who lives in New York and works for XCorp suffers from Parkinson's", "Lou Gehrig who lives in [MASK] and works for XCorp suffers from Parkinson's","Lou Gehrig who lives in New York and works for [MASK] suffers from Parkinson's","Lou Gehrig who lives in New York and works for XCorp suffers from [MASK]","[MASK] who lives in New York and works for XCorp suffers from Lou Gehrig's", "Parkinson who lives in [MASK] and works for XCorp suffers from Lou Gehrig's","Parkinson who lives in New York and works for [MASK] suffers from Lou Gehrig's","Parkinson who lives in New York and works for XCorp suffers from [MASK]","Lou Gehrig","Parkinson","Lou Gehrigh's is a [MASK]","Parkinson is a [MASK]","New York is a [MASK]","New York","XCorp","XCorp is a [MASK]","acute lymphoblastic leukemia","acute lymphoblastic leukemia is a [MASK]"),on_change=on_option_change,key='my_choice')
129
- return option
130
 
131
 
132
 
@@ -154,14 +153,14 @@ def main():
154
  # with st.spinner("Computing"):
155
  try:
156
 
157
- model_name = st.sidebar.selectbox(label='Select Model to Apply', options=['ajitrajasekharan/biomedical', 'bert-base-cased','bert-large-cased','microsoft/BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext','allenai/scibert_scivocab_cased','dmis-lab/biobert-v1.1'], index=0, key = "my_model1",on_change=on_model_change1)
158
- option = init_selectbox()
159
- input_text = st.text_input("Enter text below", "",on_change=on_text_change,key='my_text')
160
- custom_model_name = st.text_input("Model not listed on left? Type the model name (fill-mask BERT models only)", "",key="my_model2",on_change=on_model_change2)
161
- if (len(custom_model_name) > 0):
162
- model_name = custom_model_name
163
- st.info("Custom model selected: " + model_name)
164
- bert_tokenizer, bert_model = load_bert_model(model_name)
165
  #if len(input_text) > 0:
166
  # run_test(input_text,top_k,model_name)
167
  #else:
 
6
  bert_tokenizer = None
7
  bert_model = None
8
  top_k = 20
9
+ model_name = 'ajitrajasekharan/biomedical'
10
 
11
  from transformers import BertTokenizer, BertForMaskedLM
12
 
 
123
  bert_tokenizer, bert_model = load_bert_model(model_name)
124
 
125
  def init_selectbox():
126
+ st.selectbox(
127
  'Choose any of these sentences or type any text below',
128
  ('', "[MASK] who lives in New York and works for XCorp suffers from Parkinson's", "Lou Gehrig who lives in [MASK] and works for XCorp suffers from Parkinson's","Lou Gehrig who lives in New York and works for [MASK] suffers from Parkinson's","Lou Gehrig who lives in New York and works for XCorp suffers from [MASK]","[MASK] who lives in New York and works for XCorp suffers from Lou Gehrig's", "Parkinson who lives in [MASK] and works for XCorp suffers from Lou Gehrig's","Parkinson who lives in New York and works for [MASK] suffers from Lou Gehrig's","Parkinson who lives in New York and works for XCorp suffers from [MASK]","Lou Gehrig","Parkinson","Lou Gehrigh's is a [MASK]","Parkinson is a [MASK]","New York is a [MASK]","New York","XCorp","XCorp is a [MASK]","acute lymphoblastic leukemia","acute lymphoblastic leukemia is a [MASK]"),on_change=on_option_change,key='my_choice')
 
129
 
130
 
131
 
 
153
  # with st.spinner("Computing"):
154
  try:
155
 
156
+ st.sidebar.selectbox(label='Select Model to Apply', options=['ajitrajasekharan/biomedical', 'bert-base-cased','bert-large-cased','microsoft/BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext','allenai/scibert_scivocab_cased','dmis-lab/biobert-v1.1'], index=0, key = "my_model1",on_change=on_model_change1)
157
+ init_selectbox()
158
+ st.text_input("Enter text below", "",on_change=on_text_change,key='my_text')
159
+ st.text_input("Model not listed on left? Type the model name (fill-mask BERT models only)", "",key="my_model2",on_change=on_model_change2)
160
+ #if (len(custom_model_name) > 0):
161
+ # model_name = custom_model_name
162
+ # st.info("Custom model selected: " + model_name)
163
+ # bert_tokenizer, bert_model = load_bert_model(model_name)
164
  #if len(input_text) > 0:
165
  # run_test(input_text,top_k,model_name)
166
  #else: