mr4 commited on
Commit
f6bb879
·
verified ·
1 Parent(s): 519a93c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Tải pipeline NER
5
+ ner_model = pipeline("ner", model="mr4/pii-ner-vi")
6
+
7
+
8
+ def ner_predict(text):
9
+ entities = ner_model(text)
10
+ result = ""
11
+ for ent in entities:
12
+ result += f"{ent['word']} ({ent['entity_group']}) - Score: {ent['score']:.2f}\n"
13
+ return result
14
+
15
+ # Tạo giao diện
16
+ demo = gr.Interface(
17
+ fn=ner_predict,
18
+ inputs=gr.Textbox(lines=5, placeholder="Nhập văn bản tiếng Anh..."),
19
+ outputs="text",
20
+ title="Named Entity Recognition Demo",
21
+ description="Ứng dụng nhận dạng thực thể sử dụng mô hình BERT fine-tuned trên tập dữ liệu CoNLL-2003."
22
+ )
23
+
24
+ # Chạy ứng dụng
25
+ demo.launch()