From 824e58ac14635d97407f3a405f7c10cbe79a3228 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:02:47 +0200 Subject: [PATCH 01/14] disable py3.8, enable 3.11/3.12/3.13 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82e0fd7f6..837307af7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, '3.10', '3.11'] + python-version: [3.9, '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 From b1851c7db99b96414c106c0d05d0196bb0246f6a Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:03:59 +0200 Subject: [PATCH 02/14] remove py3.8 in setup.cfg/conda recipe --- conda/recipe.yaml | 6 +++--- setup.cfg | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/recipe.yaml b/conda/recipe.yaml index 9d8ed34ae..0150ba9dc 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -15,13 +15,13 @@ build: requirements: build: - - python>=3.8,<3.12 + - python>=3.9,<3.14 - setuptools>=36.6.0,<70.0.0 - pbr host: - - python>=3.8,<3.12 + - python>=3.9,<3.14 run: - - python>=3.8,<3.12 + - python>=3.9,<3.14 - python-bidi~=0.4.0 - lxml - regex diff --git a/setup.cfg b/setup.cfg index 1400d5d12..edd8f8404 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ max_line_length = 160 exclude = tests/* [options] -python_requires = >=3.8,<=3.11.99 +python_requires = >=3.9,<=3.13.99 install_requires = jsonschema lxml From 96f12cdf5c62445436f25e686e64fc60edf00213 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:10:17 +0200 Subject: [PATCH 03/14] bump up scikit-image/scipy versions --- conda/recipe.yaml | 4 ++-- environment.yml | 4 ++-- environment_cuda.yml | 4 ++-- setup.cfg | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conda/recipe.yaml b/conda/recipe.yaml index 0150ba9dc..c643806a7 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -29,13 +29,13 @@ requirements: - click>=8.1 - numpy~=1.23.0 - pillow>=9.2.0 - - scipy~=1.11.0 + - scipy~=1.14.0 - jinja2~=3.0 - torchvision - pytorch~=2.1.0 - cudatoolkit - jsonschema - - scikit-image~=0.21.0 + - scikit-image~=0.24.0 - scikit-learn~=1.2.1 - shapely~=1.8.5 - pyvips diff --git a/environment.yml b/environment.yml index 47e991eeb..ade8e836a 100644 --- a/environment.yml +++ b/environment.yml @@ -11,13 +11,13 @@ dependencies: - click>=8.1 - numpy~=1.23.0 - pillow~=9.2.0 - - scipy~=1.10.0 + - scipy~=1.14.0 - jinja2~=3.0 - conda-forge::torchvision-cpu>=0.5.0 - conda-forge::pytorch-cpu~=2.1.0 - jsonschema - scikit-learn~=1.2.1 - - scikit-image~=0.21.0 + - scikit-image~=0.24.0 - shapely~=1.8.5 - pyvips - imagemagick>=7.1.0 diff --git a/environment_cuda.yml b/environment_cuda.yml index fa0e3edc9..8c3340a66 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -11,14 +11,14 @@ dependencies: - click>=8.1 - numpy~=1.23 - pillow>=9.2.0 - - scipy~=1.10.0 + - scipy~=1.14.0 - jinja2~=3.0 - conda-forge::torchvision>=0.5.0 - conda-forge::pytorch~=2.1.0 - cudatoolkit>=9.2 - jsonschema - scikit-learn~=1.2.1 - - scikit-image~=0.21.0 + - scikit-image~=0.24.0 - shapely~=1.8.5 - pyvips - imagemagick>=7.1.0 diff --git a/setup.cfg b/setup.cfg index edd8f8404..118fb018f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = numpy~=1.23.0 Pillow>=9.2.0 regex - scipy~=1.10.0 # bump up to latest release with py3.8 EOL + scipy~=1.14.0 protobuf>=3.0.0 coremltools~=6.0 jinja2~=3.0 @@ -55,7 +55,7 @@ install_requires = torchvision>=0.5.0 torch~=2.1.0 scikit-learn~=1.2.1 - scikit-image~=0.21.0 + scikit-image~=0.24.0 shapely~=1.8.5 pyarrow lightning~=2.2.0 From d3a1be94c1d2a7684d294c0f771830d668972129 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:16:27 +0200 Subject: [PATCH 04/14] reduce scipy version to 1.13.x 1.14.x does not support py3.9 --- conda/recipe.yaml | 2 +- environment.yml | 2 +- environment_cuda.yml | 2 +- setup.cfg | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/recipe.yaml b/conda/recipe.yaml index c643806a7..4e6f345a6 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -29,7 +29,7 @@ requirements: - click>=8.1 - numpy~=1.23.0 - pillow>=9.2.0 - - scipy~=1.14.0 + - scipy~=1.13.0 - jinja2~=3.0 - torchvision - pytorch~=2.1.0 diff --git a/environment.yml b/environment.yml index ade8e836a..8365f643d 100644 --- a/environment.yml +++ b/environment.yml @@ -11,7 +11,7 @@ dependencies: - click>=8.1 - numpy~=1.23.0 - pillow~=9.2.0 - - scipy~=1.14.0 + - scipy~=1.13.0 - jinja2~=3.0 - conda-forge::torchvision-cpu>=0.5.0 - conda-forge::pytorch-cpu~=2.1.0 diff --git a/environment_cuda.yml b/environment_cuda.yml index 8c3340a66..0e345014c 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -11,7 +11,7 @@ dependencies: - click>=8.1 - numpy~=1.23 - pillow>=9.2.0 - - scipy~=1.14.0 + - scipy~=1.13.0 - jinja2~=3.0 - conda-forge::torchvision>=0.5.0 - conda-forge::pytorch~=2.1.0 diff --git a/setup.cfg b/setup.cfg index 118fb018f..35bae344a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = numpy~=1.23.0 Pillow>=9.2.0 regex - scipy~=1.14.0 + scipy~=1.13.0 protobuf>=3.0.0 coremltools~=6.0 jinja2~=3.0 From 0cc0cb66312c01e7f7ef45711977fadad0262caa Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:25:20 +0200 Subject: [PATCH 05/14] bump all libraries and restrict python interpeter versions --- .github/workflows/test.yml | 2 +- conda/recipe.yaml | 14 +++++++------- environment.yml | 10 +++++----- environment_cuda.yml | 8 ++++---- setup.cfg | 14 +++++++------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 837307af7..e8c393ab4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, '3.10', '3.11', '3.12', '3.13'] + python-version: [3.9, '3.10', '3.11'] steps: - uses: actions/checkout@v4 diff --git a/conda/recipe.yaml b/conda/recipe.yaml index 4e6f345a6..77c01b689 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -15,24 +15,24 @@ build: requirements: build: - - python>=3.9,<3.14 + - python>=3.9,<3.12 - setuptools>=36.6.0,<70.0.0 - pbr host: - - python>=3.9,<3.14 + - python>=3.9,<3.12 run: - - python>=3.9,<3.14 + - python>=3.9,<3.12 - python-bidi~=0.4.0 - lxml - regex - requests - click>=8.1 - - numpy~=1.23.0 + - numpy~=2.0.0 - pillow>=9.2.0 - scipy~=1.13.0 - jinja2~=3.0 - torchvision - - pytorch~=2.1.0 + - pytorch~=2.4.0 - cudatoolkit - jsonschema - scikit-image~=0.24.0 @@ -41,9 +41,9 @@ requirements: - pyvips - coremltools - pyarrow - - lightning~=2.2 + - lightning~=2.4.0 - torchmetrics>=1.1.0 - - conda-forge::threadpoolctl~=3.4.0 + - conda-forge::threadpoolctl~=3.5.0 - albumentations - rich diff --git a/environment.yml b/environment.yml index 8365f643d..6c5681452 100644 --- a/environment.yml +++ b/environment.yml @@ -9,12 +9,12 @@ dependencies: - regex - requests - click>=8.1 - - numpy~=1.23.0 + - numpy~=2.0.0 - pillow~=9.2.0 - scipy~=1.13.0 - jinja2~=3.0 - conda-forge::torchvision-cpu>=0.5.0 - - conda-forge::pytorch-cpu~=2.1.0 + - conda-forge::pytorch-cpu~=2.4.0 - jsonschema - scikit-learn~=1.2.1 - scikit-image~=0.24.0 @@ -23,13 +23,13 @@ dependencies: - imagemagick>=7.1.0 - pyarrow - importlib-resources>=1.3.0 - - conda-forge::lightning~=2.2.0 + - conda-forge::lightning~=2.4.0 - conda-forge::torchmetrics>=1.1.0 - - conda-forge::threadpoolctl~=3.4 + - conda-forge::threadpoolctl~=3.5.0 - pip - albumentations - rich - setuptools>=36.6.0,<70.0.0 - pip: - - coremltools~=6.0 + - coremltools~=8.0 - file:. diff --git a/environment_cuda.yml b/environment_cuda.yml index 0e345014c..84db83f9c 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -14,7 +14,7 @@ dependencies: - scipy~=1.13.0 - jinja2~=3.0 - conda-forge::torchvision>=0.5.0 - - conda-forge::pytorch~=2.1.0 + - conda-forge::pytorch~=2.4.0 - cudatoolkit>=9.2 - jsonschema - scikit-learn~=1.2.1 @@ -24,13 +24,13 @@ dependencies: - imagemagick>=7.1.0 - pyarrow - importlib-resources>=1.3.0 - - conda-forge::lightning~=2.2.0 + - conda-forge::lightning~=2.4.0 - conda-forge::torchmetrics>=1.1.0 - - conda-forge::threadpoolctl~=3.4 + - conda-forge::threadpoolctl~=3.5.0 - pip - albumentations - rich - setuptools>=36.6.0,<70.0.0 - pip: - - coremltools~=6.0 + - coremltools~=8.0 - file:. diff --git a/setup.cfg b/setup.cfg index 35bae344a..de9d14ed4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,29 +38,29 @@ max_line_length = 160 exclude = tests/* [options] -python_requires = >=3.9,<=3.13.99 +python_requires = >=3.9,<3.12 install_requires = jsonschema lxml requests click>=8.1 - numpy~=1.23.0 + numpy~=2.0.0 Pillow>=9.2.0 regex scipy~=1.13.0 protobuf>=3.0.0 - coremltools~=6.0 + coremltools~=8.0 jinja2~=3.0 python-bidi~=0.4.0 torchvision>=0.5.0 - torch~=2.1.0 - scikit-learn~=1.2.1 + torch~=2.4.0 + scikit-learn~=1.5.0 scikit-image~=0.24.0 shapely~=1.8.5 pyarrow - lightning~=2.2.0 + lightning~=2.4.0 torchmetrics>=1.1.0 - threadpoolctl~=3.4.0 + threadpoolctl~=3.5.0 importlib-resources>=1.3.0 rich From 3dce8635cfc6b46574b5c4ab87b06a88ebdec3ee Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 15:27:53 +0200 Subject: [PATCH 06/14] remove 3.8 support in metadata --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index de9d14ed4..711905114 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,6 @@ classifier = Intended Audience :: Science/Research License :: OSI Approved :: Apache Software License Operating System :: POSIX - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 From 99e8e58f82cff9b82d7455c576f5a237ce9a9a72 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Fri, 18 Oct 2024 16:35:26 +0200 Subject: [PATCH 07/14] s/add/union --- tests/test_newpolygons.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_newpolygons.py b/tests/test_newpolygons.py index 7c24ffb7b..119d99e7a 100644 --- a/tests/test_newpolygons.py +++ b/tests/test_newpolygons.py @@ -249,7 +249,7 @@ def test_ketoscli_train_old_model(self): fp = str(Path(tempdir) / "test.xml") self._test_ketoscli( - args=['train', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'add', '-o', mfp, '--workers', '0', self.segmented_img], + args=['train', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'union', '-o', mfp, '--workers', '0', self.segmented_img], expect_legacy=False, check_exit_code=[0, 1], # Model may not improve during training ) @@ -268,7 +268,7 @@ def test_ketoscli_train_old_model_force_legacy(self): fp = str(Path(tempdir) / "test.xml") self._test_ketoscli( - args=['train', '--legacy-polygons', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'add', '-o', mfp, '--workers', '0', self.segmented_img], + args=['train', '--legacy-polygons', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'union', '-o', mfp, '--workers', '0', self.segmented_img], expect_legacy=True, check_exit_code=[0, 1], # Model may not improve during training ) @@ -326,7 +326,7 @@ def test_ketoscli_pretrain_old_model(self): fp = str(Path(tempdir) / "test.xml") self._test_ketoscli( - args=['pretrain', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'add', '-o', mfp, '--workers', '0', self.segmented_img], + args=['pretrain', '-f', 'xml', '-N', '1', '-q', 'fixed', '-i', self.old_model_path, '--resize', 'union', '-o', mfp, '--workers', '0', self.segmented_img], expect_legacy=False, check_exit_code=[0, 1], # Model may not improve during training ) @@ -349,7 +349,7 @@ def _assertWarnsWhenTrainingArrow(self, if force_legacy: args = ['--legacy-polygons'] + args if from_model: - args = ['-i', from_model, '--resize', 'add'] + args + args = ['-i', from_model, '--resize', 'union'] + args print("ketos", 'train', *args) run = self.runner.invoke(ketos_cli, ['train'] + args) From 5a2af52d55337446cce94f7e335f9bdcd96c159d Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Sun, 20 Oct 2024 16:27:30 +0200 Subject: [PATCH 08/14] fix transcription interface tests --- tests/test_transcribe.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/test_transcribe.py b/tests/test_transcribe.py index 044779813..11d02ceab 100644 --- a/tests/test_transcribe.py +++ b/tests/test_transcribe.py @@ -8,6 +8,7 @@ from lxml import etree from PIL import Image +from kraken import containers from kraken.transcribe import TranscriptionInterface thisfile = Path(__file__).resolve().parent @@ -18,16 +19,25 @@ class TestTranscriptionInterface(unittest.TestCase): """ Test of the transcription interface generation """ + def setUp(self): + with open(resources /'records.json', 'r') as fp: + self.box_records = [containers.BBoxOCRRecord(**x) for x in json.load(fp)] + + self.box_segmentation = containers.Segmentation(type='bbox', + imagename='foo.png', + text_direction='horizontal-lr', + lines=self.box_records, + script_detection=True, + regions={}) + + self.im = Image.open(resources / 'input.jpg') def test_transcription_generation(self): """ Tests creation of transcription interfaces with segmentation. """ tr = TranscriptionInterface() - with open(resources / 'segmentation.json') as fp: - seg = json.load(fp) - with Image.open(resources / 'input.jpg') as im: - tr.add_page(im, seg) + tr.add_page(im = self.im, segmentation=self.box_segmentation) fp = BytesIO() tr.write(fp) # this will not throw an exception ever so we need a better validator From bf7bf15af668aaa42de0156ce1e202f5312f0830 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Mon, 21 Oct 2024 12:25:35 +0200 Subject: [PATCH 09/14] Remove mentions/building of conda packages There are still no coremltools packages we can use --- .github/workflows/test.yml | 46 +------------------------------ README.rst | 8 +----- conda/recipe.yaml | 55 -------------------------------------- docs/index.rst | 20 ++++---------- 4 files changed, 7 insertions(+), 122 deletions(-) delete mode 100644 conda/recipe.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8c393ab4..934e1505a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,53 +61,9 @@ jobs: name: pypi_packages path: dist/* - build-n-publish-anaconda: - name: Build and publish anaconda packages - needs: lint_and_test - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: conda-incubator/setup-miniconda@v3 - with: - python-version: 3.9 - miniforge-variant: Mambaforge - - name: install dependencies build - shell: bash -l {0} - run: mamba install colorama pip ruamel ruamel.yaml rich jsonschema conda-verify anaconda-client - - name: Build linux-64 conda package - uses: prefix-dev/rattler-build-action@v0.2.6 - with: - recipe-path: "conda/recipe.yaml" - build-args: "--experimental --target-platform linux-64" - - name: Build osx-64 conda package - uses: prefix-dev/rattler-build-action@v0.2.6 - with: - recipe-path: "conda/recipe.yaml" - build-args: "--experimental --target-platform osx-64" -# - name: Build osx-arm64 conda package -# uses: prefix-dev/rattler-build-action@v0.2.6 -# with: -# recipe-path: "conda/recipe.yaml" -# build-args: "--experimental --target-platform osx-arm64" - - name: Upload conda package - run: | - for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do - echo "Uploading ${pkg}" - rattler-build upload anaconda -o mittagessen -a ${{ secrets.ANACONDA_TOKEN }} "${pkg}" - done - - name: Upload conda artifacts to GH storage - uses: actions/upload-artifact@v4 - with: - name: conda_packages - path: output/*/*.conda - autodraft-gh-release: name: Create github release - needs: [build-n-publish-anaconda, build-n-publish-pypi] + needs: build-n-publish-pypi runs-on: ubuntu-latest steps: diff --git a/README.rst b/README.rst index 747b1036c..72632cee2 100644 --- a/README.rst +++ b/README.rst @@ -25,18 +25,12 @@ Installation kraken only runs on **Linux or Mac OS X**. Windows is not supported. -The latest stable releases can be installed either from `PyPi `_: +The latest stable releases can be installed from `PyPi `_: :: $ pip install kraken -or through `conda `_: - -:: - - $ conda install -c conda-forge -c mittagessen kraken - If you want direct PDF and multi-image TIFF/JPEG2000 support it is necessary to install the `pdf` extras package for PyPi: diff --git a/conda/recipe.yaml b/conda/recipe.yaml deleted file mode 100644 index 77c01b689..000000000 --- a/conda/recipe.yaml +++ /dev/null @@ -1,55 +0,0 @@ -context: - git_url: . - git_tag: ${{ git.latest_tag(git_url) }} - -package: - name: kraken - version: ${{ git_tag }} - -source: - git: ${{ git_url }} - tag: ${{ git_tag }} - -build: - script: pip install --no-deps . - -requirements: - build: - - python>=3.9,<3.12 - - setuptools>=36.6.0,<70.0.0 - - pbr - host: - - python>=3.9,<3.12 - run: - - python>=3.9,<3.12 - - python-bidi~=0.4.0 - - lxml - - regex - - requests - - click>=8.1 - - numpy~=2.0.0 - - pillow>=9.2.0 - - scipy~=1.13.0 - - jinja2~=3.0 - - torchvision - - pytorch~=2.4.0 - - cudatoolkit - - jsonschema - - scikit-image~=0.24.0 - - scikit-learn~=1.2.1 - - shapely~=1.8.5 - - pyvips - - coremltools - - pyarrow - - lightning~=2.4.0 - - torchmetrics>=1.1.0 - - conda-forge::threadpoolctl~=3.5.0 - - albumentations - - rich - -about: - homepage: https://kraken.re - license: Apache-2.0 - summary: 'OCR/HTR engine for all the languages' - repository: https://github.com/mittagessen/kraken - documentation: https://kraken.re diff --git a/docs/index.rst b/docs/index.rst index dda41e35e..4c1076a09 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -67,22 +67,12 @@ or respectively. -Installation using Conda ------------------------- +Development Branch Installation using Conda +------------------------------------------- -To install the stable version through `conda `_: - -.. code-block:: console - - $ conda install -c conda-forge -c mittagessen kraken - -Again PDF/multi-page TIFF/JPEG2000 support requires some additional dependencies: - -.. code-block:: console - - $ conda install -c conda-forge pyvips - -The git repository contains some environment files that aid in setting up the latest development version: +To install the latest development branch through `conda +`_ clone the kraken git repository and install with the +provided environment files: .. code-block:: console From 06aa9c2f90a9ee42673f1b8195a4208376b60da3 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Tue, 22 Oct 2024 12:39:17 +0200 Subject: [PATCH 10/14] bump up shapely version just to see what will happen --- environment.yml | 2 +- environment_cuda.yml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index 6c5681452..d194768d4 100644 --- a/environment.yml +++ b/environment.yml @@ -18,7 +18,7 @@ dependencies: - jsonschema - scikit-learn~=1.2.1 - scikit-image~=0.24.0 - - shapely~=1.8.5 + - shapely~=2.0.6 - pyvips - imagemagick>=7.1.0 - pyarrow diff --git a/environment_cuda.yml b/environment_cuda.yml index 84db83f9c..3f3cbfc8a 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -19,7 +19,7 @@ dependencies: - jsonschema - scikit-learn~=1.2.1 - scikit-image~=0.24.0 - - shapely~=1.8.5 + - shapely~=2.0.6 - pyvips - imagemagick>=7.1.0 - pyarrow diff --git a/setup.cfg b/setup.cfg index 711905114..85ba10344 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,7 +55,7 @@ install_requires = torch~=2.4.0 scikit-learn~=1.5.0 scikit-image~=0.24.0 - shapely~=1.8.5 + shapely~=2.0.6 pyarrow lightning~=2.4.0 torchmetrics>=1.1.0 From 73be59fc5809f6ff08da0986423841c5304f3cee Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Wed, 20 Nov 2024 15:53:17 +0100 Subject: [PATCH 11/14] bump up interpreter, coreml, and python-bidi version --- environment.yml | 4 ++-- environment_cuda.yml | 4 ++-- setup.cfg | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/environment.yml b/environment.yml index d194768d4..9688e59c8 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: - conda-forge dependencies: - python>=3.9 - - python-bidi~=0.4.0 + - python-bidi~=0.6.0 - lxml - regex - requests @@ -31,5 +31,5 @@ dependencies: - rich - setuptools>=36.6.0,<70.0.0 - pip: - - coremltools~=8.0 + - coremltools~=8.1 - file:. diff --git a/environment_cuda.yml b/environment_cuda.yml index 3f3cbfc8a..cdb6c95a5 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -4,7 +4,7 @@ channels: - conda-forge dependencies: - python>=3.9 - - python-bidi~=0.4.0 + - python-bidi~=0.6.0 - lxml - regex - requests @@ -32,5 +32,5 @@ dependencies: - rich - setuptools>=36.6.0,<70.0.0 - pip: - - coremltools~=8.0 + - coremltools~=8.1 - file:. diff --git a/setup.cfg b/setup.cfg index 85ba10344..a08f6ec8c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,6 +17,7 @@ classifier = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Topic :: Scientific/Engineering :: Image Recognition Topic :: Scientific/Engineering :: Artificial Intelligence @@ -37,7 +38,7 @@ max_line_length = 160 exclude = tests/* [options] -python_requires = >=3.9,<3.12 +python_requires = >=3.9,<3.13 install_requires = jsonschema lxml @@ -48,9 +49,9 @@ install_requires = regex scipy~=1.13.0 protobuf>=3.0.0 - coremltools~=8.0 + coremltools~=8.1 jinja2~=3.0 - python-bidi~=0.4.0 + python-bidi~=0.6.0 torchvision>=0.5.0 torch~=2.4.0 scikit-learn~=1.5.0 From c38590192b804b118f4fb042a44c026b57835adb Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Wed, 20 Nov 2024 15:54:28 +0100 Subject: [PATCH 12/14] enable python 3.12 support in gh action --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 934e1505a..8e3382851 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, '3.10', '3.11'] + python-version: [3.9, '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 @@ -42,10 +42,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Build a binary wheel and a source tarball run: | python -m pip install build --user @@ -96,10 +96,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install sphinx-multiversion run: python -m pip install sphinx-multiversion sphinx-autoapi - name: Create docs From 54998334c74e94e8fb385c669fb1733749d15c36 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Thu, 21 Nov 2024 16:48:11 +0100 Subject: [PATCH 13/14] shapely 2.x does not reverse coordinate order on offset --- kraken/lib/segmentation.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kraken/lib/segmentation.py b/kraken/lib/segmentation.py index 0eb7f0bdc..2c14d7bc9 100644 --- a/kraken/lib/segmentation.py +++ b/kraken/lib/segmentation.py @@ -757,14 +757,10 @@ def calculate_polygonal_environment(im: Image.Image = None, line = np.array(line.coords, dtype=float) offset_line = np.array(offset_line.coords, dtype=float) - # parallel_offset on the right reverses the coordinate order - if not topline: - offset_line = offset_line[::-1] # calculate magnitude-weighted average direction vector lengths = np.linalg.norm(np.diff(line.T), axis=0) p_dir = np.mean(np.diff(line.T) * lengths/lengths.sum(), axis=1) p_dir = (p_dir.T / np.sqrt(np.sum(p_dir**2, axis=-1))) - env_up, env_bottom = _calc_roi(line, bounds, baselines[:idx] + baselines[idx+1:], suppl_obj, p_dir) polygons.append(_extract_patch(env_up, From 1cbba578e3450d5808384716853c50cd00f3469b Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Thu, 21 Nov 2024 16:49:18 +0100 Subject: [PATCH 14/14] Pin to shapely to 2.0.x >= 2.0.6 --- environment.yml | 2 +- environment_cuda.yml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index 9688e59c8..6d192901b 100644 --- a/environment.yml +++ b/environment.yml @@ -18,7 +18,7 @@ dependencies: - jsonschema - scikit-learn~=1.2.1 - scikit-image~=0.24.0 - - shapely~=2.0.6 + - shapely>=2.0.6,~=2.0.6 - pyvips - imagemagick>=7.1.0 - pyarrow diff --git a/environment_cuda.yml b/environment_cuda.yml index cdb6c95a5..d9525927b 100644 --- a/environment_cuda.yml +++ b/environment_cuda.yml @@ -19,7 +19,7 @@ dependencies: - jsonschema - scikit-learn~=1.2.1 - scikit-image~=0.24.0 - - shapely~=2.0.6 + - shapely>=2.0.6,~=2.0.6 - pyvips - imagemagick>=7.1.0 - pyarrow diff --git a/setup.cfg b/setup.cfg index a08f6ec8c..73cb67fe4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,7 +56,7 @@ install_requires = torch~=2.4.0 scikit-learn~=1.5.0 scikit-image~=0.24.0 - shapely~=2.0.6 + shapely>=2.0.6,~=2.0.6 pyarrow lightning~=2.4.0 torchmetrics>=1.1.0