From 839d7b9a7e1340cbc01bc0dd8ba03c1a02ab2408 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 04:09:33 +0200 Subject: [PATCH 1/7] ModelZoo: avoid Azure EP (displacing CPU) --- src/eynollah/model_zoo/model_zoo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eynollah/model_zoo/model_zoo.py b/src/eynollah/model_zoo/model_zoo.py index 1d15ee2..5a0a867 100644 --- a/src/eynollah/model_zoo/model_zoo.py +++ b/src/eynollah/model_zoo/model_zoo.py @@ -334,6 +334,8 @@ class EynollahModelZoo: providers = [provider for provider in providers if provider[:-17] in override_providers] # configure and prioritise + if 'AzureExecutionProvider' in providers: + providers.remove('AzureExecutionProvider') if 'CUDAExecutionProvider' in providers: providers.remove('CUDAExecutionProvider') if gpu >= 0: From efe4aa8b0c1f9f57774be54d498451244e5f26b3 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 04:10:47 +0200 Subject: [PATCH 2/7] mbreorder: fix init (wrong way to load model) --- src/eynollah/mb_ro_on_layout.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/eynollah/mb_ro_on_layout.py b/src/eynollah/mb_ro_on_layout.py index 6c0477b..5bab608 100644 --- a/src/eynollah/mb_ro_on_layout.py +++ b/src/eynollah/mb_ro_on_layout.py @@ -42,7 +42,6 @@ class Reorder(Eynollah): self.logger = logger or logging.getLogger('eynollah.mbreorder') self.model_zoo = model_zoo - self.model_zoo.load_model('reading_order') self.setup_models(device=device) def setup_models(self, device=''): From 25865372d0a7b3f7fabacd68fb02ab8689bc94db Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 04:11:29 +0200 Subject: [PATCH 3/7] dependencies for `[OCR]`: add TF, avoid newer Torch (pulling CUDA 13) --- requirements-ocr.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-ocr.txt b/requirements-ocr.txt index dad26f4..0825e18 100644 --- a/requirements-ocr.txt +++ b/requirements-ocr.txt @@ -1,3 +1,5 @@ -torch +torch < 2.11 # avoid pull CUDA 13 (which will clash with 12) transformers <= 4.30.2 ; python_version < '3.10' transformers >= 5 ; python_version >= '3.10' +tensorflow[and-cuda] +tf-keras # avoid keras 3 (also needs TF_USE_LEGACY_KERAS=1) From b89e1b42965e18b4544d91a79954e8bced2c4ab6 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 04:24:33 +0200 Subject: [PATCH 4/7] ocrd-tool.json: differentiate inference-all and inference-layout --- src/eynollah/ocrd-tool.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/eynollah/ocrd-tool.json b/src/eynollah/ocrd-tool.json index 38a129d..48c1740 100644 --- a/src/eynollah/ocrd-tool.json +++ b/src/eynollah/ocrd-tool.json @@ -89,14 +89,14 @@ "name": "models_inference_all_v0_9_0", "type": "archive", "size": 5177204769, - "description": "Models for layout detection, reading order detection, textline detection, page extraction, column classification, table detection, binarization and image enhancement", + "description": "Models for layout detection, reading order detection, textline detection, page extraction, column classification, table detection, binarization and image enhancement, as well as OCR", "version_range": ">= v0.9.0" }, { - "url": "https://zenodo.org/records/21362927/files/models_inference_all_v0_9_0.zip", - "name": "models_inference_all_v0_9_0", + "url": "https://zenodo.org/records/21362927/files/models_inference_layout_v0_9_0.zip", + "name": "models_inference_layout_v0_9_0", "type": "archive", - "size": 5177204769, + "size": 1572255489, "description": "Models for layout detection, reading order detection, textline detection, page extraction, column classification, table detection, binarization and image enhancement", "version_range": ">= v0.9.0" }, From 0ab6e19f33abbe021a37221a948b3fd81931a301 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 12:46:13 +0200 Subject: [PATCH 5/7] configure ruff search path --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e6821a5..fdd41db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ source = ["eynollah"] [tool.ruff] line-length = 120 +include = ["pyproject.toml", "src/eynollah/**/*.py"] [tool.ruff.lint] ignore = [ From 4d97e3bf7ff3de7e6aa8a31ff8cdaf61a583ce33 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 12:46:33 +0200 Subject: [PATCH 6/7] training: fix typos found by ruff --- src/eynollah/training/utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/eynollah/training/utils.py b/src/eynollah/training/utils.py index e84ac66..d04a17b 100644 --- a/src/eynollah/training/utils.py +++ b/src/eynollah/training/utils.py @@ -1127,13 +1127,21 @@ def preprocess_img_ocr( if task == 'cnn-rnn-ocr': assert char_to_num, 'task is cnn-rnn-ocr, so preprocess_imgs_ocr should be passed "char_to_num"' lab = char_to_num(tf.strings.unicode_split(lab, input_encoding="UTF-8")) - yield_encoder = lambda x: x + def yield_encoder(x): + return x elif task == 'transformer-ocr': + import torch assert processor, 'task is transformer-ocr, so preprocess_imgs_ocr should be passed "processor"' # TODO make max_length configurable again, if deemed sensible - lab = [l if l != self.processor.tokenizer.pad_token_id else -100 - for l in processor.tokenizer(lab, padding="max_length", max_length=128).input_ids] - yield_encoder = lambda img_, lab_: {"pixel_values": processor(Image.fromarray(img_), return_tensors="pt").pixel_values.squeeze(), "labels": torch.tensor(lab_)} + lab = [tok if tok != processor.tokenizer.pad_token_id else -100 + for tok in processor.tokenizer(lab, + padding="max_length", + max_length=128 + ).input_ids] + def yield_encoder(img_, lab_): + return {"pixel_values": processor(Image.fromarray(img_), + return_tensors="pt").pixel_values.squeeze(), + "labels": torch.tensor(lab_)} yield yield_encoder(scale_image(img), lab) #to_yield = {"image": ret_x, "label": ret_y} From 9804d736ac06e6aa99764559b4f25fe4dc48428c Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 15 Jul 2026 13:59:43 +0200 Subject: [PATCH 7/7] CI: avoid CUDA dependencies here --- .github/workflows/test-eynollah.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-eynollah.yml b/.github/workflows/test-eynollah.yml index 82de94d..44910ce 100644 --- a/.github/workflows/test-eynollah.yml +++ b/.github/workflows/test-eynollah.yml @@ -64,6 +64,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + # preempt CUDA dependencies (which need core's recipe) + pip install onnxruntime tensorflow tf-keras "torch<2.11" + sed -i '/onnxruntime-gpu/d;/tensorrt/d;/torch/d;/tensorflow/d' requirements*.txt make install-dev EXTRAS=OCR,plotting make deps-test EXTRAS=OCR,plotting