Views
No views yet
image/layoutlmv3/ — a text-in-image classifier for text PII in
images (47 categories), run on Tesseract OCR words.image/yolo/best.pt — a detector for visual entities (signature,
seal/stamp, QR/barcode, face photo, fingerprint, logo).text/minilm/ — a lightweight multilingual classifier for PII in
plain text (no image, no OCR).1pip install "document-pii-redactor[visual]" # full pipeline, used by the examples below (AGPL-3.0 — see License below)
2pip install document-pii-redactor # text pipeline + built-in OCR only, no visual entities (permissive licenses)ImagePIIRedactor detects visual entities by default — PII that is an
image region rather than readable text: signatures, seals/stamps,
QR codes/barcodes, face photos, fingerprints, and logos. That detector
needs the [visual] extra, so the image examples below assume it — or
pass detect_visual=False to detect only text PII on the core install.detect(..., words=..., boxes=...)).1# Debian/Ubuntu
2sudo apt-get install -y tesseract-ocr
3# macOS
4brew install tesseractdetect() is the core primitive — it finds every PII entity with its
location, category, and confidence, and runs the models exactly once. The
transforms (redact / anonymize / de-identify) take its result as a required
argument: detect once, feed the result to any transform.1from document_pii_redactor import ImagePIIRedactor, TextPIIRedactor
2
3image_redactor = ImagePIIRedactor("ekacare/document-pii-redactor")
4entities = image_redactor.detect("page.jpg") # built-in Tesseract OCR
5# each entity: kind ("text"/"visual"), category, bbox (pixels), text, score
6
7# …or bring your own OCR — pass words + pixel boxes, Tesseract is skipped
8# and your exact boxes come back on the detected entities:
9entities = image_redactor.detect("page.jpg", words=["John", "Doe"],
10 boxes=[[100, 20, 140, 40], [145, 20, 180, 40]])
11
12text_redactor = TextPIIRedactor("ekacare/document-pii-redactor")
13text = "Mr. John Doe, 45 yrs, DOB 12-03-1979, Indiranagar, Bangalore. Contact: +91 98765 43210."
14spans = text_redactor.detect(text) # char-offset spans1image_redactor.redact("page.jpg", entities, mode="blur").save("redacted.png") # or "solid" / "pixelate"
2
3text_redactor.redact(text, spans)
4# '[REDACTED], [REDACTED] yrs, DOB [REDACTED], [REDACTED], [REDACTED]. Contact: [REDACTED].'[LOCATION]
(state and country survive), everything else becomes an unnumbered token;
faces/signatures are filled solid:1image_redactor.anonymize("page.jpg", entities).save("anonymized.png")
2
3text_redactor.anonymize(text, spans)
4# '[PERSON], 40–49 yrs, DOB 1979, [LOCATION], [LOCATION]. Contact: [PHONE].'strategy="hash" gives globally deterministic tokens that stay stable across
documents with no mapping to thread (secret= salts the hash so guessable
values can't be dictionary-reversed):1deid = image_redactor.deidentify("page.jpg", entities) # .image + .mapping
2deid.image.save("deidentified.png")
3
4text_redactor.deidentify(text, spans).text
5# 'Person_1, Age_1 yrs, DOB Date_1, City_1, City_2. Contact: Phone_1.'
6
7text_redactor.deidentify(text, spans, strategy="hash").text
8# 'Person_539681, Age_6c8349 yrs, DOB Date_7f19c4, City_d12704, City_60c7d5. Contact: Phone_d57003.'categories=[...] on detect() limits which of the 53 PII categories are
found (default: all); detect_visual=False on ImagePIIRedactor skips the
visual-entity detector entirely.mapping — pass
mapping=result.mapping on the next page of the same record to keep
numbering consistent. Hash tokens need no threading.quickstart.ipynb and
byo_ocr_nemotron.ipynb — the full
API reference, the category taxonomy, and the Docker/FastAPI deployment setup
(the same setup behind the demo Space above).| weights | fine-tuned from | license |
|---|---|---|
text/minilm/ | Multilingual MiniLM (MIT) | CC-BY-4.0 — free use incl. commercial; credit Eka Care with a link back |
image/layoutlmv3/ | microsoft/layoutlmv3-base (CC-BY-NC-SA-4.0) | CC-BY-NC-SA-4.0 — non-commercial use only, ShareAlike |
image/yolo/best.pt | YOLO11m (Ultralytics, AGPL-3.0) | AGPL-3.0 |
TextPIIRedactor) has a
fully permissive lineage and may be used commercially with attribution.
The image pipeline currently inherits its bases' restrictions — no
commercial use of the LayoutLMv3 fine-tune, and AGPL obligations for the
visual detector (the ultralytics runtime it needs is also AGPL-3.0 and
is an optional [visual] extra of the pip package).1@software{document_pii_redactor,
2 author = {{Eka Care}},
3 title = {document-pii-redactor: detect, redact, de-identify, or anonymize
4 PII in document images and plain text},
5 year = {2026},
6 url = {https://github.com/eka-care/document-pii-redactor},
7 note = {Model weights: https://huggingface.co/ekacare/document-pii-redactor}
8}