IS361Group4 commited on
Commit
79446df
·
verified ·
1 Parent(s): 26ae3e0

Update personal_info_identifier.py

Browse files
Files changed (1) hide show
  1. personal_info_identifier.py +14 -1
personal_info_identifier.py CHANGED
@@ -1,3 +1,16 @@
1
  import gradio as gr
 
2
 
3
- gr.load("models/iiiorg/piiranha-v1-detect-personal-information")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # โหลด pipeline
5
+ pii_detector = pipeline("token-classification", model="iiiorg/piiranha-v1-detect-personal-information", aggregation_strategy="simple")
6
+
7
+ def detect_pii(text):
8
+ results = pii_detector(text)
9
+ return results
10
+
11
+ def create_personal_info_tab():
12
+ with gr.Column():
13
+ gr.Markdown("### Detect Personal Information (PII)")
14
+ textbox = gr.Textbox(label="Enter text", lines=5)
15
+ output = gr.JSON(label="Detected Entities")
16
+ textbox.change(fn=detect_pii, inputs=textbox, outputs=output)