diff --git a/.circleci/config.yml b/.circleci/config.yml
index 919d30f..715caa1 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -19,6 +19,7 @@ jobs:
paths:
ocrd-resources
- run: make test
+ resource_class: large
workflows:
@@ -27,5 +28,5 @@ workflows:
- build-python:
matrix:
parameters:
- python-version: ['3.7', '3.8', '3.9', '3.10']
+ python-version: ['3.8', '3.9', '3.10', '3.11']
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
new file mode 100644
index 0000000..17b6cb8
--- /dev/null
+++ b/.github/workflows/docker-image.yml
@@ -0,0 +1,47 @@
+name: Docker Image CD
+
+on:
+ push:
+ branches: [ "master" ]
+ workflow_dispatch:
+ inputs:
+ docker-tagname:
+ description: Tag name of the Docker image
+ default: 'ocrd/sbb_binarization'
+
+env:
+ DOCKER_TAGNAME: ${{ github.evenv.inputs.docker-tagname || 'ocrd/sbb_binarization' }}
+
+jobs:
+
+ build:
+
+ runs-on: ubuntu-latest
+ permissions:
+ packages: write
+ contents: read
+
+ steps:
+ - uses: actions/checkout@v4
+ - # Activate cache export feature to reduce build time of image
+ name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Build the Docker image
+ run: make docker DOCKER_TAG=${{ env.DOCKER_TAGNAME }}
+ - name: Login to Dockerhub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
+ - name: Push image to Dockerhub
+ run: docker push ${{ env.DOCKER_TAGNAME }}
+ - name: Alias the Docker image for GHCR
+ run: docker tag ${{ env.DOCKER_TAGNAME }} ghcr.io/${{ github.repository }}
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Push image to Github Container Registry
+ run: docker push ghcr.io/${{ github.repository }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 53c6850..fc21ec4 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -3,7 +3,10 @@
name: CLI Tests
-on: [push, pull_request]
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
jobs:
build:
@@ -11,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ['3.7', '3.8', '3.9', '3.10']
+ python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v4
- name: Set up Python
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f71dc7b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+ARG DOCKER_BASE_IMAGE
+FROM $DOCKER_BASE_IMAGE
+ARG VCS_REF
+ARG BUILD_DATE
+LABEL \
+ maintainer="https://ocr-d.de/kontakt" \
+ org.label-schema.vcs-ref=$VCS_REF \
+ org.label-schema.vcs-url="https://github.com/qurator-spk/sbb_binarization" \
+ org.label-schema.build-date=$BUILD_DATE
+
+WORKDIR /build/sbb_binarization
+COPY pyproject.toml .
+COPY ocrd-tool.json .
+COPY sbb_binarize ./sbb_binarize
+COPY requirements.txt .
+COPY README.md .
+COPY Makefile .
+RUN make install
+RUN rm -rf /build/sbb_binarization
+
+WORKDIR /data
+VOLUME ["/data"]
diff --git a/Makefile b/Makefile
index e4f5b87..23b6476 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,9 @@
# BEGIN-EVAL makefile-parser --make-help Makefile
+# should really be core-cuda-tf2, but not as long as we must restrict TF2 minor version
+DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda:v2.69.0
+DOCKER_TAG = ocrd/sbb_binarization
+
.PHONY: help install
help:
@echo ""
@@ -10,13 +14,18 @@ help:
@echo " test Run tests"
@echo " clean Remove copies/results in test/assets"
@echo ""
+ @echo " docker Build a Docker image $(DOCKER_TAG) from $(DOCKER_BASE_IMAGE)"
+ @echo ""
@echo " Variables"
@echo ""
+ @echo " PYTHON"
+ @echo " DOCKER_TAG Docker image tag of result for the docker target"
# END-EVAL
# Install with pip
install:
+ pip install -U setuptools pip
pip install .
# Downloads the pre-trained models from qurator-data.de
@@ -40,6 +49,15 @@ test: test/assets models
ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN -P model default -P operation_level region
ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN2 -P model default-2021-03-09 -P operation_level region
+.PHONY: docker
+docker:
+ docker build \
+ --build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
+ --build-arg VCS_REF=$$(git rev-parse --short HEAD) \
+ --build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
+ -t $(DOCKER_TAG) .
+
+
.PHONY: clean
clean:
-$(RM) -fr test/assets
diff --git a/README.md b/README.md
index 39d4ad1..ef69cb6 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,8 @@
> Document Image Binarization
[![pip release](https://img.shields.io/pypi/v/sbb-binarization.svg)](https://pypi.org/project/sbb-binarization/)
-[![GHActions Tests](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml)
+[![GHActions CI](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml)
+[![GHActions CD](https://github.com/qurator-spk/sbb_binarization/actions/workflows/docker-image.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/docker-image.yml)
@@ -13,16 +14,19 @@ Python `3.7-3.10` with Tensorflow `<=2.11.1` are currently supported. While newe
You can either install from PyPI via
-```
-pip install sbb-binarization
-```
+ pip install sbb-binarization
+
or clone the repository, enter it and install (editable) with
-```
-git clone git@github.com:qurator-spk/sbb_binarization.git
-cd sbb_binarization; pip install -e .
-```
+ git clone git@github.com:qurator-spk/sbb_binarization.git
+ cd sbb_binarization; pip install -e .
+
+
+Alternatively, download the prebuilt image from Dockerhub:
+
+ docker pull ocrd/sbb_binarization
+
### Models
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..f837231
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,47 @@
+[build-system]
+requires = ["setuptools>=61.0", "wheel", "setuptools-ocrd"]
+
+[project]
+name = "sbb_binarization"
+authors = [
+ {name = "Vahid Rezanezhad"},
+ {name = "Staatsbibliothek zu Berlin - Preußischer Kulturbesitz"},
+]
+description = "Pixelwise binarization with selectional auto-encoders in Keras"
+readme = "README.md"
+license.file = "LICENSE"
+requires-python = ">=3.8"
+
+dynamic = ["dependencies", "version"]
+
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Environment :: Console",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: Apache Software License",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3 :: Only",
+ "Topic :: Scientific/Engineering :: Image Processing",
+]
+
+[project.scripts]
+sbb_binarize = "sbb_binarize.cli:main"
+ocrd-sbb-binarize = "sbb_binarize.ocrd_cli:cli"
+
+[project.urls]
+Homepage = "https://github.com/qurator-spk/sbb_binarization"
+Repository = "https://github.com/qurator-spk/sbb_binarization.git"
+
+[tool.setuptools.dynamic]
+dependencies = {file = ["requirements.txt"]}
+
+[tool.setuptools.packages.find]
+where = ["."]
+include = ["sbb_binarize"]
+namespaces = false
+
+[tool.setuptools]
+include-package-data = true
+
+[tool.setuptools.package-data]
+"*" = ["*.json"]
diff --git a/requirements.txt b/requirements.txt
index 4afbfba..8a5cd40 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,4 +2,4 @@ numpy
setuptools >= 41
opencv-python-headless
ocrd >= 2.38.0
-tensorflow <= 2.11.1
+tensorflow < 2.13
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 437730c..0000000
--- a/setup.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-from json import load
-from setuptools import setup, find_packages
-
-with open('./ocrd-tool.json', 'r') as f:
- version = load(f)['version']
-
-install_requires = open('requirements.txt').read().split('\n')
-
-setup(
- name='sbb_binarization',
- version=version,
- description='Pixelwise binarization with selectional auto-encoders in Keras',
- long_description=open('README.md').read(),
- long_description_content_type='text/markdown',
- author='Vahid Rezanezhad',
- url='https://github.com/qurator-spk/sbb_binarization',
- license='Apache License 2.0',
- packages=find_packages(exclude=('test', 'repo')),
- include_package_data=True,
- package_data={'': ['*.json', '*.yml', '*.yaml']},
- install_requires=install_requires,
- entry_points={
- 'console_scripts': [
- 'sbb_binarize=sbb_binarize.cli:main',
- 'ocrd-sbb-binarize=sbb_binarize.ocrd_cli:cli',
- ]
- },
-)