Spaces:
Running
Running
Commit
·
592fb56
1
Parent(s):
067c9fa
logging steps removed
Browse files
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
import logging
|
2 |
-
import logging.config
|
3 |
import re
|
4 |
from pathlib import Path
|
5 |
|
@@ -12,16 +10,6 @@ import yaml
|
|
12 |
import pteredactyl as pt
|
13 |
from pteredactyl.defaults import change_model
|
14 |
|
15 |
-
# Logging configuration. This is only done at root level
|
16 |
-
logging_config = yaml.safe_load(Path("logging.yaml").read_text())
|
17 |
-
logging.config.dictConfig(logging_config)
|
18 |
-
|
19 |
-
# Get the logger
|
20 |
-
log = logging.getLogger(__name__)
|
21 |
-
|
22 |
-
# Load the model
|
23 |
-
log.info("Starting App")
|
24 |
-
|
25 |
sample_text = """
|
26 |
1. Dr. Huntington (Patient No: 1234567890) diagnosed Ms. Alzheimer with Alzheimer's disease during her last visit to the Huntington Medical Center on 12/12/2023. The prognosis was grim, but Dr. Huntington assured Ms. Alzheimer that the facility was well-equipped to handle her condition despite the lack of a cure for Alzheimer's.
|
27 |
|
@@ -80,9 +68,6 @@ def redact(text: str, model_name: str):
|
|
80 |
|
81 |
model_path = model_paths.get(model_name, "StanfordAIMI/stanford-deidentifier-base")
|
82 |
|
83 |
-
# Log the model being changed to
|
84 |
-
log.info(f"Changing to model: {model_path}")
|
85 |
-
|
86 |
if model_path:
|
87 |
change_model(model_path)
|
88 |
else:
|
@@ -271,12 +256,6 @@ def redact_and_visualize(text: str, model_name: str):
|
|
271 |
reference_text, redacted_text
|
272 |
)
|
273 |
|
274 |
-
# Print the final texts with flags for debugging
|
275 |
-
log.debug("Final Reference Text with False Negatives:")
|
276 |
-
log.debug(reference_text_with_fn)
|
277 |
-
log.debug("\nFinal Redacted Text with False Positives:")
|
278 |
-
log.debug(redacted_text_with_fp)
|
279 |
-
|
280 |
# Count entities and compute metrics
|
281 |
tp_count, fn_count, fp_count, tn_count = count_entities_and_compute_metrics(
|
282 |
reference_text_with_fn, redacted_text_with_fp
|
|
|
|
|
|
|
1 |
import re
|
2 |
from pathlib import Path
|
3 |
|
|
|
10 |
import pteredactyl as pt
|
11 |
from pteredactyl.defaults import change_model
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
sample_text = """
|
14 |
1. Dr. Huntington (Patient No: 1234567890) diagnosed Ms. Alzheimer with Alzheimer's disease during her last visit to the Huntington Medical Center on 12/12/2023. The prognosis was grim, but Dr. Huntington assured Ms. Alzheimer that the facility was well-equipped to handle her condition despite the lack of a cure for Alzheimer's.
|
15 |
|
|
|
68 |
|
69 |
model_path = model_paths.get(model_name, "StanfordAIMI/stanford-deidentifier-base")
|
70 |
|
|
|
|
|
|
|
71 |
if model_path:
|
72 |
change_model(model_path)
|
73 |
else:
|
|
|
256 |
reference_text, redacted_text
|
257 |
)
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
# Count entities and compute metrics
|
260 |
tp_count, fn_count, fp_count, tn_count = count_entities_and_compute_metrics(
|
261 |
reference_text_with_fn, redacted_text_with_fp
|