Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test
repo
dist
build
*.egg-info
*.whl
15 changes: 8 additions & 7 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Install package
run: make install
- name: Cache models
uses: actions/cache@v3
uses: actions/cache@v4
with:
key: detectron-models
path: /home/runner/.local/share/ocrd-resources/ocrd-detectron2-segment/*
Expand All @@ -54,7 +54,8 @@ jobs:
- name: Run tests
run: make test
- name: Upload test results
uses: actions/upload-artifact@v3
if: matrix.python-version == '3.8'
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
Expand All @@ -71,11 +72,11 @@ jobs:
continue-on-error: true
steps:
- name: Checkout GH Pages
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Download Artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
uses: actions/download-artifact@v4
with:
name: test-results
path: test-results
Expand Down
41 changes: 29 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,39 @@ FROM $DOCKER_BASE_IMAGE
ARG VCS_REF
ARG BUILD_DATE
LABEL \
maintainer="https://ocr-d.de/kontakt" \
maintainer="https://ocr-d.de/en/contact" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/bertsky/detectron2" \
org.label-schema.build-date=$BUILD_DATE
org.label-schema.vcs-url="https://github.com/bertsky/ocrd_detectron2" \
org.label-schema.build-date=$BUILD_DATE \
org.opencontainers.image.vendor="DFG-Funded Initiative for Optical Character Recognition Development" \
org.opencontainers.image.title="ocrd_detectron2" \
org.opencontainers.image.description="OCR-D wrapper for detectron2 based segmentation models" \
org.opencontainers.image.source="https://github.com/bertsky/ocrd_detectron2" \
org.opencontainers.image.documentation="https://github.com/bertsky/ocrd_detectron2/blob/${VCS_REF}/README.md" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.base.name=ocrd/core-cuda-torch

ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONIOENCODING utf8
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONIOENCODING=utf8
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

# avoid HOME/.local/share (hard to predict USER here)
# so let XDG_DATA_HOME coincide with fixed system location
# (can still be overridden by derived stages)
ENV XDG_DATA_HOME /usr/local/share
# avoid the need for an extra volume for persistent resource user db
# (i.e. XDG_CONFIG_HOME/ocrd/resources.yml)
ENV XDG_CONFIG_HOME /usr/local/share/ocrd-resources

WORKDIR /build/ocrd_detectron2
COPY setup.py .
COPY ocrd_detectron2/ocrd-tool.json .
COPY README.md .
COPY requirements.txt .
COPY requirements-test.txt .
COPY ocrd_detectron2 ./ocrd_detectron2
COPY Makefile .

COPY . .
COPY ocrd-tool.json .
# prepackage ocrd-tool.json as ocrd-all-tool.json
RUN ocrd ocrd-tool ocrd-tool.json dump-tools > $(dirname $(ocrd bashlib filename))/ocrd-all-tool.json
# install everything and reduce image size
RUN apt-get install -y --no-install-recommends g++ && \
make deps && \
make install && \
Expand Down
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ PYTHONIOENCODING=utf8
SHELL = /bin/bash

# Docker container tag
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-torch:v2.69.0
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-torch:v3.3.0
DOCKER_TAG = 'ocrd/detectron2'

help:
@echo
@echo " Targets"
@echo
@echo " deps Install only Python dependencies via pip"
@echo " install Install full Python package via pip"
@echo " deps-test Install Python dependencies for tests via pip and models via resmgr"
@echo " test Run regression tests"
@echo " build Build Python package as source and wheel distribution"
@echo " clean Remove symlinks in test/assets"
@echo " docker Build Docker image"
@echo " deps Install only Python dependencies via pip"
@echo " install Install full Python package via pip"
@echo " install-dev Install full Python package via pip"
@echo " deps-test Install Python dependencies for tests via pip and models via resmgr"
@echo " test Run regression tests"
@echo " build Build Python package as source and wheel distribution"
@echo " clean Remove symlinks in test/assets"
@echo " docker Build Docker image"
@echo
@echo " Variables"
@echo " PYTHON"
Expand Down Expand Up @@ -70,6 +71,10 @@ deps:
install: deps
$(PIP) install .

# Install Python package via pip
install-dev: deps
$(PIP) install -e .

# Install testing python deps via pip
deps-test: models-test
$(PIP) install -r requirements-test.txt
Expand Down
4 changes: 0 additions & 4 deletions ocrd_detectron2/config.py

This file was deleted.

10 changes: 3 additions & 7 deletions ocrd_detectron2/ocrd-tool.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"git_url": "https://github.com/bertsky/ocrd_detectron2",
"version": "0.1.8",
"version": "0.2.0",
"tools": {
"ocrd-detectron2-segment": {
"executable": "ocrd-detectron2-segment",
"categories": ["Layout analysis"],
"steps": ["layout/segmentation/region"],
"description": "Detect regions with Detectron2 models",
"input_file_grp": [
"OCR-D-IMG"
],
"output_file_grp": [
"OCR-D-SEG-REGION"
],
"input_file_grp_cardinality": 1,
"output_file_grp_cardinality": 1,
"parameters": {
"operation_level": {
"type": "string",
Expand Down
Loading