Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SavedModel instead of HDF5 format, fix dewarping #89

Merged
merged 17 commits into from
Feb 22, 2022
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ Versioned according to [Semantic Versioning](http://semver.org/).

## Unreleased

Fixed:

* Makefile/tests: fix tests, update to resmgr cwd semantics, add dewarp
* layout-analysis: use correct pageId
* tiseg/layout-analysis: use TF SavedFormat instead of HDF5
* dewarp/layout-analysis: load during init (`setup` instead of `process`)
* dewarp: fix image input (in-memory instead of file-based)
* dewarp: fix image output (resizing with better quality)
* dewarp: fix/update pix2pixHD for CPU-only and newer PyTorch
* dewarp: rename parameters (now `resize_{mode,width,height}`)
* dewarp: fix oplevel region, update to ocrd_mets changes
* update requirements
* improve README

## [1.6.0] - 2021-05-20

Removed:
Expand Down
50 changes: 34 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export

CUDA_VISIBLE_DEVICES=0
SHELL = /bin/bash
PYTHON = python
PIP = pip
PYTHON ?= python
PIP ?= pip
PIP_INSTALL = $(PIP) install
LOG_LEVEL = INFO
PYTHONIOENCODING=utf8
Expand All @@ -19,6 +19,7 @@ DOCKER_TAG = ocrd/anybaseocr

# BEGIN-EVAL makefile-parser --make-help Makefile

.PHONY: help
help:
@echo ""
@echo " Targets"
Expand All @@ -36,8 +37,9 @@ help:
@echo " test-crop Test cropping CLI"
@echo " test-tiseg Test text/non-text segmentation CLI"
@echo " test-block-segmentation Test block segmentation CLI"
@echo " test-textline Test textline extraction CLI"
@echo " test-textline Test textline segmentation CLI"
@echo " test-layout-analysis Test document structure analysis CLI"
@echo " test-dewarp Test page dewarping CLI"
@echo ""
@echo " Variables"
@echo ""
Expand All @@ -46,6 +48,7 @@ help:
# END-EVAL

# Install python deps via pip
.PHONY: deps
deps:
$(PIP_INSTALL) -r requirements.txt

Expand Down Expand Up @@ -81,6 +84,7 @@ models:
ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-layout-analysis '*'
ocrd resmgr download --allow-uninstalled --location cwd ocrd-anybaseocr-tiseg '*'

.PHONY: docker
docker:
docker build -t '$(DOCKER_TAG)' .

Expand All @@ -90,51 +94,65 @@ repo/assets:
git clone https://github.com/OCR-D/assets "$@"

# Remove assets
.PHONY: assets-clean
assets-clean:
rm -rf $(testdir)/assets

# Setup test assets
assets: repo/assets
.PHONY: assets
assets: repo/assets models
mkdir -p $(testdir)/assets
cp -r -t $(testdir)/assets repo/assets/data/*
$(MAKE) models
ln -sr ocrd-resources/* $(TESTDATA)/
#
# Tests
#

# Run unit tests
.PHONY: test
test: assets-clean assets
$(PYTHON) -m pytest --continue-on-collection-errors $(TESTS)

# Run CLI tests
cli-test: assets-clean assets \
test-binarize test-deskew test-crop test-tiseg test-textline test-layout-analysis
.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

# Test binarization CLI
test-binarize:
.PHONY: test-binarize
test-binarize: assets
ocrd-anybaseocr-binarize -m $(TESTDATA)/mets.xml -I MAX -O BIN-TEST

# Test deskewing CLI
test-deskew:
.PHONY: test-deskew
test-deskew: test-binarize
ocrd-anybaseocr-deskew -m $(TESTDATA)/mets.xml -I BIN-TEST -O DESKEW-TEST

# Test cropping CLI
test-crop:
.PHONY: test-crop
test-crop: test-deskew
ocrd-anybaseocr-crop -m $(TESTDATA)/mets.xml -I DESKEW-TEST -O CROP-TEST

# Test text/non-text segmentation CLI
test-tiseg:
.PHONY: test-tiseg
test-tiseg: test-crop
ocrd-anybaseocr-tiseg -m $(TESTDATA)/mets.xml --overwrite -I CROP-TEST -O TISEG-TEST

# Test block segmentation CLI
test-block-segmentation:
.PHONY: test-block-segmentation
test-block-segmentation: test-tiseg
ocrd-anybaseocr-block-segmentation -m $(TESTDATA)/mets.xml -I TISEG-TEST -O OCR-D-BLOCK-SEGMENT

# Test textline extraction CLI
test-textline:
# 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 page dewarping CLI
.PHONY: test-dewarp
test-dewarp: test-crop
ocrd-anybaseocr-dewarp -m $(TESTDATA)/mets.xml -I CROP-TEST -O DEWARP-TEST

# Test document structure analysis CLI
test-layout-analysis:
.PHONY: test-layout-analysis
test-layout-analysis: test-binarize
ocrd-anybaseocr-layout-analysis -m $(TESTDATA)/mets.xml -I BIN-TEST -O LAYOUT
Loading