Redact personally identifiable information (PII) from documents (PDF, PNG, JPG), Word files (DOCX), or tabular data (XLSX/CSV/Parquet). Please see the User Guide for a full walkthrough of all the features in the app.
Follow these instructions to get the document redaction application running on your local machine.
Clone the repository and install in editable mode:
git clone https://github.com/seanpedrick-case/doc_redaction.git
cd doc_redaction
pip install -e .
To install with PaddleOCR (with a transformers backend as of v2.4.0):
pip install -e ".[paddle]"
If you want to run VLMs / LLMs with the transformers package:
pip install -e ".[vlm]"
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the GPU-enabled version of torch, it is advised to install the following version:
pip install torch==2.13.0 torchvision==0.28.0 --index-url https://download.pytorch.org/whl/cu130
Create a virtual environment (recommended) and install doc_redaction.
python -m venv venv
# Windows:
.\venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
The package is published on PyPI as doc-redaction (import name doc_redaction):
pip install doc_redaction
Optional extras (same as in pyproject.toml). For installing paddleOCR:
pip install "doc_redaction[paddle]"
For running VLMs / LLMs with the transformers package:
pip install "doc_redaction[vlm]"
For programmatic use (CLI-first API matching Gradio api_name routes), see Python Package usage (Python). The console script cli_redact is available after install.
Web UI from a PyPI install: You can start the Gradio UI after pip install doc_redaction by running (note that the prerequisites tesseract and poppler will need to be correctly installed following step 2 below):
python -m app
Important: your working directory matters. When you run python -m app, the app treats your current folder as the “app folder”:
config/app_config.env relative to the folder you run it from (and python -m doc_redaction.install_deps will also write config/app_config.env there).config/, output/, input/, logs/, usage/, feedback/, and temporary/cache folders depending on your settings).doc_redaction package). If you run from a “random” directory after a PyPI install, the app can still locate its packaged examples; your working directory mainly affects where config/, input/, output/, logs, and temp folders are created.In practice, the smoothest UI experience (examples, bundled assets, docs links, predictable relative paths) is still usually via a repository checkout or Docker, but PyPI install is sufficient to launch the UI as long as you run it from a suitable working folder and have the system dependencies available (or run python -m doc_redaction.install_deps first).
The doc_redaction Redaction app can be installed by using the Dockerfile or Docker compose files (llama.cpp, vLLM) provided in the repo.
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by llama.cpp, or vLLM. Llama.cpp is more flexible than vLLM for low VRAM systems, as Llama.cpp will offload to cpu/system RAM automatically rather than failing as vLLM tends to do.
For Llama.cpp, you can use the docker-compose_llama.yml file, and for vLLM, you can use the docker-compose_vllm.yml file. To run, Docker / Docker Desktop should be installed, and then you can run the commands suggested in the top of the files to run the servers.
You will need ~40 GB of disk space to run everything depending on the model chosen from the compose file. For the vLLM server, you will need 24 GB VRAM. For the Llama.cpp server, 24 GB VRAM is needed to run at full speed, but the n-gpu-layers and n-cpu-moe parameters in the Docker compose file can be adjusted to fit into your system. I would suggest that 8 GB VRAM is needed as a bare minimum for decent inference speed. See the Unsloth guide for more details on working with GGUF files for Qwen 3.5.
If you want a working Docker installation without GPU support, you can install from the Dockerfile in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on Hugging Face. You can adjust the INSTALL_PADDLEOCR, PADDLE_GPU_ENABLED, INSTALL_VLM, and TORCH_GPU_ENABLED config variables to adjust for PaddleOCR and Transformers packages for local VLM support. Note that GPU-enabled PaddleOCR, and GPU-enabled Transformers/Torch often don't work well together, which is one reason why a Llama.cpp/vLLM inference server Docker installation option is provided below.
The main Dockerfile produces two final images via build targets: gradio (default web UI, non-root user, named volumes for writable paths) and lambda (AWS Lambda handler). Build examples:
docker build -f Dockerfile --target gradio -t doc-redaction-gradio .
docker build -f Dockerfile --target lambda -t doc-redaction-lambda .
The agent-redact/ folder adds a separate Gradio UI that orchestrates redaction (Pass 1 review CSV, optional Pass 2 VLM, /review_apply) against the main doc_redaction app. Heavy OCR and PII detection stay in the main app; the agent UI only drives the workflow.
Choose the orchestration backend with AGENT_ORCHESTRATOR in config/agent.env (copy from config/agent.env.example):
AGENT_ORCHESTRATOR | Runtime | Typical use |
|---|---|---|
pi (default) | Pi coding agent (pi --mode rpc) | Full bash + skills; Hugging Face Space; local Docker / ECS |
langgraph | LangGraph ReAct agent in redaction_langgraph/ | Same Docker image as Pi; curated Python tools only (no shell); local llama.cpp, Gemini, or Bedrock |
agentcore | Amazon Bedrock AgentCore Runtime | Managed AWS runtime wrapping the LangGraph bundle; the Gradio UI proxies prompts via AGENTCORE_RUNTIME_URL |
agentcore-harness | Bedrock AgentCore Harness | Console-managed loop (AGENTCORE_HARNESS_ARN); Pi-like skills/shell; S3 file bridge for uploads |
The Gradio agent UI and the Pi / LangGraph in-container runtimes share one multi-stage image at agent-redact/pi-agent/Dockerfile. It uses the same Python 3.12 slim base as the main app; a small Node stage installs the pi CLI, which is copied into the runtime image.
| Build target | Typical use |
|---|---|
dev | Local development with docker-compose_llama_agentic.yml — the repo is bind-mounted; only Pi CLI + Python deps are in the image. |
runtime | Hugging Face Space and AWS ECS — agent code is baked in; runs as non-root user with named volumes for workspace, uploads, and session dirs (read-only root filesystem friendly). |
Build from the repository root:
docker build -f agent-redact/pi-agent/Dockerfile --target dev -t pi-agent-dev .
docker build -f agent-redact/pi-agent/Dockerfile --target runtime -t pi-agent-runtime .
LangGraph (in-container). Set AGENT_ORCHESTRATOR=langgraph in config/agent.env (or compose) and start the same pi-agent service as for Pi. Optional: LANGGRAPH_REQUIRE_REVIEW_APPROVAL=true to gate /review_apply until the agent calls an explicit approve tool. A headless Pass 1 spike is python agent-redact/redaction_langgraph/headless_pass1.py --pdf path/to.pdf --direct-tool. Optional tracing (Arize AX / Phoenix) lives under agent-redact/eval/.
Bedrock AgentCore. Deploy the LangGraph agent as a managed runtime, then point the Gradio UI at it:
AGENT_ORCHESTRATOR=agentcore
AGENTCORE_RUNTIME_URL=https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<URL-encoded-ARN>
The CDK demo installer can also build an ARM64 runtime image and create the AgentCore resource (python cdk/cdk_install.py --profile demo --enable-agentic --enable-agentcore-cdk-deploy). For a console Harness instead of the LangGraph bundle, use AGENT_ORCHESTRATOR=agentcore-harness with AGENTCORE_HARNESS_ARN. Full deploy, auth, and troubleshooting: agent-redact/agentcore/README.md.
For llama.cpp + the agent UI together, see the compose examples at the top of docker-compose_llama_agentic.yml. Layout of the agent tree: agent-redact/README.md. LLM providers, env vars, and Gradio usage: agent-redact/pi/agent/README.md.
The repo contains a CDK folder, that contains all the files you need to setup and deploy to an AWS environment with CDK. The installation wizard is cdk_install.py, which provides a number of options to deploy the Document Redaction App to AWS for demonstration or production. CDK-specific notes (including CloudFront CSP/CORS and the post-deploy refresh deploy) are in cdk/README.md. More details on CDK deployment can be found in the Installation Guide.
This application relies on two external tools for OCR (Tesseract) and PDF processing (Poppler). If not using a Docker-based deployment, you will need to install them on your system before proceeding. To run the Document Redaction app successfully, these tools need to be installed and either 1. added to PATH, or 2. be in a folder that is directly referenced in the config/app_config.env file with the variables TESSERACT_FOLDER and POPPLER_FOLDER (defined here if you want to see the code). The instructions below will guide you through different ways to install these dependencies.
If you don’t have admin rights (or you just want the simplest setup), you can have the project download and configure Tesseract and Poppler into a local redaction_deps/ folder inside the doc_redaction folder.
You need the installer script available first, which means either:
git clone ... and run the command from the repo root (recommended for the web UI), orpip install doc_redaction and run from a writable folder where you want redaction_deps/ and config/app_config.env to be created/updated.From the repository root (or your chosen working folder) after creating/activating your venv and installing Python requirements:
python -m doc_redaction.install_deps
This writes TESSERACT_FOLDER / POPPLER_FOLDER into config/app_config.env so the app can find the binaries without you editing your system PATH.
To just check whether your machine can already see the tools:
python -m doc_redaction.install_deps --verify-only
If you don’t use the automated setup above, you can install the dependencies manually by downloading installers and adding the programs to your system's PATH.
Install Tesseract OCR:
tesseract-ocr-w64-setup-v5.X.X...exe).Install Poppler:
.zip file (e.g., poppler-25.07.0-win.zip).C:\Program Files\poppler\.bin folder from your Poppler installation to your system's PATH environment variable.
Path variable, then click "Edit...".bin directory inside your Poppler folder (e.g., C:\Program Files\poppler\poppler-24.02.0\bin).To verify, open a new Command Prompt and run tesseract --version and pdftoppm -v. If they both return version information, you have successfully installed the prerequisites.
Open your terminal and run the following command to install Tesseract and Poppler:
sudo apt-get update && sudo apt-get install -y tesseract-ocr poppler-utils
Open your terminal and use the dnf or yum package manager:
sudo dnf install -y tesseract poppler-utils
With all dependencies installed, you can now start the Gradio application GUI. For a guide on how to use this, please go here.
python app.py
After running the command, the application will start, and you will see a local URL in your terminal (usually http://127.0.0.1:7860).
Open this URL in your web browser to use the document redaction tool
For example CLI commands, please refer to this guide or the examples in cli_redact.py
If you installed from PyPI, use the installed console script:
cli_redact --help
From a repository checkout, you can also run:
python cli_redact.py --help
For Python examples in using the Python package, please see Python Package usage (Python).
You can customise the application's behavior by creating a configuration file. This allows you to change settings without modifying the source code, such as enabling AWS features, changing logging behavior, or pointing to local Tesseract/Poppler installations. A full overview of all the potential settings you can modify in the app_config.env file can be seen in tools/config.py, with explanation on the documentation website for the github repo
To get started:
config/app_config.env.example to config/app_config.env.config/app_config.env to suit your needs. The application will automatically load these settings on startup.If you do not create this file, the application will run with default settings.
Here is an overview of the most important settings, separated by whether they are for local use or require AWS.
These settings are useful for all users, regardless of whether you are using AWS.
TESSERACT_FOLDER / POPPLER_FOLDER
bin sub-directory).POPPLER_FOLDER=C:/Program Files/poppler-24.02.0/bin/ TESSERACT_FOLDER=tesseract/TESSERACT_DATA_FOLDER
Error opening data file ./eng.traineddata or Tesseract couldn't load any languages, this is usually because it can't find the tessdata/ language files.eng.traineddata (typically a tessdata directory).TESSERACT_DATA_FOLDER=C:/Program Files/Tesseract-OCR/tessdataSHOW_LANGUAGE_SELECTION=True
True to display a language selection dropdown in the UI for OCR processing.DEFAULT_LOCAL_OCR_MODEL=tesseract"
tesseract, paddle, or hybrid. "Tesseract" is the default, and is recommended. "hybrid-paddle" is a combination of the two - first pass through the redactions will be done with Tesseract, and then a second pass will be done with PaddleOCR on words with low confidence. "paddle" will only return whole line text extraction, and so will only work for OCR, not redaction.SESSION_OUTPUT_FOLDER=False
True, redacted files will be saved in unique subfolders within the output/ directory for each session.DISPLAY_FILE_NAMES_IN_LOGS=False
True to include them.These settings are only relevant if you intend to use AWS services like Textract for OCR and Comprehend for PII detection.
RUN_AWS_FUNCTIONS=True
True to enable any AWS functionality. If it is False, all other AWS settings will be ignored.UI Options:
SHOW_AWS_TEXT_EXTRACTION_OPTIONS=True: Adds "AWS Textract" as an option in the text extraction dropdown.SHOW_AWS_PII_DETECTION_OPTIONS=True: Adds "AWS Comprehend" as an option in the PII detection dropdown.Core AWS Configuration:
AWS_REGION=example-region: Set your AWS region (e.g., us-east-1).DOCUMENT_REDACTION_BUCKET=example-bucket: The name of the S3 bucket the application will use for temporary file storage and processing.AWS Logging:
SAVE_LOGS_TO_DYNAMODB=True: If enabled, usage and feedback logs will be saved to DynamoDB tables.ACCESS_LOG_DYNAMODB_TABLE_NAME, USAGE_LOG_DYNAMODB_TABLE_NAME, etc.: Specify the names of your DynamoDB tables for logging.Advanced AWS Textract Features:
SHOW_WHOLE_DOCUMENT_TEXTRACT_CALL_OPTIONS=True: Enables UI components for large-scale, asynchronous document processing via Textract.TEXTRACT_WHOLE_DOCUMENT_ANALYSIS_BUCKET=example-bucket-output: A separate S3 bucket for the final output of asynchronous Textract jobs.LOAD_PREVIOUS_TEXTRACT_JOBS_S3=True: If enabled, the app will try to load the status of previously submitted asynchronous jobs from S3.Cost Tracking (for internal accounting):
SHOW_COSTS=True: Displays an estimated cost for AWS operations. Can be enabled even if AWS functions are off.GET_COST_CODES=True: Enables a dropdown for users to select a cost code before running a job.COST_CODES_PATH=config/cost_codes.csv: The local path to a CSV file containing your cost codes.ENFORCE_COST_CODES=True: Makes selecting a cost code mandatory before starting a redaction.Now you have the app installed, please refer to the User Guide for more information on how to use it for basic and advanced redaction.
If you are an LLM/agent interacting with this app over HTTP (e.g. Hugging Face Spaces), do not guess inputs from the UI. Use the Gradio schema as the source of truth:
GET /gradio_api/infoPOST /gradio_api/upload (multipart field files) → returns server-internal paths like /tmp/gradio_tmp/...POST /gradio_api/call/{api_name} with body {"data":[...]} (argument order must match /gradio_api/info)GET /gradio_api/call/{api_name}/{event_id} until completeGET /gradio_api/file={path} (note: some deployments return 403 without session cookies)gr.api endpoints)Fetch /gradio_api/info and then prefer the simplest route that exists:
/review_apply/doc_redact — optional handwrite_signature_checkbox for AWS Textract (e.g. Extract handwriting, Extract signatures)/pdf_summarise/tabular_redactIf those endpoints are not present in your deployment, fall back to the long UI-chained routes (/apply_review_redactions, /redact_data, etc.) and build data[] strictly from /gradio_api/info.
needed: N, got: M) mean you called a session-heavy UI handler with the wrong data[]. Prefer the short endpoints above.handle_file() gotcha (for gradio_client users): do not wrap server-internal upload paths (e.g. /tmp/gradio_tmp/...) with handle_file(). Pass them as plain strings./home/user/app/output/). Plan to download via file=... or use a mounted output directory in Docker.If you want external agents to call this app reliably without re-implementing Gradio upload/call/poll/download details, consider an MCP server that wraps the main tasks (redact_document, apply_review_redactions, redact_tabular, summarise_document) behind a small tool interface. See the relevant documentation.
Use as a library: After installing from PyPI (pip install doc_redaction), you can call the same workflows as the Gradio api_name routes from Python. See the documentation: Python Package usage (Python).
To extract text from documents, the 'Local' options are PikePDF for PDFs with selectable text, and OCR with Tesseract. Use AWS Textract to extract more complex elements e.g. handwriting, signatures, or unclear text. PaddleOCR and VLM support is also provided (see the installation instructions below).
For PII identification, 'Local' (based on spaCy) gives good results if you are looking for common names or terms, or a custom list of terms to redact (see Redaction settings). AWS Comprehend gives better results at a small cost.
Additional options on the 'Redaction settings' include, the type of information to redact (e.g. people, places), custom terms to include/ exclude from redaction, fuzzy matching, language settings, and whole page redaction. After redaction is complete, you can view and modify suggested redactions on the 'Review redactions' tab to quickly create a final redacted document.
NOTE: The app is not 100% accurate, and it will miss some personal information. It is essential that all outputs are reviewed by a human before using the final outputs.
1 commits
Redact personally identifiable information (PII) from documents (PDF, PNG, JPG), Word files (DOCX), or tabular data (XLSX/CSV/Parquet). Please see the User Guide for a full walkthrough of all the features in the app.
Follow these instructions to get the document redaction application running on your local machine.
Clone the repository and install in editable mode:
git clone https://github.com/seanpedrick-case/doc_redaction.git
cd doc_redaction
pip install -e .
To install with PaddleOCR (with a transformers backend as of v2.4.0):
pip install -e ".[paddle]"
If you want to run VLMs / LLMs with the transformers package:
pip install -e ".[vlm]"
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the GPU-enabled version of torch, it is advised to install the following version:
pip install torch==2.13.0 torchvision==0.28.0 --index-url https://download.pytorch.org/whl/cu130
Create a virtual environment (recommended) and install doc_redaction.
python -m venv venv
# Windows:
.\venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
The package is published on PyPI as doc-redaction (import name doc_redaction):
pip install doc_redaction
Optional extras (same as in pyproject.toml). For installing paddleOCR:
pip install "doc_redaction[paddle]"
For running VLMs / LLMs with the transformers package:
pip install "doc_redaction[vlm]"
For programmatic use (CLI-first API matching Gradio api_name routes), see Python Package usage (Python). The console script cli_redact is available after install.
Web UI from a PyPI install: You can start the Gradio UI after pip install doc_redaction by running (note that the prerequisites tesseract and poppler will need to be correctly installed following step 2 below):
python -m app
Important: your working directory matters. When you run python -m app, the app treats your current folder as the “app folder”:
config/app_config.env relative to the folder you run it from (and python -m doc_redaction.install_deps will also write config/app_config.env there).config/, output/, input/, logs/, usage/, feedback/, and temporary/cache folders depending on your settings).doc_redaction package). If you run from a “random” directory after a PyPI install, the app can still locate its packaged examples; your working directory mainly affects where config/, input/, output/, logs, and temp folders are created.In practice, the smoothest UI experience (examples, bundled assets, docs links, predictable relative paths) is still usually via a repository checkout or Docker, but PyPI install is sufficient to launch the UI as long as you run it from a suitable working folder and have the system dependencies available (or run python -m doc_redaction.install_deps first).
The doc_redaction Redaction app can be installed by using the Dockerfile or Docker compose files (llama.cpp, vLLM) provided in the repo.
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by llama.cpp, or vLLM. Llama.cpp is more flexible than vLLM for low VRAM systems, as Llama.cpp will offload to cpu/system RAM automatically rather than failing as vLLM tends to do.
For Llama.cpp, you can use the docker-compose_llama.yml file, and for vLLM, you can use the docker-compose_vllm.yml file. To run, Docker / Docker Desktop should be installed, and then you can run the commands suggested in the top of the files to run the servers.
You will need ~40 GB of disk space to run everything depending on the model chosen from the compose file. For the vLLM server, you will need 24 GB VRAM. For the Llama.cpp server, 24 GB VRAM is needed to run at full speed, but the n-gpu-layers and n-cpu-moe parameters in the Docker compose file can be adjusted to fit into your system. I would suggest that 8 GB VRAM is needed as a bare minimum for decent inference speed. See the Unsloth guide for more details on working with GGUF files for Qwen 3.5.
If you want a working Docker installation without GPU support, you can install from the Dockerfile in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on Hugging Face. You can adjust the INSTALL_PADDLEOCR, PADDLE_GPU_ENABLED, INSTALL_VLM, and TORCH_GPU_ENABLED config variables to adjust for PaddleOCR and Transformers packages for local VLM support. Note that GPU-enabled PaddleOCR, and GPU-enabled Transformers/Torch often don't work well together, which is one reason why a Llama.cpp/vLLM inference server Docker installation option is provided below.
The main Dockerfile produces two final images via build targets: gradio (default web UI, non-root user, named volumes for writable paths) and lambda (AWS Lambda handler). Build examples:
docker build -f Dockerfile --target gradio -t doc-redaction-gradio .
docker build -f Dockerfile --target lambda -t doc-redaction-lambda .
The agent-redact/ folder adds a separate Gradio UI that orchestrates redaction (Pass 1 review CSV, optional Pass 2 VLM, /review_apply) against the main doc_redaction app. Heavy OCR and PII detection stay in the main app; the agent UI only drives the workflow.
Choose the orchestration backend with AGENT_ORCHESTRATOR in config/agent.env (copy from config/agent.env.example):
AGENT_ORCHESTRATOR | Runtime | Typical use |
|---|---|---|
pi (default) | Pi coding agent (pi --mode rpc) | Full bash + skills; Hugging Face Space; local Docker / ECS |
langgraph | LangGraph ReAct agent in redaction_langgraph/ | Same Docker image as Pi; curated Python tools only (no shell); local llama.cpp, Gemini, or Bedrock |
agentcore | Amazon Bedrock AgentCore Runtime | Managed AWS runtime wrapping the LangGraph bundle; the Gradio UI proxies prompts via AGENTCORE_RUNTIME_URL |
agentcore-harness | Bedrock AgentCore Harness | Console-managed loop (AGENTCORE_HARNESS_ARN); Pi-like skills/shell; S3 file bridge for uploads |
The Gradio agent UI and the Pi / LangGraph in-container runtimes share one multi-stage image at agent-redact/pi-agent/Dockerfile. It uses the same Python 3.12 slim base as the main app; a small Node stage installs the pi CLI, which is copied into the runtime image.
| Build target | Typical use |
|---|---|
dev | Local development with docker-compose_llama_agentic.yml — the repo is bind-mounted; only Pi CLI + Python deps are in the image. |
runtime | Hugging Face Space and AWS ECS — agent code is baked in; runs as non-root user with named volumes for workspace, uploads, and session dirs (read-only root filesystem friendly). |
Build from the repository root:
docker build -f agent-redact/pi-agent/Dockerfile --target dev -t pi-agent-dev .
docker build -f agent-redact/pi-agent/Dockerfile --target runtime -t pi-agent-runtime .
LangGraph (in-container). Set AGENT_ORCHESTRATOR=langgraph in config/agent.env (or compose) and start the same pi-agent service as for Pi. Optional: LANGGRAPH_REQUIRE_REVIEW_APPROVAL=true to gate /review_apply until the agent calls an explicit approve tool. A headless Pass 1 spike is python agent-redact/redaction_langgraph/headless_pass1.py --pdf path/to.pdf --direct-tool. Optional tracing (Arize AX / Phoenix) lives under agent-redact/eval/.
Bedrock AgentCore. Deploy the LangGraph agent as a managed runtime, then point the Gradio UI at it:
AGENT_ORCHESTRATOR=agentcore
AGENTCORE_RUNTIME_URL=https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<URL-encoded-ARN>
The CDK demo installer can also build an ARM64 runtime image and create the AgentCore resource (python cdk/cdk_install.py --profile demo --enable-agentic --enable-agentcore-cdk-deploy). For a console Harness instead of the LangGraph bundle, use AGENT_ORCHESTRATOR=agentcore-harness with AGENTCORE_HARNESS_ARN. Full deploy, auth, and troubleshooting: agent-redact/agentcore/README.md.
For llama.cpp + the agent UI together, see the compose examples at the top of docker-compose_llama_agentic.yml. Layout of the agent tree: agent-redact/README.md. LLM providers, env vars, and Gradio usage: agent-redact/pi/agent/README.md.
The repo contains a CDK folder, that contains all the files you need to setup and deploy to an AWS environment with CDK. The installation wizard is cdk_install.py, which provides a number of options to deploy the Document Redaction App to AWS for demonstration or production. CDK-specific notes (including CloudFront CSP/CORS and the post-deploy refresh deploy) are in cdk/README.md. More details on CDK deployment can be found in the Installation Guide.
This application relies on two external tools for OCR (Tesseract) and PDF processing (Poppler). If not using a Docker-based deployment, you will need to install them on your system before proceeding. To run the Document Redaction app successfully, these tools need to be installed and either 1. added to PATH, or 2. be in a folder that is directly referenced in the config/app_config.env file with the variables TESSERACT_FOLDER and POPPLER_FOLDER (defined here if you want to see the code). The instructions below will guide you through different ways to install these dependencies.
If you don’t have admin rights (or you just want the simplest setup), you can have the project download and configure Tesseract and Poppler into a local redaction_deps/ folder inside the doc_redaction folder.
You need the installer script available first, which means either:
git clone ... and run the command from the repo root (recommended for the web UI), orpip install doc_redaction and run from a writable folder where you want redaction_deps/ and config/app_config.env to be created/updated.From the repository root (or your chosen working folder) after creating/activating your venv and installing Python requirements:
python -m doc_redaction.install_deps
This writes TESSERACT_FOLDER / POPPLER_FOLDER into config/app_config.env so the app can find the binaries without you editing your system PATH.
To just check whether your machine can already see the tools:
python -m doc_redaction.install_deps --verify-only
If you don’t use the automated setup above, you can install the dependencies manually by downloading installers and adding the programs to your system's PATH.
Install Tesseract OCR:
tesseract-ocr-w64-setup-v5.X.X...exe).Install Poppler:
.zip file (e.g., poppler-25.07.0-win.zip).C:\Program Files\poppler\.bin folder from your Poppler installation to your system's PATH environment variable.
Path variable, then click "Edit...".bin directory inside your Poppler folder (e.g., C:\Program Files\poppler\poppler-24.02.0\bin).To verify, open a new Command Prompt and run tesseract --version and pdftoppm -v. If they both return version information, you have successfully installed the prerequisites.
Open your terminal and run the following command to install Tesseract and Poppler:
sudo apt-get update && sudo apt-get install -y tesseract-ocr poppler-utils
Open your terminal and use the dnf or yum package manager:
sudo dnf install -y tesseract poppler-utils
With all dependencies installed, you can now start the Gradio application GUI. For a guide on how to use this, please go here.
python app.py
After running the command, the application will start, and you will see a local URL in your terminal (usually http://127.0.0.1:7860).
Open this URL in your web browser to use the document redaction tool
For example CLI commands, please refer to this guide or the examples in cli_redact.py
If you installed from PyPI, use the installed console script:
cli_redact --help
From a repository checkout, you can also run:
python cli_redact.py --help
For Python examples in using the Python package, please see Python Package usage (Python).
You can customise the application's behavior by creating a configuration file. This allows you to change settings without modifying the source code, such as enabling AWS features, changing logging behavior, or pointing to local Tesseract/Poppler installations. A full overview of all the potential settings you can modify in the app_config.env file can be seen in tools/config.py, with explanation on the documentation website for the github repo
To get started:
config/app_config.env.example to config/app_config.env.config/app_config.env to suit your needs. The application will automatically load these settings on startup.If you do not create this file, the application will run with default settings.
Here is an overview of the most important settings, separated by whether they are for local use or require AWS.
These settings are useful for all users, regardless of whether you are using AWS.
TESSERACT_FOLDER / POPPLER_FOLDER
bin sub-directory).POPPLER_FOLDER=C:/Program Files/poppler-24.02.0/bin/ TESSERACT_FOLDER=tesseract/TESSERACT_DATA_FOLDER
Error opening data file ./eng.traineddata or Tesseract couldn't load any languages, this is usually because it can't find the tessdata/ language files.eng.traineddata (typically a tessdata directory).TESSERACT_DATA_FOLDER=C:/Program Files/Tesseract-OCR/tessdataSHOW_LANGUAGE_SELECTION=True
True to display a language selection dropdown in the UI for OCR processing.DEFAULT_LOCAL_OCR_MODEL=tesseract"
tesseract, paddle, or hybrid. "Tesseract" is the default, and is recommended. "hybrid-paddle" is a combination of the two - first pass through the redactions will be done with Tesseract, and then a second pass will be done with PaddleOCR on words with low confidence. "paddle" will only return whole line text extraction, and so will only work for OCR, not redaction.SESSION_OUTPUT_FOLDER=False
True, redacted files will be saved in unique subfolders within the output/ directory for each session.DISPLAY_FILE_NAMES_IN_LOGS=False
True to include them.These settings are only relevant if you intend to use AWS services like Textract for OCR and Comprehend for PII detection.
RUN_AWS_FUNCTIONS=True
True to enable any AWS functionality. If it is False, all other AWS settings will be ignored.UI Options:
SHOW_AWS_TEXT_EXTRACTION_OPTIONS=True: Adds "AWS Textract" as an option in the text extraction dropdown.SHOW_AWS_PII_DETECTION_OPTIONS=True: Adds "AWS Comprehend" as an option in the PII detection dropdown.Core AWS Configuration:
AWS_REGION=example-region: Set your AWS region (e.g., us-east-1).DOCUMENT_REDACTION_BUCKET=example-bucket: The name of the S3 bucket the application will use for temporary file storage and processing.AWS Logging:
SAVE_LOGS_TO_DYNAMODB=True: If enabled, usage and feedback logs will be saved to DynamoDB tables.ACCESS_LOG_DYNAMODB_TABLE_NAME, USAGE_LOG_DYNAMODB_TABLE_NAME, etc.: Specify the names of your DynamoDB tables for logging.Advanced AWS Textract Features:
SHOW_WHOLE_DOCUMENT_TEXTRACT_CALL_OPTIONS=True: Enables UI components for large-scale, asynchronous document processing via Textract.TEXTRACT_WHOLE_DOCUMENT_ANALYSIS_BUCKET=example-bucket-output: A separate S3 bucket for the final output of asynchronous Textract jobs.LOAD_PREVIOUS_TEXTRACT_JOBS_S3=True: If enabled, the app will try to load the status of previously submitted asynchronous jobs from S3.Cost Tracking (for internal accounting):
SHOW_COSTS=True: Displays an estimated cost for AWS operations. Can be enabled even if AWS functions are off.GET_COST_CODES=True: Enables a dropdown for users to select a cost code before running a job.COST_CODES_PATH=config/cost_codes.csv: The local path to a CSV file containing your cost codes.ENFORCE_COST_CODES=True: Makes selecting a cost code mandatory before starting a redaction.Now you have the app installed, please refer to the User Guide for more information on how to use it for basic and advanced redaction.
If you are an LLM/agent interacting with this app over HTTP (e.g. Hugging Face Spaces), do not guess inputs from the UI. Use the Gradio schema as the source of truth:
GET /gradio_api/infoPOST /gradio_api/upload (multipart field files) → returns server-internal paths like /tmp/gradio_tmp/...POST /gradio_api/call/{api_name} with body {"data":[...]} (argument order must match /gradio_api/info)GET /gradio_api/call/{api_name}/{event_id} until completeGET /gradio_api/file={path} (note: some deployments return 403 without session cookies)gr.api endpoints)Fetch /gradio_api/info and then prefer the simplest route that exists:
/review_apply/doc_redact — optional handwrite_signature_checkbox for AWS Textract (e.g. Extract handwriting, Extract signatures)/pdf_summarise/tabular_redactIf those endpoints are not present in your deployment, fall back to the long UI-chained routes (/apply_review_redactions, /redact_data, etc.) and build data[] strictly from /gradio_api/info.
needed: N, got: M) mean you called a session-heavy UI handler with the wrong data[]. Prefer the short endpoints above.handle_file() gotcha (for gradio_client users): do not wrap server-internal upload paths (e.g. /tmp/gradio_tmp/...) with handle_file(). Pass them as plain strings./home/user/app/output/). Plan to download via file=... or use a mounted output directory in Docker.If you want external agents to call this app reliably without re-implementing Gradio upload/call/poll/download details, consider an MCP server that wraps the main tasks (redact_document, apply_review_redactions, redact_tabular, summarise_document) behind a small tool interface. See the relevant documentation.
Use as a library: After installing from PyPI (pip install doc_redaction), you can call the same workflows as the Gradio api_name routes from Python. See the documentation: Python Package usage (Python).
To extract text from documents, the 'Local' options are PikePDF for PDFs with selectable text, and OCR with Tesseract. Use AWS Textract to extract more complex elements e.g. handwriting, signatures, or unclear text. PaddleOCR and VLM support is also provided (see the installation instructions below).
For PII identification, 'Local' (based on spaCy) gives good results if you are looking for common names or terms, or a custom list of terms to redact (see Redaction settings). AWS Comprehend gives better results at a small cost.
Additional options on the 'Redaction settings' include, the type of information to redact (e.g. people, places), custom terms to include/ exclude from redaction, fuzzy matching, language settings, and whole page redaction. After redaction is complete, you can view and modify suggested redactions on the 'Review redactions' tab to quickly create a final redacted document.
NOTE: The app is not 100% accurate, and it will miss some personal information. It is essential that all outputs are reviewed by a human before using the final outputs.
1 commits