Spaces:
Sleeping
Sleeping
Update personal_info_identifier.py
Browse files- personal_info_identifier.py +14 -1
personal_info_identifier.py
CHANGED
@@ -1,3 +1,16 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|