Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
09e355b
layout/writer: simplify and refactor using dataclasses for segments…
Jul 19, 2026
f41badc
extract_images: make it work (again), adapt to dataclasses…
Jul 19, 2026
ff3ac6c
reorder: simplify and refactor…
Jul 19, 2026
a36d98c
enhancement: log job timing here, too
Jul 19, 2026
e0c8975
ModelZoo type hints: reflect Predictor stand-in and inference backends
Jul 19, 2026
90e147a
`get_slopes*curved`: fix missing arg
Jul 19, 2026
7113e94
layout/writer/extract-images: also refactor page as dataclass…
Jul 19, 2026
42968f8
layout/extract-images/processor: write AlternativeImage if binarized…
Jul 19, 2026
944729e
`layout -cl`: fix typo (`shapely.prepare` instead of `prepared`)
Jul 19, 2026
cefcee1
`layout -cl`: ensure lines are also within parent regions here
Jul 19, 2026
5fe904e
rename `mb_ro_on_layout` → `reorder`
Jul 19, 2026
e59c684
calculate_width_height_by_columns_1_2: do allow highest enlargement w…
Jul 20, 2026
c696513
layout: refactor into new function `do_order_of_regions_heuristic`…
Jul 20, 2026
72289c6
reorder: also cover heuristic RO besides model-based…
Jul 20, 2026
c98bcfe
reorder: adapt tests
Jul 20, 2026
e71923c
reorder: adapt smoke tests
Jul 20, 2026
72f4a25
pil2cv: remove alpha, if any
Jul 28, 2026
bad250f
Merge remote-tracking branch 'origin/main' into refactor-dataclasses
Jul 28, 2026
b2777a2
do_prediction*: refactor into separate module
Jul 30, 2026
5f4e4fb
tiling for enhancement: ensure precision by rounding
Jul 30, 2026
628e76c
tiling: avoid self-overlapping windows if margin too wide
Jul 30, 2026
fa21cff
add extract-page CLI for cropping only
Jul 30, 2026
642363c
remove unused function (used by old table extraction)
Jul 30, 2026
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ smoke-test: tests/resources/2files/kant_aufklaerung_1784_0020.tif
eynollah -m $(CURDIR) layout -di $(<D) -o $(TMPDIR)
test -s $(TMPDIR)/euler_rechenkunst01_1738_0025.xml
# mbreorder, directory mode (overwrite):
eynollah -m $(CURDIR) machine-based-reading-order -di $(<D) -o $(TMPDIR)
eynollah -m $(CURDIR) reorder -mb -di $(<D) -o $(TMPDIR)
fgrep -q http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15 $(TMPDIR)/$(basename $(<F)).xml
fgrep -c -e RegionRefIndexed $(TMPDIR)/$(basename $(<F)).xml
# binarize:
Expand Down
4 changes: 3 additions & 1 deletion src/eynollah/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .cli import main
from .cli_binarize import binarize_cli
from .cli_enhance import enhance_cli
from .cli_extract_page import extract_page_cli
from .cli_extract_images import extract_images_cli
from .cli_layout import layout_cli
from .cli_models import models_cli
Expand All @@ -10,7 +11,8 @@
main.add_command(binarize_cli, 'binarization')
main.add_command(enhance_cli, 'enhancement')
main.add_command(layout_cli, 'layout')
main.add_command(readingorder_cli, 'machine-based-reading-order')
main.add_command(readingorder_cli, 'reorder')
main.add_command(models_cli, 'models')
main.add_command(ocr_cli, 'ocr')
main.add_command(extract_page_cli, 'extract-page')
main.add_command(extract_images_cli, 'extract-images')
2 changes: 1 addition & 1 deletion src/eynollah/cli/cli_extract_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def extract_images_cli(
ignore_page_extraction,
):
"""
Detect Layout (with optional image enhancement and reading order detection)
Detect image regions only
"""
assert enable_plotting or not save_images, "Plotting with -si also requires -ep"
assert not enable_plotting or save_images, "Plotting with -ep also requires -si"
Expand Down
80 changes: 80 additions & 0 deletions src/eynollah/cli/cli_extract_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import click

@click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option(
"--image",
"-i",
help="input image filename",
type=click.Path(exists=True, dir_okay=False),
)

@click.option(
"--out",
"-o",
help="directory for output PAGE-XML files",
type=click.Path(exists=True, file_okay=False),
required=True,
)
@click.option(
"--overwrite",
"-O",
help="overwrite (instead of skipping) if output xml exists",
is_flag=True,
)
@click.option(
"--dir_in",
"-di",
help="directory of input images (instead of --image)",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--input_binary",
"-ib",
is_flag=True,
help="In general, eynollah uses RGB as input, but if the input document is very dark, very bright or for any other reason you can turn on internal binarization here. When set, eynollah will binarize the RGB input document first.",
)
@click.option(
"--num_col_upper",
"-ncu",
default=0,
type=click.IntRange(min=0),
help="lower limit of columns in document image; 0 means autodetected from model",
)
@click.option(
"--num_col_lower",
"-ncl",
default=0,
type=click.IntRange(min=0),
help="upper limit of columns in document image; 0 means autodetected from model",
)
@click.pass_context
def extract_page_cli(
ctx,
image,
out,
overwrite,
dir_in,
input_binary,
num_col_upper,
num_col_lower,
):
"""
Detect image regions only
"""
assert bool(image) != bool(dir_in), "Either -i (single input) or -di (directory) must be provided, but not both."

from ..extract_page import EynollahPageExtractor
extractor = EynollahPageExtractor(
model_zoo=ctx.obj.model_zoo,
input_binary=input_binary,
num_col_upper=num_col_upper,
num_col_lower=num_col_lower,
)
extractor.run(overwrite=overwrite,
image_filename=image,
dir_in=dir_in,
dir_out=out,
)

32 changes: 27 additions & 5 deletions src/eynollah/cli/cli_readingorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
@click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option(
"--model_based",
"-mb",
help="use machine-learning model instead of heuristic rules",
is_flag=True,
)
@click.option(
"--input",
"-i",
Expand All @@ -15,24 +21,40 @@
help="directory of PAGE-XML input files (instead of --input)",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--dir_imgs",
"-dim",
help="directory of image input files (in addition to --dir_in or --input; filename stems must match the XML files, with image file format suffixes). Not needed for --model_based.",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--out",
"-o",
help="directory for output images",
type=click.Path(exists=True, file_okay=False),
required=True,
)
@click.option(
"--overwrite",
"-O",
help="overwrite (instead of skipping) if output xml exists",
is_flag=True,
)
@click.pass_context
def readingorder_cli(ctx, input, dir_in, out):
def readingorder_cli(ctx, model_based, input, dir_in, dir_imgs, out, overwrite):
"""
Generate ReadingOrder with a ML model
Generate ReadingOrder for existing segmentation from ML model or from heuristic rules
"""
from ..mb_ro_on_layout import Reorder
from ..reorder import Reorder
assert bool(input) != bool(dir_in), "Either -i (single input) or -di (directory) must be provided, but not both."
assert bool(model_based) or bool(dir_imgs), "For heuristic reading order, -dim must be provided, too."
orderer = Reorder(model_zoo=ctx.obj.model_zoo,
device=ctx.obj.device)
orderer.run(xml_filename=input,
device=ctx.obj.device,
model_based=model_based)
orderer.run(overwrite=overwrite,
xml_filename=input,
dir_in=dir_in,
dir_imgs=dir_imgs,
dir_out=out,
)

Loading