Update app.py
Browse files
app.py
CHANGED
@@ -357,10 +357,7 @@ def clean_text(text,doc=False,plain_text=False,url=False):
|
|
357 |
|
358 |
return None, clean_text
|
359 |
|
360 |
-
|
361 |
-
sentence_embedding_model = get_sentence_embedding_model()
|
362 |
-
ner_model = get_transformer_pipeline()
|
363 |
-
nlp = get_spacy()
|
364 |
|
365 |
@st.experimental_singleton
|
366 |
def get_spacy():
|
@@ -388,6 +385,11 @@ def get_ner_pipeline():
|
|
388 |
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
389 |
model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
390 |
return pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
#Streamlit App
|
393 |
|
|
|
357 |
|
358 |
return None, clean_text
|
359 |
|
360 |
+
|
|
|
|
|
|
|
361 |
|
362 |
@st.experimental_singleton
|
363 |
def get_spacy():
|
|
|
385 |
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
386 |
model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
387 |
return pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
388 |
+
|
389 |
+
# Load all different models (cached) at start time of the hugginface space
|
390 |
+
sentence_embedding_model = get_sentence_embedding_model()
|
391 |
+
ner_model = get_transformer_pipeline()
|
392 |
+
nlp = get_spacy()
|
393 |
|
394 |
#Streamlit App
|
395 |
|