diff --git a/.circleci/config.yml b/.circleci/config.yml index 05f840f..5ef5c56 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,33 +13,32 @@ jobs: working_directory: '~/repo' steps: - checkout - - restore_cache: - keys: - - v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements.test.txt" }} - run: name: install dependencies command: | - python3 -m venv venv - . venv/bin/activate pip install --upgrade pip pip install -r requirements.test.txt pip install -r requirements.txt sudo apt-get update -y sudo apt-get install -y imagemagick - make models + pip install . + - restore_cache: + keys: + # ocrd-resources depends on the model files registered under ocrd_anybaseocr/ocrd-tool.json + - v2-models-{{ checksum "ocrd_anybaseocr/ocrd-tool.json" }} + - run: + name: download models + command: make models - save_cache: paths: - - ./venv - - ./ocrd-resources - # ocrd-resources depends on the model files registered under core/ocrd-tool json - # but let's assume these won't change without changing requirements.txt for now - key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements.test.txt" }} + - ~/.local/share/ocrd-resources + key: v2-models-{{ checksum "ocrd_anybaseocr/ocrd-tool.json" }} - run: name: run unit tests - command: . venv/bin/activate && make test + command: make test - run: name: run CLI tests - command: . venv/bin/activate && pip install . && make cli-test + command: make cli-test - store_artifacts: path: test-reports destination: test-reports @@ -68,7 +67,7 @@ workflows: - test: matrix: parameters: - version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + version: ['3.8', '3.9', '3.10', '3.11'] - deploy-docker: filters: branches: diff --git a/Dockerfile b/Dockerfile index a887f1f..3f10c6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ocrd/core-cuda:v2.63.0 AS base +FROM ocrd/core-cuda-tf2:v2.70.0 AS base ARG VCS_REF ARG BUILD_DATE LABEL \ @@ -7,14 +7,14 @@ LABEL \ org.label-schema.vcs-url="https://github.com/OCR-D/ocrd_anybaseocr" \ org.label-schema.build-date=$BUILD_DATE -WORKDIR /build +WORKDIR /build/ocrd_anybaseocr COPY setup.py . COPY ocrd_anybaseocr/ocrd-tool.json . COPY ocrd_anybaseocr ./ocrd_anybaseocr COPY requirements.txt . COPY README.md . RUN pip install . \ - && rm -rf /build + && rm -rf /build/ocrd_anybaseocr WORKDIR /data VOLUME ["/data"] diff --git a/Makefile b/Makefile index 0772f59..ec4351d 100755 --- a/Makefile +++ b/Makefile @@ -67,10 +67,8 @@ ocrd_anybaseocr/pix2pixhd: # Download sample model TODO Add other models here .PHONY: models models: - ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-dewarp '*' - ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-block-segmentation '*' - ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-layout-analysis '*' - ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-tiseg '*' + ocrd resmgr download ocrd-anybaseocr-dewarp '*' + ocrd resmgr download ocrd-anybaseocr-layout-analysis '*' .PHONY: docker docker: @@ -106,7 +104,7 @@ test: assets-clean assets # Run CLI tests .PHONY: cli-test cli-test: assets-clean assets -cli-test: test-binarize test-deskew test-crop test-tiseg test-textline test-layout-analysis test-dewarp +cli-test: test-binarize test-deskew test-crop test-textline test-layout-analysis test-dewarp # Test binarization CLI .PHONY: test-binarize @@ -135,8 +133,8 @@ test-block-segmentation: test-tiseg # Test textline segmentation CLI .PHONY: test-textline -test-textline: test-tiseg - ocrd-anybaseocr-textline -m $(TESTDATA)/mets.xml -I TISEG-TEST -O TL-TEST +test-textline: test-crop + ocrd-anybaseocr-textline -m $(TESTDATA)/mets.xml -I CROP-TEST -O TL-TEST # Test page dewarping CLI .PHONY: test-dewarp diff --git a/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py b/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py index 89ea486..9e26fd5 100755 --- a/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py +++ b/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py @@ -107,7 +107,7 @@ def setup(self): sys.exit(1) self.opt, self.model = prepare_options( gpu_id=self.parameter['gpu_id'], - model_path=model_path, + model_path=model_path.absolute(), resize_or_crop=self.parameter['resize_mode'], loadSize=self.parameter['resize_height'], fineSize=self.parameter['resize_width'], diff --git a/requirements.txt b/requirements.txt index 19233b5..42695cc 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -keras +keras < 3.0 keras-preprocessing numpy >= 1.15.4 ocrd >= 2.31 @@ -10,7 +10,7 @@ scikit-image >= 0.17.2 scipy >= 1.4.1 setuptools >= 41.0.0 shapely -tensorflow +tensorflow < 2.16 torch>=1.1.0 torchvision >= 0.6.1 pix2pixhd # @ ./ocrd_anybaseocr/pix2pixhd diff --git a/tests/test_dewarp.py b/tests/test_dewarp.py index 49bb808..7b03ef9 100644 --- a/tests/test_dewarp.py +++ b/tests/test_dewarp.py @@ -14,7 +14,7 @@ class AnyocrDewarperTest(TestCase): def setUp(self): - self.model_path = Path(Path.cwd(), 'latest_net_G.pth') + self.model_path = 'latest_net_G.pth' self.resolver = Resolver() initLogging() diff --git a/tests/test_smoke.py b/tests/test_smoke.py index be7b495..4c2d2a8 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -3,23 +3,19 @@ from .base import main, CapturingTestCase as TestCase from ocrd_anybaseocr.cli.ocrd_anybaseocr_binarize import cli as OcrdAnybaseocrBinarizer -from ocrd_anybaseocr.cli.ocrd_anybaseocr_block_segmentation import cli as OcrdAnybaseocrBlockSegmenter from ocrd_anybaseocr.cli.ocrd_anybaseocr_cropping import cli as OcrdAnybaseocrCropper from ocrd_anybaseocr.cli.ocrd_anybaseocr_deskew import cli as OcrdAnybaseocrDeskewer from ocrd_anybaseocr.cli.ocrd_anybaseocr_dewarp import cli as OcrdAnybaseocrDewarper from ocrd_anybaseocr.cli.ocrd_anybaseocr_layout_analysis import cli as OcrdAnybaseocrLayoutAnalyser from ocrd_anybaseocr.cli.ocrd_anybaseocr_textline import cli as OcrdAnybaseocrTextline -from ocrd_anybaseocr.cli.ocrd_anybaseocr_tiseg import cli as OcrdAnybaseocrTiseg CLIS = [ OcrdAnybaseocrBinarizer, - OcrdAnybaseocrBlockSegmenter, OcrdAnybaseocrCropper, OcrdAnybaseocrDeskewer, OcrdAnybaseocrDewarper, OcrdAnybaseocrLayoutAnalyser, OcrdAnybaseocrTextline, - OcrdAnybaseocrTiseg ] class SmokeTest(TestCase):