Update app.py
Browse files
app.py
CHANGED
|
@@ -15,20 +15,7 @@ st.write("This tool lets you extract relation triples concerning interactions be
|
|
| 15 |
st.write("It is the result of an end of studies project within ESI school and dedicated to biomedical researchers looking to extract precise information about the subject without digging into long publications.")
|
| 16 |
|
| 17 |
|
| 18 |
-
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None})
|
| 19 |
-
def load_tokenizer():
|
| 20 |
-
return AutoTokenizer.from_pretrained("dmis-lab/biobert-large-cased-v1.1", truncation = True, padding=True, model_max_length=512,)
|
| 21 |
-
|
| 22 |
-
tokenizer = load_tokenizer()
|
| 23 |
|
| 24 |
-
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None})
|
| 25 |
-
def load_modelNER(tokenizer):
|
| 26 |
-
model_checkpoint = BertForTokenClassification.from_pretrained("dexay/Ner2HgF", )
|
| 27 |
-
return pipeline("token-classification", tokenizer = tokenizer,model=model_checkpoint, )
|
| 28 |
-
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None})
|
| 29 |
-
def load_modelRE(tokenizer):
|
| 30 |
-
model_re = AutoModelForSequenceClassification.from_pretrained("dexay/reDs3others", )
|
| 31 |
-
return pipeline("text-classification", tokenizer = tokenizer,model=model_re, )
|
| 32 |
|
| 33 |
form = st.form(key='my-form')
|
| 34 |
x = form.text_area('Enter text', height=250)
|
|
@@ -42,10 +29,11 @@ if submit and len(x) != 0:
|
|
| 42 |
#model.to("cpu")
|
| 43 |
st.text("Execution is in progress ...")
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
|
| 51 |
|
|
@@ -190,7 +178,7 @@ if submit and len(x) != 0:
|
|
| 190 |
|
| 191 |
# Relation extraction part
|
| 192 |
|
| 193 |
-
|
| 194 |
|
| 195 |
rrdata = lstSentEnc
|
| 196 |
|
|
|
|
| 15 |
st.write("It is the result of an end of studies project within ESI school and dedicated to biomedical researchers looking to extract precise information about the subject without digging into long publications.")
|
| 16 |
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
form = st.form(key='my-form')
|
| 21 |
x = form.text_area('Enter text', height=250)
|
|
|
|
| 29 |
#model.to("cpu")
|
| 30 |
st.text("Execution is in progress ...")
|
| 31 |
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained("dmis-lab/biobert-large-cased-v1.1", truncation = True, padding=True, model_max_length=512,)
|
| 33 |
+
model_checkpoint = BertForTokenClassification.from_pretrained("dexay/Ner2HgF", )
|
| 34 |
+
model_re = AutoModelForSequenceClassification.from_pretrained("dexay/reDs3others", )
|
| 35 |
|
| 36 |
+
token_classifier = pipeline("token-classification", tokenizer = tokenizer,model=model_checkpoint, )
|
| 37 |
|
| 38 |
|
| 39 |
|
|
|
|
| 178 |
|
| 179 |
# Relation extraction part
|
| 180 |
|
| 181 |
+
token_classifier = pipeline("text-classification", tokenizer = tokenizer,model=model_re, )
|
| 182 |
|
| 183 |
rrdata = lstSentEnc
|
| 184 |
|