Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,13 @@ from transformers import AutoTokenizer, AutoModelForTokenClassification, pipelin
|
|
6 |
import spacy
|
7 |
from spacy import displacy
|
8 |
|
9 |
-
#
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# โหลดโมเดล NER จาก Hugging Face
|
13 |
model_name = "Nucha/Nucha_SkillNER_BERT"
|
@@ -18,7 +23,7 @@ model = AutoModelForTokenClassification.from_pretrained(model_name)
|
|
18 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
19 |
|
20 |
# UI ด้วย Streamlit
|
21 |
-
st.title("NER Analysis with Nucha SkillNER BERT and displacy")
|
22 |
|
23 |
text = st.text_area("Enter text for NER analysis:")
|
24 |
|
|
|
6 |
import spacy
|
7 |
from spacy import displacy
|
8 |
|
9 |
+
# ตรวจสอบว่ามีการติดตั้งโมเดล spacy หรือไม่
|
10 |
+
try:
|
11 |
+
nlp = spacy.load("en_core_web_sm")
|
12 |
+
except OSError:
|
13 |
+
import os
|
14 |
+
os.system("python -m spacy download en_core_web_sm")
|
15 |
+
nlp = spacy.load("en_core_web_sm")
|
16 |
|
17 |
# โหลดโมเดล NER จาก Hugging Face
|
18 |
model_name = "Nucha/Nucha_SkillNER_BERT"
|
|
|
23 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
24 |
|
25 |
# UI ด้วย Streamlit
|
26 |
+
st.title("NER Analysis with Nucha SkillNER BERT and spacy displacy")
|
27 |
|
28 |
text = st.text_area("Enter text for NER analysis:")
|
29 |
|