doc-redaction 2.2.4__tar.gz → 2.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {doc_redaction-2.2.4/doc_redaction.egg-info → doc_redaction-2.2.6}/PKG-INFO +29 -14
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/README.md +29 -14
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/README_PYPI.md +28 -13
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/app.py +13 -4
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/install_deps.py +17 -17
- {doc_redaction-2.2.4 → doc_redaction-2.2.6/doc_redaction.egg-info}/PKG-INFO +29 -14
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/pyproject.toml +1 -1
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/config.py +11 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/custom_image_analyser_engine.py +34 -2
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/helper_functions.py +178 -30
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/MANIFEST.in +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/agent_routes.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/cli_redact.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/__init__.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/api.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/assets/favicon.png +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/cli_api.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/cli_redact.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/data_anonymise.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Bold minimalist professional cover letter.docx +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Difficult handwritten note.jpg +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Example-cv-university-graduaty-hr-role-with-photo-2.pdf +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Lambeth_2030-Our_Future_Our_Lambeth.pdf.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Partnership-Agreement-Toolkit_0_0.pdf +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/Partnership-Agreement-Toolkit_test_deny_list_para_single_spell.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/combined_case_notes.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/combined_case_notes.xlsx +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/doubled_output_joined.pdf +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_complaint_letter.jpg +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_of_emails_sent_to_a_professor_before_applying.pdf +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/Partnership-Agreement-Toolkit_0_0.pdf_ocr_output.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/Partnership-Agreement-Toolkit_0_0.pdf_review_file.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/Partnership-Agreement-Toolkit_0_0_ocr_results_with_words_textract.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/doubled_output_joined.pdf_ocr_output.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/example_of_emails_sent_to_a_professor_before_applying_ocr_output_textract.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/example_of_emails_sent_to_a_professor_before_applying_ocr_results_with_words_textract.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/example_outputs/example_of_emails_sent_to_a_professor_before_applying_review_file.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/graduate-job-example-cover-letter.pdf +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/partnership_toolkit_redact_custom_deny_list.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/partnership_toolkit_redact_some_pages.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/test_allow_list_graduate.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/example_data/test_allow_list_partnership.csv +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/file_conversion.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/file_redaction.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/find_duplicate_pages.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/find_duplicate_tabular.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/gradio_app.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/helper_functions.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/lambda_entrypoint.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/redaction_review.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction/summaries.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction.egg-info/SOURCES.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction.egg-info/dependency_links.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction.egg-info/entry_points.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction.egg-info/requires.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/doc_redaction.egg-info/top_level.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/intros/long_intro.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/intros/short_intro.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/intros/short_intro_responsible.txt +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/lambda_entrypoint.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/load_dynamo_logs.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/load_s3_logs.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/mcp_doc_redaction/__init__.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/mcp_doc_redaction/artifact_bundle.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/mcp_doc_redaction/gradio_transport.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/mcp_doc_redaction/schemas.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/mcp_doc_redaction/server.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/setup.cfg +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_agent_apply_review_redactions.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_annotation_color_parsing.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_cli_smoke.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_gradio_doc_redact_simple.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_gradio_summarise_simple.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_gradio_transport_sse.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_gradio_upload_staging.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_gui_only.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_mcp_doc_redaction_bundle.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_mcp_doc_redaction_extract_paths.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_package_api_smoke.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_placeholder_bbox_scaling.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_redaction_overlay_export.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_redaction_types.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/test/test_review_ocr_visualisation_export.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/__init__.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/apply_hf_zero_gpu_readme_frontmatter.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/auth.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/aws_functions.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/aws_textract.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/cli_usage_logger.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/custom_csvlogger.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/data_anonymise.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/file_conversion.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/file_redaction.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/find_duplicate_pages.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/find_duplicate_tabular.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/llm_entity_detection.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/llm_entity_detection_prompts.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/llm_funcs.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/load_spacy_model_custom_recognisers.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/presidio_analyzer_custom.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/preview_redaction_boxes.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/quickstart.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/redaction_review.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/redaction_types.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/run_vlm.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/secure_path_utils.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/secure_regex_utils.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/simplified_api.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/summaries.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/textract_batch_call.py +0 -0
- {doc_redaction-2.2.4 → doc_redaction-2.2.6}/tools/word_segmenter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: doc_redaction
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: Redact PDF/image-based documents, Word, or CSV/XLSX files using a Gradio-based GUI interface
|
|
5
5
|
Author-email: Sean Pedrick-Case <spedrickcase@lambeth.gov.uk>
|
|
6
6
|
Maintainer-email: Sean Pedrick-Case <spedrickcase@lambeth.gov.uk>
|
|
@@ -86,7 +86,7 @@ Follow these instructions to get the document redaction application running on y
|
|
|
86
86
|
|
|
87
87
|
### 1. Package installation
|
|
88
88
|
|
|
89
|
-
#### Install from source repo
|
|
89
|
+
#### Option 1 - Recommended: Install from source repo
|
|
90
90
|
|
|
91
91
|
Clone the repository and install in editable mode:
|
|
92
92
|
|
|
@@ -96,10 +96,12 @@ cd doc_redaction
|
|
|
96
96
|
pip install -e .
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
#####
|
|
99
|
+
##### Install extras (Paddle or Transformers/Torch VLM)
|
|
100
|
+
|
|
101
|
+
To install with PaddleOCR:
|
|
100
102
|
|
|
101
103
|
```bash
|
|
102
|
-
pip install -e ".[paddle
|
|
104
|
+
pip install -e ".[paddle]"
|
|
103
105
|
```
|
|
104
106
|
|
|
105
107
|
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the equivalent GPU versions, you will need to run the following commands:
|
|
@@ -107,6 +109,13 @@ Note that the versions of both PaddleOCR and Torch installed by default are the
|
|
|
107
109
|
pip install paddlepaddle-gpu==3.2.1 --index-url https://www.paddlepaddle.org.cn/packages/stable/cu129/
|
|
108
110
|
```
|
|
109
111
|
|
|
112
|
+
If you want to run VLMs / LLMs with the transformers package:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install -e ".[vlm]"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
|
|
110
119
|
**Note:** It is difficult to get paddlepaddle gpu working in an environment alongside torch. You may well need to reinstall the cpu version to ensure compatibility, and run paddlepaddle-gpu in a separate environment without torch installed. If you get errors related to .dll files following paddle gpu install, you may need to install the latest c++ redistributables. For Windows, you can find them [here](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
|
111
120
|
|
|
112
121
|
```bash
|
|
@@ -114,7 +123,7 @@ pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cu129
|
|
|
114
123
|
pip install torchvision --index-url https://download.pytorch.org/whl/cu129
|
|
115
124
|
```
|
|
116
125
|
|
|
117
|
-
#### Install from PyPI
|
|
126
|
+
#### Option 2 - Install from PyPI
|
|
118
127
|
|
|
119
128
|
Create a virtual environment (recommended) and install **doc_redaction**.
|
|
120
129
|
|
|
@@ -132,15 +141,21 @@ The package is published on PyPI as **`doc-redaction`** (import name **`doc_reda
|
|
|
132
141
|
pip install doc_redaction
|
|
133
142
|
```
|
|
134
143
|
|
|
135
|
-
Optional extras (same as in `pyproject.toml`):
|
|
144
|
+
Optional extras (same as in `pyproject.toml`). For installing paddleOCR:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install "doc_redaction[paddle]"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
For running VLMs / LLMs with the transformers package:
|
|
136
151
|
|
|
137
152
|
```bash
|
|
138
|
-
pip install "doc_redaction[
|
|
153
|
+
pip install "doc_redaction[vlm]"
|
|
139
154
|
```
|
|
140
155
|
|
|
141
156
|
For programmatic use (CLI-first API matching Gradio `api_name` routes), see **[Python Package usage (Python)](https://seanpedrick-case.github.io/doc_redaction/src/python_package_usage.html)**. The console script **`cli_redact`** is available after install.
|
|
142
157
|
|
|
143
|
-
**Web UI from a PyPI install:** You *can* start the Gradio UI after `pip install doc_redaction` by running:
|
|
158
|
+
**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):
|
|
144
159
|
|
|
145
160
|
```bash
|
|
146
161
|
python -m app
|
|
@@ -154,21 +169,21 @@ python -m app
|
|
|
154
169
|
|
|
155
170
|
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).
|
|
156
171
|
|
|
157
|
-
#### Docker installation
|
|
172
|
+
#### Option 3 - Docker installation
|
|
158
173
|
|
|
159
174
|
The doc_redaction Redaction app can be installed by using the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) or Docker compose files ([llama.cpp](https://github.com/ggml-org/llama.cpp), [vLLM](https://docs.vllm.ai/en/stable/)) provided in the repo.
|
|
160
175
|
|
|
161
|
-
##### Without Llama.cpp / vLLM inference server
|
|
162
|
-
|
|
163
|
-
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
164
|
-
|
|
165
176
|
##### With Llama.cpp / vLLM inference server
|
|
166
177
|
|
|
167
178
|
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by [llama.cpp](https://github.com/ggml-org/llama.cpp), or [vLLM](https://docs.vllm.ai/en/stable/). 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.
|
|
168
179
|
|
|
169
180
|
For Llama.cpp, you can use the [docker-compose_llama.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/docker-compose_llama.yml) file, and for vLLM, you can use the [docker-compose_vllm.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/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.
|
|
170
181
|
|
|
171
|
-
You will need ~40
|
|
182
|
+
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](https://unsloth.ai/docs/models/qwen3.5) for more details on working with GGUF files for Qwen 3.5.
|
|
183
|
+
|
|
184
|
+
##### Without Llama.cpp / vLLM inference server
|
|
185
|
+
|
|
186
|
+
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
172
187
|
|
|
173
188
|
### 2. Install prerequisites: Tesseract and Poppler
|
|
174
189
|
|
|
@@ -23,7 +23,7 @@ Follow these instructions to get the document redaction application running on y
|
|
|
23
23
|
|
|
24
24
|
### 1. Package installation
|
|
25
25
|
|
|
26
|
-
#### Install from source repo
|
|
26
|
+
#### Option 1 - Recommended: Install from source repo
|
|
27
27
|
|
|
28
28
|
Clone the repository and install in editable mode:
|
|
29
29
|
|
|
@@ -33,10 +33,12 @@ cd doc_redaction
|
|
|
33
33
|
pip install -e .
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
#####
|
|
36
|
+
##### Install extras (Paddle or Transformers/Torch VLM)
|
|
37
|
+
|
|
38
|
+
To install with PaddleOCR:
|
|
37
39
|
|
|
38
40
|
```bash
|
|
39
|
-
pip install -e ".[paddle
|
|
41
|
+
pip install -e ".[paddle]"
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the equivalent GPU versions, you will need to run the following commands:
|
|
@@ -44,6 +46,13 @@ Note that the versions of both PaddleOCR and Torch installed by default are the
|
|
|
44
46
|
pip install paddlepaddle-gpu==3.2.1 --index-url https://www.paddlepaddle.org.cn/packages/stable/cu129/
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
If you want to run VLMs / LLMs with the transformers package:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install -e ".[vlm]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
|
|
47
56
|
**Note:** It is difficult to get paddlepaddle gpu working in an environment alongside torch. You may well need to reinstall the cpu version to ensure compatibility, and run paddlepaddle-gpu in a separate environment without torch installed. If you get errors related to .dll files following paddle gpu install, you may need to install the latest c++ redistributables. For Windows, you can find them [here](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
|
48
57
|
|
|
49
58
|
```bash
|
|
@@ -51,7 +60,7 @@ pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cu129
|
|
|
51
60
|
pip install torchvision --index-url https://download.pytorch.org/whl/cu129
|
|
52
61
|
```
|
|
53
62
|
|
|
54
|
-
#### Install from PyPI
|
|
63
|
+
#### Option 2 - Install from PyPI
|
|
55
64
|
|
|
56
65
|
Create a virtual environment (recommended) and install **doc_redaction**.
|
|
57
66
|
|
|
@@ -69,15 +78,21 @@ The package is published on PyPI as **`doc-redaction`** (import name **`doc_reda
|
|
|
69
78
|
pip install doc_redaction
|
|
70
79
|
```
|
|
71
80
|
|
|
72
|
-
Optional extras (same as in `pyproject.toml`):
|
|
81
|
+
Optional extras (same as in `pyproject.toml`). For installing paddleOCR:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install "doc_redaction[paddle]"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For running VLMs / LLMs with the transformers package:
|
|
73
88
|
|
|
74
89
|
```bash
|
|
75
|
-
pip install "doc_redaction[
|
|
90
|
+
pip install "doc_redaction[vlm]"
|
|
76
91
|
```
|
|
77
92
|
|
|
78
93
|
For programmatic use (CLI-first API matching Gradio `api_name` routes), see **[Python Package usage (Python)](https://seanpedrick-case.github.io/doc_redaction/src/python_package_usage.html)**. The console script **`cli_redact`** is available after install.
|
|
79
94
|
|
|
80
|
-
**Web UI from a PyPI install:** You *can* start the Gradio UI after `pip install doc_redaction` by running:
|
|
95
|
+
**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):
|
|
81
96
|
|
|
82
97
|
```bash
|
|
83
98
|
python -m app
|
|
@@ -91,25 +106,25 @@ python -m app
|
|
|
91
106
|
|
|
92
107
|
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).
|
|
93
108
|
|
|
94
|
-
#### Docker installation
|
|
109
|
+
#### Option 3 - Docker installation
|
|
95
110
|
|
|
96
111
|
The doc_redaction Redaction app can be installed by using the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) or Docker compose files ([llama.cpp](https://github.com/ggml-org/llama.cpp), [vLLM](https://docs.vllm.ai/en/stable/)) provided in the repo.
|
|
97
112
|
|
|
98
|
-
##### Without Llama.cpp / vLLM inference server
|
|
99
|
-
|
|
100
|
-
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
101
|
-
|
|
102
113
|
##### With Llama.cpp / vLLM inference server
|
|
103
114
|
|
|
104
115
|
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by [llama.cpp](https://github.com/ggml-org/llama.cpp), or [vLLM](https://docs.vllm.ai/en/stable/). 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.
|
|
105
116
|
|
|
106
117
|
For Llama.cpp, you can use the [docker-compose_llama.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/docker-compose_llama.yml) file, and for vLLM, you can use the [docker-compose_vllm.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/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.
|
|
107
118
|
|
|
108
|
-
You will need ~40
|
|
119
|
+
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](https://unsloth.ai/docs/models/qwen3.5) for more details on working with GGUF files for Qwen 3.5.
|
|
120
|
+
|
|
121
|
+
##### Without Llama.cpp / vLLM inference server
|
|
122
|
+
|
|
123
|
+
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
109
124
|
|
|
110
125
|
### 2. Install prerequisites: Tesseract and Poppler
|
|
111
126
|
|
|
112
|
-
This application relies on two external tools for OCR (Tesseract) and PDF processing (Poppler). Please install them on your system before proceeding.
|
|
127
|
+
This application relies on two external tools for OCR (Tesseract) and PDF processing (Poppler). Please 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](https://github.com/seanpedrick-case/doc_redaction/blob/main/tools/config.py) if you want to see the code). The instructions below will guide you through diffferent ways to install these dependencies.
|
|
113
128
|
|
|
114
129
|
---
|
|
115
130
|
|
|
@@ -12,7 +12,7 @@ Follow these instructions to get the document redaction application running on y
|
|
|
12
12
|
|
|
13
13
|
### 1. Package installation
|
|
14
14
|
|
|
15
|
-
#### Install from source repo
|
|
15
|
+
#### Option 1 - Recommended: Install from source repo
|
|
16
16
|
|
|
17
17
|
Clone the repository and install in editable mode:
|
|
18
18
|
|
|
@@ -22,10 +22,12 @@ cd doc_redaction
|
|
|
22
22
|
pip install -e .
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
#####
|
|
25
|
+
##### Install extras (Paddle or Transformers/Torch VLM)
|
|
26
|
+
|
|
27
|
+
To install with PaddleOCR:
|
|
26
28
|
|
|
27
29
|
```bash
|
|
28
|
-
pip install -e ".[paddle
|
|
30
|
+
pip install -e ".[paddle]"
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the equivalent GPU versions, you will need to run the following commands:
|
|
@@ -33,6 +35,13 @@ Note that the versions of both PaddleOCR and Torch installed by default are the
|
|
|
33
35
|
pip install paddlepaddle-gpu==3.2.1 --index-url https://www.paddlepaddle.org.cn/packages/stable/cu129/
|
|
34
36
|
```
|
|
35
37
|
|
|
38
|
+
If you want to run VLMs / LLMs with the transformers package:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install -e ".[vlm]"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
36
45
|
**Note:** It is difficult to get paddlepaddle gpu working in an environment alongside torch. You may well need to reinstall the cpu version to ensure compatibility, and run paddlepaddle-gpu in a separate environment without torch installed. If you get errors related to .dll files following paddle gpu install, you may need to install the latest c++ redistributables. For Windows, you can find them [here](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
|
37
46
|
|
|
38
47
|
```bash
|
|
@@ -40,7 +49,7 @@ pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cu129
|
|
|
40
49
|
pip install torchvision --index-url https://download.pytorch.org/whl/cu129
|
|
41
50
|
```
|
|
42
51
|
|
|
43
|
-
#### Install from PyPI
|
|
52
|
+
#### Option 2 - Install from PyPI
|
|
44
53
|
|
|
45
54
|
Create a virtual environment (recommended) and install **doc_redaction**.
|
|
46
55
|
|
|
@@ -58,15 +67,21 @@ The package is published on PyPI as **`doc-redaction`** (import name **`doc_reda
|
|
|
58
67
|
pip install doc_redaction
|
|
59
68
|
```
|
|
60
69
|
|
|
61
|
-
Optional extras (same as in `pyproject.toml`):
|
|
70
|
+
Optional extras (same as in `pyproject.toml`). For installing paddleOCR:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install "doc_redaction[paddle]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For running VLMs / LLMs with the transformers package:
|
|
62
77
|
|
|
63
78
|
```bash
|
|
64
|
-
pip install "doc_redaction[
|
|
79
|
+
pip install "doc_redaction[vlm]"
|
|
65
80
|
```
|
|
66
81
|
|
|
67
82
|
For programmatic use (CLI-first API matching Gradio `api_name` routes), see **[Python Package usage (Python)](https://seanpedrick-case.github.io/doc_redaction/src/python_package_usage.html)**. The console script **`cli_redact`** is available after install.
|
|
68
83
|
|
|
69
|
-
**Web UI from a PyPI install:** You *can* start the Gradio UI after `pip install doc_redaction` by running:
|
|
84
|
+
**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):
|
|
70
85
|
|
|
71
86
|
```bash
|
|
72
87
|
python -m app
|
|
@@ -80,21 +95,21 @@ python -m app
|
|
|
80
95
|
|
|
81
96
|
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).
|
|
82
97
|
|
|
83
|
-
#### Docker installation
|
|
98
|
+
#### Option 3 - Docker installation
|
|
84
99
|
|
|
85
100
|
The doc_redaction Redaction app can be installed by using the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) or Docker compose files ([llama.cpp](https://github.com/ggml-org/llama.cpp), [vLLM](https://docs.vllm.ai/en/stable/)) provided in the repo.
|
|
86
101
|
|
|
87
|
-
##### Without Llama.cpp / vLLM inference server
|
|
88
|
-
|
|
89
|
-
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
90
|
-
|
|
91
102
|
##### With Llama.cpp / vLLM inference server
|
|
92
103
|
|
|
93
104
|
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by [llama.cpp](https://github.com/ggml-org/llama.cpp), or [vLLM](https://docs.vllm.ai/en/stable/). 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.
|
|
94
105
|
|
|
95
106
|
For Llama.cpp, you can use the [docker-compose_llama.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/docker-compose_llama.yml) file, and for vLLM, you can use the [docker-compose_vllm.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/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.
|
|
96
107
|
|
|
97
|
-
You will need ~40
|
|
108
|
+
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](https://unsloth.ai/docs/models/qwen3.5) for more details on working with GGUF files for Qwen 3.5.
|
|
109
|
+
|
|
110
|
+
##### Without Llama.cpp / vLLM inference server
|
|
111
|
+
|
|
112
|
+
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
98
113
|
|
|
99
114
|
### 2. Install prerequisites: Tesseract and Poppler
|
|
100
115
|
|
|
@@ -168,6 +168,7 @@ from tools.config import (
|
|
|
168
168
|
CLOUD_VLM_MODEL_CHOICE,
|
|
169
169
|
COGNITO_AUTH,
|
|
170
170
|
CONFIG_FOLDER,
|
|
171
|
+
COST_CODE_ACCORDION_OPEN,
|
|
171
172
|
COST_CODES_PATH,
|
|
172
173
|
CSV_ACCESS_LOG_HEADERS,
|
|
173
174
|
CSV_FEEDBACK_LOG_HEADERS,
|
|
@@ -315,6 +316,7 @@ from tools.config import (
|
|
|
315
316
|
SHOW_OCR_GUI_OPTIONS,
|
|
316
317
|
SHOW_PII_IDENTIFICATION_OPTIONS,
|
|
317
318
|
SHOW_QUICKSTART,
|
|
319
|
+
SHOW_SET_DEFAULT_COST_CODE_BUTTON,
|
|
318
320
|
SHOW_SUMMARISATION,
|
|
319
321
|
SHOW_TRANSFORMERS_LLM_PII_DETECTION_OPTIONS,
|
|
320
322
|
SHOW_WHOLE_DOCUMENT_TEXTRACT_CALL_OPTIONS,
|
|
@@ -923,12 +925,13 @@ cost_code_choice_drop = gr.Dropdown(
|
|
|
923
925
|
value=DEFAULT_COST_CODE,
|
|
924
926
|
label="Choose cost code for analysis",
|
|
925
927
|
choices=[DEFAULT_COST_CODE],
|
|
926
|
-
allow_custom_value=
|
|
928
|
+
allow_custom_value=True,
|
|
927
929
|
visible=GET_COST_CODES or ENFORCE_COST_CODES,
|
|
928
930
|
)
|
|
929
931
|
set_default_cost_code_button = gr.Button(
|
|
930
932
|
value="Set default cost code",
|
|
931
|
-
visible=GET_COST_CODES or ENFORCE_COST_CODES
|
|
933
|
+
visible=(GET_COST_CODES or ENFORCE_COST_CODES)
|
|
934
|
+
and SHOW_SET_DEFAULT_COST_CODE_BUTTON,
|
|
932
935
|
)
|
|
933
936
|
|
|
934
937
|
reset_cost_code_dataframe_button = gr.Button(
|
|
@@ -1255,6 +1258,9 @@ with blocks:
|
|
|
1255
1258
|
) # Keeps track of the last page that the annotator was on
|
|
1256
1259
|
s3_logs_output_textbox = gr.State(value="")
|
|
1257
1260
|
|
|
1261
|
+
# Session default cost codes dataframe
|
|
1262
|
+
session_default_cost_codes_df = gr.State(pd.DataFrame())
|
|
1263
|
+
|
|
1258
1264
|
## Annotator zoom value
|
|
1259
1265
|
annotator_zoom_number = gr.Number(
|
|
1260
1266
|
label="Current annotator zoom level", value=100, precision=0, visible=False
|
|
@@ -2334,7 +2340,8 @@ If you are an LLM/agent calling this app programmatically, prefer the **short `g
|
|
|
2334
2340
|
walkthrough_set_default_cost_code_button = (
|
|
2335
2341
|
gr.Button(
|
|
2336
2342
|
value="Set default cost code",
|
|
2337
|
-
visible=show_cost_codes
|
|
2343
|
+
visible=show_cost_codes
|
|
2344
|
+
and SHOW_SET_DEFAULT_COST_CODE_BUTTON,
|
|
2338
2345
|
)
|
|
2339
2346
|
)
|
|
2340
2347
|
|
|
@@ -2786,7 +2793,9 @@ If you are an LLM/agent calling this app programmatically, prefer the **short `g
|
|
|
2786
2793
|
|
|
2787
2794
|
if GET_COST_CODES or ENFORCE_COST_CODES:
|
|
2788
2795
|
with gr.Accordion(
|
|
2789
|
-
"Assign task to cost code",
|
|
2796
|
+
"Assign task to cost code",
|
|
2797
|
+
open=COST_CODE_ACCORDION_OPEN,
|
|
2798
|
+
visible=True,
|
|
2790
2799
|
):
|
|
2791
2800
|
gr.Markdown(
|
|
2792
2801
|
"Please ensure that you have approval from your budget holder before using this app for redaction tasks that incur a cost."
|
|
@@ -405,26 +405,26 @@ def _install_windows_poppler(base_dir: Path, force: bool) -> Path:
|
|
|
405
405
|
|
|
406
406
|
def _tesseract_latest_installer_url() -> str:
|
|
407
407
|
"""
|
|
408
|
-
|
|
409
|
-
64-bit installer filename.
|
|
408
|
+
Use the GitHub API to get the latest (5.50) tesseract installer URL for Windows.
|
|
410
409
|
"""
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
)
|
|
410
|
+
# Use the GitHub API to get release data
|
|
411
|
+
api_url = "https://api.github.com/repos/tesseract-ocr/tesseract/releases/tags/5.5.0"
|
|
412
|
+
req = urllib.request.Request(api_url, headers={"User-Agent": "python-script"})
|
|
413
|
+
|
|
416
414
|
with urllib.request.urlopen(req) as resp:
|
|
417
|
-
|
|
415
|
+
data = json.loads(resp.read().decode())
|
|
418
416
|
|
|
419
|
-
#
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
417
|
+
# Search through the 'assets' list for the .exe
|
|
418
|
+
for asset in data.get("assets", []):
|
|
419
|
+
name = asset.get("name", "")
|
|
420
|
+
print("name: ", name)
|
|
421
|
+
if re.match(r"tesseract-ocr-w64-setup-.*\.exe", name):
|
|
422
|
+
print("found tesseract download url: ", asset.get("browser_download_url"))
|
|
423
|
+
return asset.get("browser_download_url")
|
|
424
|
+
else:
|
|
425
|
+
print("Not a tesseract installer: ", name)
|
|
426
|
+
|
|
427
|
+
raise RuntimeError("Could not find Windows installer in GitHub assets.")
|
|
428
428
|
|
|
429
429
|
|
|
430
430
|
def _find_tesseract_bin_from_prefix(prefix: Path) -> Path | None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: doc_redaction
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: Redact PDF/image-based documents, Word, or CSV/XLSX files using a Gradio-based GUI interface
|
|
5
5
|
Author-email: Sean Pedrick-Case <spedrickcase@lambeth.gov.uk>
|
|
6
6
|
Maintainer-email: Sean Pedrick-Case <spedrickcase@lambeth.gov.uk>
|
|
@@ -86,7 +86,7 @@ Follow these instructions to get the document redaction application running on y
|
|
|
86
86
|
|
|
87
87
|
### 1. Package installation
|
|
88
88
|
|
|
89
|
-
#### Install from source repo
|
|
89
|
+
#### Option 1 - Recommended: Install from source repo
|
|
90
90
|
|
|
91
91
|
Clone the repository and install in editable mode:
|
|
92
92
|
|
|
@@ -96,10 +96,12 @@ cd doc_redaction
|
|
|
96
96
|
pip install -e .
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
#####
|
|
99
|
+
##### Install extras (Paddle or Transformers/Torch VLM)
|
|
100
|
+
|
|
101
|
+
To install with PaddleOCR:
|
|
100
102
|
|
|
101
103
|
```bash
|
|
102
|
-
pip install -e ".[paddle
|
|
104
|
+
pip install -e ".[paddle]"
|
|
103
105
|
```
|
|
104
106
|
|
|
105
107
|
Note that the versions of both PaddleOCR and Torch installed by default are the CPU-only versions. If you want to install the equivalent GPU versions, you will need to run the following commands:
|
|
@@ -107,6 +109,13 @@ Note that the versions of both PaddleOCR and Torch installed by default are the
|
|
|
107
109
|
pip install paddlepaddle-gpu==3.2.1 --index-url https://www.paddlepaddle.org.cn/packages/stable/cu129/
|
|
108
110
|
```
|
|
109
111
|
|
|
112
|
+
If you want to run VLMs / LLMs with the transformers package:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install -e ".[vlm]"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
|
|
110
119
|
**Note:** It is difficult to get paddlepaddle gpu working in an environment alongside torch. You may well need to reinstall the cpu version to ensure compatibility, and run paddlepaddle-gpu in a separate environment without torch installed. If you get errors related to .dll files following paddle gpu install, you may need to install the latest c++ redistributables. For Windows, you can find them [here](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
|
111
120
|
|
|
112
121
|
```bash
|
|
@@ -114,7 +123,7 @@ pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cu129
|
|
|
114
123
|
pip install torchvision --index-url https://download.pytorch.org/whl/cu129
|
|
115
124
|
```
|
|
116
125
|
|
|
117
|
-
#### Install from PyPI
|
|
126
|
+
#### Option 2 - Install from PyPI
|
|
118
127
|
|
|
119
128
|
Create a virtual environment (recommended) and install **doc_redaction**.
|
|
120
129
|
|
|
@@ -132,15 +141,21 @@ The package is published on PyPI as **`doc-redaction`** (import name **`doc_reda
|
|
|
132
141
|
pip install doc_redaction
|
|
133
142
|
```
|
|
134
143
|
|
|
135
|
-
Optional extras (same as in `pyproject.toml`):
|
|
144
|
+
Optional extras (same as in `pyproject.toml`). For installing paddleOCR:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install "doc_redaction[paddle]"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
For running VLMs / LLMs with the transformers package:
|
|
136
151
|
|
|
137
152
|
```bash
|
|
138
|
-
pip install "doc_redaction[
|
|
153
|
+
pip install "doc_redaction[vlm]"
|
|
139
154
|
```
|
|
140
155
|
|
|
141
156
|
For programmatic use (CLI-first API matching Gradio `api_name` routes), see **[Python Package usage (Python)](https://seanpedrick-case.github.io/doc_redaction/src/python_package_usage.html)**. The console script **`cli_redact`** is available after install.
|
|
142
157
|
|
|
143
|
-
**Web UI from a PyPI install:** You *can* start the Gradio UI after `pip install doc_redaction` by running:
|
|
158
|
+
**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):
|
|
144
159
|
|
|
145
160
|
```bash
|
|
146
161
|
python -m app
|
|
@@ -154,21 +169,21 @@ python -m app
|
|
|
154
169
|
|
|
155
170
|
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).
|
|
156
171
|
|
|
157
|
-
#### Docker installation
|
|
172
|
+
#### Option 3 - Docker installation
|
|
158
173
|
|
|
159
174
|
The doc_redaction Redaction app can be installed by using the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) or Docker compose files ([llama.cpp](https://github.com/ggml-org/llama.cpp), [vLLM](https://docs.vllm.ai/en/stable/)) provided in the repo.
|
|
160
175
|
|
|
161
|
-
##### Without Llama.cpp / vLLM inference server
|
|
162
|
-
|
|
163
|
-
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
164
|
-
|
|
165
176
|
##### With Llama.cpp / vLLM inference server
|
|
166
177
|
|
|
167
178
|
The project now has Docker and Docker compose files available to pair running the Redaction app with local inference servers powered by [llama.cpp](https://github.com/ggml-org/llama.cpp), or [vLLM](https://docs.vllm.ai/en/stable/). 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.
|
|
168
179
|
|
|
169
180
|
For Llama.cpp, you can use the [docker-compose_llama.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/docker-compose_llama.yml) file, and for vLLM, you can use the [docker-compose_vllm.yml](https://github.com/seanpedrick-case/doc_redaction/blob/main/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.
|
|
170
181
|
|
|
171
|
-
You will need ~40
|
|
182
|
+
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](https://unsloth.ai/docs/models/qwen3.5) for more details on working with GGUF files for Qwen 3.5.
|
|
183
|
+
|
|
184
|
+
##### Without Llama.cpp / vLLM inference server
|
|
185
|
+
|
|
186
|
+
If you want a working Docker installation without GPU support, you can install from the [Dockerfile](https://github.com/seanpedrick-case/doc_redaction/blob/main/Dockerfile) in the repo. A working example of this, with the CPU version of PaddleOCR, can be found on [Hugging Face](https://huggingface.co/spaces/seanpedrickcase/document_redaction). 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.
|
|
172
187
|
|
|
173
188
|
### 2. Install prerequisites: Tesseract and Poppler
|
|
174
189
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "doc_redaction"
|
|
7
|
-
version = "2.2.
|
|
7
|
+
version = "2.2.6"
|
|
8
8
|
description = "Redact PDF/image-based documents, Word, or CSV/XLSX files using a Gradio-based GUI interface"
|
|
9
9
|
readme = "README_PYPI.md"
|
|
10
10
|
authors = [
|
|
@@ -2569,6 +2569,17 @@ ENFORCE_COST_CODES = convert_string_to_boolean(
|
|
|
2569
2569
|
if ENFORCE_COST_CODES:
|
|
2570
2570
|
GET_COST_CODES = True
|
|
2571
2571
|
|
|
2572
|
+
COST_CODE_ACCORDION_OPEN = convert_string_to_boolean(
|
|
2573
|
+
get_or_create_env_var("COST_CODE_ACCORDION_OPEN", "True")
|
|
2574
|
+
)
|
|
2575
|
+
|
|
2576
|
+
SESSION_DEFAULT_COST_CODES_FILENAME = get_or_create_env_var(
|
|
2577
|
+
"SESSION_DEFAULT_COST_CODES_FILENAME", "session_default_cost_codes.csv"
|
|
2578
|
+
)
|
|
2579
|
+
|
|
2580
|
+
SHOW_SET_DEFAULT_COST_CODE_BUTTON = convert_string_to_boolean(
|
|
2581
|
+
get_or_create_env_var("SHOW_SET_DEFAULT_COST_CODE_BUTTON", "True")
|
|
2582
|
+
)
|
|
2572
2583
|
|
|
2573
2584
|
###
|
|
2574
2585
|
# WHOLE DOCUMENT API OPTIONS
|
|
@@ -1384,6 +1384,10 @@ def _call_inference_server_vlm_api(
|
|
|
1384
1384
|
# generated so far on each chunk). Printing every chunk reprints completed lines.
|
|
1385
1385
|
# Others stream incremental tokens only. Support both.
|
|
1386
1386
|
accumulated_response = ""
|
|
1387
|
+
# Qwen3 / vLLM --reasoning-parser: assistant text may stream only in
|
|
1388
|
+
# delta.reasoning_content (or reasoning) while content stays empty. Non-streaming
|
|
1389
|
+
# responses are handled by _extract_choice_message_text; mirror that here.
|
|
1390
|
+
accumulated_reasoning = ""
|
|
1387
1391
|
# Track only the current in-progress line (since the last newline) so GUI line
|
|
1388
1392
|
# reporting doesn't repeatedly emit the entire response.
|
|
1389
1393
|
line_buffer = ""
|
|
@@ -1407,7 +1411,30 @@ def _call_inference_server_vlm_api(
|
|
|
1407
1411
|
|
|
1408
1412
|
if "choices" in chunk and len(chunk["choices"]) > 0:
|
|
1409
1413
|
delta = chunk["choices"][0].get("delta", {})
|
|
1410
|
-
token = delta.get("content"
|
|
1414
|
+
token = delta.get("content") or ""
|
|
1415
|
+
reason_piece = delta.get("reasoning_content")
|
|
1416
|
+
if not isinstance(reason_piece, str):
|
|
1417
|
+
reason_piece = ""
|
|
1418
|
+
if not reason_piece:
|
|
1419
|
+
r_alt = delta.get("reasoning")
|
|
1420
|
+
reason_piece = (
|
|
1421
|
+
r_alt if isinstance(r_alt, str) else ""
|
|
1422
|
+
)
|
|
1423
|
+
|
|
1424
|
+
if reason_piece:
|
|
1425
|
+
if reason_piece == accumulated_reasoning:
|
|
1426
|
+
pass
|
|
1427
|
+
elif (
|
|
1428
|
+
accumulated_reasoning
|
|
1429
|
+
and reason_piece.startswith(
|
|
1430
|
+
accumulated_reasoning
|
|
1431
|
+
)
|
|
1432
|
+
):
|
|
1433
|
+
accumulated_reasoning = reason_piece
|
|
1434
|
+
else:
|
|
1435
|
+
accumulated_reasoning += reason_piece
|
|
1436
|
+
output_tokens += 1
|
|
1437
|
+
|
|
1411
1438
|
if not token:
|
|
1412
1439
|
continue
|
|
1413
1440
|
if token == accumulated_response:
|
|
@@ -1460,7 +1487,12 @@ def _call_inference_server_vlm_api(
|
|
|
1460
1487
|
|
|
1461
1488
|
print() # newline after stream finishes
|
|
1462
1489
|
|
|
1463
|
-
|
|
1490
|
+
_content_stripped = accumulated_response.strip()
|
|
1491
|
+
text = (
|
|
1492
|
+
accumulated_response
|
|
1493
|
+
if _content_stripped
|
|
1494
|
+
else accumulated_reasoning.strip()
|
|
1495
|
+
)
|
|
1464
1496
|
stream_elapsed_s = time.perf_counter() - stream_start
|
|
1465
1497
|
|
|
1466
1498
|
# Try to extract token usage from final chunk if available
|