JUBJAI / personal_info_identifier.py
IS361Group4's picture
Update personal_info_identifier.py
79446df verified
raw
history blame
584 Bytes
import gradio as gr
from transformers import pipeline
# โหลด pipeline
pii_detector = pipeline("token-classification", model="iiiorg/piiranha-v1-detect-personal-information", aggregation_strategy="simple")
def detect_pii(text):
results = pii_detector(text)
return results
def create_personal_info_tab():
with gr.Column():
gr.Markdown("### Detect Personal Information (PII)")
textbox = gr.Textbox(label="Enter text", lines=5)
output = gr.JSON(label="Detected Entities")
textbox.change(fn=detect_pii, inputs=textbox, outputs=output)