Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,9 @@ import streamlit.components.v1 as components
|
|
| 9 |
from annotated_text import annotated_text
|
| 10 |
from streamlit_tags import st_tags
|
| 11 |
from PyPDF2 import PdfReader, PdfWriter
|
| 12 |
-
from
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
anonymize,
|
| 16 |
-
annotate,
|
| 17 |
-
analyzer_engine,
|
| 18 |
-
)
|
| 19 |
|
| 20 |
st.set_page_config(
|
| 21 |
page_title="Presidio PHI De-identification",
|
|
@@ -53,7 +49,7 @@ st.sidebar.markdown(f"[View model on HuggingFace]({selected_model_url})")
|
|
| 53 |
st_model_package = st_model.split("/")[0]
|
| 54 |
st_model = st_model if st_model_package.lower() not in ("spacy", "huggingface") else "/".join(st_model.split("/")[1:])
|
| 55 |
|
| 56 |
-
analyzer_params = (st_model_package, st_model
|
| 57 |
st.sidebar.warning("Note: Models might take some time to download.")
|
| 58 |
|
| 59 |
st_operator = st.sidebar.selectbox(
|
|
@@ -97,7 +93,7 @@ with col1:
|
|
| 97 |
# Analyze
|
| 98 |
analyzer = analyzer_engine(*analyzer_params)
|
| 99 |
st_analyze_results = analyze(
|
| 100 |
-
|
| 101 |
text=text,
|
| 102 |
entities=get_supported_entities(*analyzer_params),
|
| 103 |
language="en",
|
|
@@ -115,10 +111,12 @@ with col1:
|
|
| 115 |
st.info("No PHI detected")
|
| 116 |
|
| 117 |
# Anonymize
|
|
|
|
| 118 |
anonymized_result = anonymize(
|
| 119 |
text=text,
|
| 120 |
operator=st_operator,
|
| 121 |
analyze_results=st_analyze_results,
|
|
|
|
| 122 |
)
|
| 123 |
|
| 124 |
# Create new PDF
|
|
|
|
| 9 |
from annotated_text import annotated_text
|
| 10 |
from streamlit_tags import st_tags
|
| 11 |
from PyPDF2 import PdfReader, PdfWriter
|
| 12 |
+
from presidio_analyzer import AnalyzerEngine, RecognizerRegistry
|
| 13 |
+
from presidio_anonymizer import AnonymizerEngine
|
| 14 |
+
from presidio_helpers import get_supported_entities, analyze, anonymize
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
st.set_page_config(
|
| 17 |
page_title="Presidio PHI De-identification",
|
|
|
|
| 49 |
st_model_package = st_model.split("/")[0]
|
| 50 |
st_model = st_model if st_model_package.lower() not in ("spacy", "huggingface") else "/".join(st_model.split("/")[1:])
|
| 51 |
|
| 52 |
+
analyzer_params = (st_model_package, st_model)
|
| 53 |
st.sidebar.warning("Note: Models might take some time to download.")
|
| 54 |
|
| 55 |
st_operator = st.sidebar.selectbox(
|
|
|
|
| 93 |
# Analyze
|
| 94 |
analyzer = analyzer_engine(*analyzer_params)
|
| 95 |
st_analyze_results = analyze(
|
| 96 |
+
analyzer,
|
| 97 |
text=text,
|
| 98 |
entities=get_supported_entities(*analyzer_params),
|
| 99 |
language="en",
|
|
|
|
| 111 |
st.info("No PHI detected")
|
| 112 |
|
| 113 |
# Anonymize
|
| 114 |
+
anonymizer = AnonymizerEngine()
|
| 115 |
anonymized_result = anonymize(
|
| 116 |
text=text,
|
| 117 |
operator=st_operator,
|
| 118 |
analyze_results=st_analyze_results,
|
| 119 |
+
anonymizer=anonymizer,
|
| 120 |
)
|
| 121 |
|
| 122 |
# Create new PDF
|