Compare commits
227 Commits
Author | SHA1 | Date |
---|---|---|
Clemens Neudecker | bc9dddd2c0 | 4 weeks ago |
Clemens Neudecker | 21893910b8 | 4 weeks ago |
Clemens Neudecker | 51f6ef63f5 | 1 month ago |
kba | b13759fdcf | 1 month ago |
kba | c487be2a1d | 1 month ago |
kba | 7eb1390583 | 1 month ago |
Clemens Neudecker | 4af0bc079c | 2 months ago |
michalbubula | d168edfd77 | 2 months ago |
michalbubula | 723f27bec4 | 2 months ago |
vahidrezanezhad | 74a0699f6b | 2 months ago |
Clemens Neudecker | 327b446a16 | 2 months ago |
Clemens Neudecker | 351e9a897a | 2 months ago |
kba | 478edc804a | 2 months ago |
Clemens Neudecker | c156a1612e | 2 months ago |
vahidrezanezhad | 6b2e5d110e | 2 months ago |
cneud | b6d3d2bdbf | 2 months ago |
cneud | de32d86fb6 | 2 months ago |
Clemens Neudecker | 256a7c347f | 3 months ago |
kba | 84b844203d | 3 months ago |
kba | 9367f86483 | 3 months ago |
kba | 62314c453c | 3 months ago |
kba | a5c7f223d1 | 3 months ago |
kba | 9ae0575436 | 3 months ago |
Clemens Neudecker | 78bfa97c06 | 3 months ago |
kba | 84d05bd0ae | 3 months ago |
cneud | 7f99526b9d | 3 months ago |
cneud | 8f76966394 | 3 months ago |
cneud | 28ee1e527e | 3 months ago |
Clemens Neudecker | 23ac58405c | 3 months ago |
vahidrezanezhad | e3edb0ec30 | 3 months ago |
vahidrezanezhad | 8e2cdad1be | 3 months ago |
vahidrezanezhad | 9170a9f21c | 3 months ago |
cneud | f0e7f75499 | 3 months ago |
cneud | 7ded54a8d2 | 3 months ago |
cneud | c9f63826c0 | 3 months ago |
cneud | 8862df9156 | 3 months ago |
cneud | 38698c6609 | 3 months ago |
cneud | 40f5408b1e | 3 months ago |
cneud | 3cfa447e84 | 3 months ago |
cneud | ad133e3425 | 3 months ago |
vahidrezanezhad | 721d3f70a0 | 6 months ago |
Robert Sachunsky | 45bd76f5e8 | 6 months ago |
Robert Sachunsky | f88ee99f3c | 6 months ago |
Clemens Neudecker | 899bb9f00c | 7 months ago |
Clemens Neudecker | ba64282118 | 7 months ago |
Clemens Neudecker | 533736a3e3 | 8 months ago |
cneud | b3fa684395 | 8 months ago |
cneud | f09b7c1bef | 8 months ago |
vahidrezanezhad | 7cbca79f16 | 12 months ago |
vahidrezanezhad | aa41e4df20 | 12 months ago |
vahidrezanezhad | 364ccacab2 | 12 months ago |
vahidrezanezhad | 6aac0b8faf | 12 months ago |
vahidrezanezhad | e7d12d3549 | 12 months ago |
vahidrezanezhad | 6018b354aa | 12 months ago |
Clemens Neudecker | f2811ee469 | 1 year ago |
vahidrezanezhad | 7983a65006 | 1 year ago |
vahidrezanezhad | fc9e9cc29f | 1 year ago |
cneud | 4254ce3bdb | 1 year ago |
cneud | 56934c876a | 1 year ago |
Clemens Neudecker | 6c65fc4dfe | 1 year ago |
Clemens Neudecker | 9d3a1a5b76 | 1 year ago |
Clemens Neudecker | 03bfd7a390 | 1 year ago |
vahidrezanezhad | 7a70b20c77 | 1 year ago |
vahidrezanezhad | 0ea90b7509 | 1 year ago |
vahidrezanezhad | 830b0fc8fa | 1 year ago |
cneud | d3b06baa84 | 1 year ago |
Clemens Neudecker | 3e62657570 | 1 year ago |
Clemens Neudecker | b58a327c5d | 1 year ago |
Clemens Neudecker | 935332e863 | 1 year ago |
Clemens Neudecker | e5acee09ab | 1 year ago |
Clemens Neudecker | 6ba5cdcc11 | 1 year ago |
Clemens Neudecker | 2db588a146 | 1 year ago |
Clemens Neudecker | aad80696e6 | 1 year ago |
Clemens Neudecker | a0949fd74a | 1 year ago |
vahidrezanezhad | 5f7d9a475c | 1 year ago |
Clemens Neudecker | bafad0c511 | 1 year ago |
Robert Sachunsky | 867a7261de | 1 year ago |
Robert Sachunsky | b049e475e3 | 1 year ago |
Clemens Neudecker | fbe2f2302f | 1 year ago |
Robert Sachunsky | 69c1d6b3d6 | 1 year ago |
vahidrezanezhad | 68923e0a5d | 1 year ago |
vahid | 0b35011847 | 1 year ago |
vahid | 0cda1f3c7a | 1 year ago |
vahid | b01888da31 | 2 years ago |
vahid | 45c40a58fc | 2 years ago |
cneud | a96147b621 | 2 years ago |
cneud | c7057bad5e | 2 years ago |
cneud | 419e589df7 | 2 years ago |
cneud | 6eab7a60a9 | 2 years ago |
Clemens Neudecker | fd9431a678 | 2 years ago |
cneud | 48f2ce6203 | 2 years ago |
vahidrezanezhad | 1621532092 | 2 years ago |
vahid | 4c217018cc | 2 years ago |
vahid | d68f240b59 | 2 years ago |
vahid | 380f59ad67 | 2 years ago |
vahidrezanezhad | 29e6ad076f | 2 years ago |
Robert Sachunsky | 529f2c0e19 | 2 years ago |
vahidrezanezhad | 52d2e0b098 | 2 years ago |
Clemens Neudecker | cb5ffaee14 | 2 years ago |
cneud | 70786377dc | 2 years ago |
cneud | 1e172cca5d | 2 years ago |
cneud | fef7cf309b | 2 years ago |
cneud | 000e39c676 | 2 years ago |
cneud | d98689edad | 2 years ago |
cneud | 50b9ce3350 | 2 years ago |
cneud | c251c4f4c8 | 2 years ago |
Robert Sachunsky | 8fe3567123 | 2 years ago |
Clemens Neudecker | cb8cfad761 | 2 years ago |
Clemens Neudecker | 0462ae0b97 | 2 years ago |
Clemens Neudecker | f264eaf424 | 2 years ago |
cneud | 63d996880d | 2 years ago |
cneud | 456fccb35e | 2 years ago |
Konstantin Baierer | abb0b293f5 | 2 years ago |
vahidrezanezhad | fd56b86acf | 2 years ago |
vahid | d3735b12f4 | 2 years ago |
Clemens Neudecker | 22a8e93031 | 2 years ago |
Konstantin Baierer | 14fc040428 | 2 years ago |
Clemens Neudecker | 0279ebfe13 | 2 years ago |
Clemens Neudecker | aecc2ea543 | 2 years ago |
cneud | fd4c0ed4e8 | 2 years ago |
cneud | 31be7892a0 | 2 years ago |
cneud | 817e5a6af9 | 2 years ago |
cneud | a9728bb899 | 2 years ago |
Robert Sachunsky | fb6d97091b | 2 years ago |
cneud | d4dd532212 | 2 years ago |
cneud | 9849541061 | 2 years ago |
Robert Sachunsky | 1ac0a7e06f | 2 years ago |
Robert Sachunsky | 73057d57d1 | 2 years ago |
vahid | a078a18530 | 2 years ago |
cneud | 3d54719c87 | 2 years ago |
cneud | 58ca226f2d | 2 years ago |
cneud | d21cc42d87 | 2 years ago |
cneud | 2c13f1bddc | 2 years ago |
cneud | 4642ccb36d | 2 years ago |
cneud | 27834ce33d | 2 years ago |
cneud | f37d324812 | 2 years ago |
cneud | 4276417938 | 2 years ago |
cneud | 4807be1b62 | 2 years ago |
Konstantin Baierer | 6c8f60993f | 2 years ago |
Konstantin Baierer | ea792d1e4a | 2 years ago |
Konstantin Baierer | e167e0863d | 2 years ago |
Konstantin Baierer | 8e894e5b7b | 2 years ago |
Konstantin Baierer | 7cd07dd550 | 2 years ago |
Konstantin Baierer | 71d0ec8dfe | 2 years ago |
Konstantin Baierer | 31a2ec8fe6 | 2 years ago |
Robert Sachunsky | 875e4fe32b | 2 years ago |
Robert Sachunsky | 318ea6acca | 2 years ago |
Robert Sachunsky | 23f0c0b40a | 2 years ago |
Robert Sachunsky | 5c26bdf402 | 2 years ago |
Robert Sachunsky | 7345f6bf67 | 2 years ago |
Robert Sachunsky | a56988a35a | 2 years ago |
Clemens Neudecker | 13bc2378d9 | 2 years ago |
Robert Sachunsky | 2d9ccac354 | 2 years ago |
Robert Sachunsky | ab4bb7cd7b | 2 years ago |
Robert Sachunsky | 79e897d3b2 | 2 years ago |
vahidrezanezhad | a6fe781033 | 2 years ago |
Clemens Neudecker | ac69136e8f | 2 years ago |
emresvd | 98529d6325 | 2 years ago |
Clemens Neudecker | 30ef006dfd | 2 years ago |
Clemens Neudecker | 5ca857018b | 2 years ago |
Clemens Neudecker | ffc7f82906 | 2 years ago |
Clemens Neudecker | b75d8afb1d | 2 years ago |
Clemens Neudecker | 000402f0dc | 2 years ago |
vahid | 38bf0d8740 | 2 years ago |
vahid | 89e58910aa | 2 years ago |
vahid | 583cdcee2c | 2 years ago |
Clemens Neudecker | 07fe0d827d | 2 years ago |
Clemens Neudecker | dbf91876e1 | 2 years ago |
vahid | 8d5079c909 | 2 years ago |
vahid | 402c5339ac | 2 years ago |
vahid | 01bfc3914d | 3 years ago |
Clemens Neudecker | 00be99d29b | 3 years ago |
vahidrezanezhad | ae7c424889 | 3 years ago |
vahid | cd9920eea7 | 3 years ago |
Robert Sachunsky | 34a061782c | 3 years ago |
vahid | 735abc43f3 | 3 years ago |
vahidrezanezhad | ae1990a48e | 3 years ago |
cneud | 934bbd5892 | 3 years ago |
cneud | 8c11b2253d | 3 years ago |
cneud | ecf117ca95 | 3 years ago |
Clemens Neudecker | 568391ec4a | 3 years ago |
vahid | 3bbbeecfec | 3 years ago |
vahid | 3871e22c35 | 3 years ago |
Clemens Neudecker | a33a1995cb | 3 years ago |
vahidrezanezhad | ceb9b8f2b9 | 3 years ago |
Gerber, Mike | f27ac155ae | 3 years ago |
vahid | adf10942fa | 3 years ago |
vahidrezanezhad | d19170035d | 3 years ago |
vahid | e564451861 | 3 years ago |
vahidrezanezhad | bd6e38334c | 3 years ago |
vahid | 94c3b0fc28 | 3 years ago |
vahid | 8d19c4c632 | 3 years ago |
vahid | 2eacb9a8ec | 3 years ago |
Clemens Neudecker | 441c8566dd | 3 years ago |
Clemens Neudecker | aa64a54feb | 3 years ago |
Clemens Neudecker | 5dafa2095b | 3 years ago |
vahid | c606391c31 | 3 years ago |
Clemens Neudecker | 571dc84c3f | 3 years ago |
vahid | cf5ef8f5ae | 3 years ago |
vahidrezanezhad | b8a532180a | 3 years ago |
vahidrezanezhad | 2736ddb42d | 3 years ago |
vahidrezanezhad | 10f1acef29 | 3 years ago |
vahidrezanezhad | c30d4d5c30 | 3 years ago |
vahidrezanezhad | 6a9d5d2076 | 3 years ago |
Gerber, Mike | 11d9b00510 | 3 years ago |
Gerber, Mike | 1fe8f92afc | 3 years ago |
Gerber, Mike | 7ccd7663e1 | 3 years ago |
Gerber, Mike | cdea0acffe | 3 years ago |
Konstantin Baierer | f0ac0bb090 | 3 years ago |
Konstantin Baierer | 8943c90b02 | 3 years ago |
Konstantin Baierer | d75803b11d | 3 years ago |
Konstantin Baierer | e769f625fe | 3 years ago |
Konstantin Baierer | 09d85bee87 | 3 years ago |
vahidrezanezhad | b018138cf8 | 3 years ago |
vahidrezanezhad | 9b28a71db7 | 3 years ago |
vahidrezanezhad | 169b50aaaf | 3 years ago |
vahidrezanezhad | c8f0feb5bd | 3 years ago |
Konstantin Baierer | 0e63ebcbe5 | 3 years ago |
Konstantin Baierer | 4223fed628 | 3 years ago |
vahid | 0859d22f4c | 3 years ago |
vahid | 14c588e162 | 3 years ago |
vahid | 254abf4d3d | 3 years ago |
vahid | 9f64110513 | 3 years ago |
vahid | b3b49272a5 | 3 years ago |
vahid | c67e155431 | 3 years ago |
vahid | a5c940705a | 3 years ago |
vahid | 80b17af40c | 3 years ago |
@ -1,28 +0,0 @@
|
||||
version: 2
|
||||
|
||||
jobs:
|
||||
|
||||
build-python36:
|
||||
docker:
|
||||
- image: python:3.6
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- model-cache
|
||||
- run: make models
|
||||
- save_cache:
|
||||
key: model-cache
|
||||
paths:
|
||||
models_eynollah.tar.gz
|
||||
models_eynollah
|
||||
- run: make install
|
||||
- run: make smoke-test
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- build-python36
|
||||
#- build-python37
|
||||
#- build-python38 # no tensorflow for python 3.8
|
@ -0,0 +1,26 @@
|
||||
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/eynollah" \
|
||||
org.label-schema.build-date=$BUILD_DATE
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PYTHONIOENCODING=utf8
|
||||
ENV XDG_DATA_HOME=/usr/local/share
|
||||
|
||||
WORKDIR /build-eynollah
|
||||
COPY src/ ./src
|
||||
COPY pyproject.toml .
|
||||
COPY requirements.txt .
|
||||
COPY README.md .
|
||||
COPY Makefile .
|
||||
RUN apt-get install -y --no-install-recommends g++
|
||||
RUN make install
|
||||
|
||||
WORKDIR /data
|
||||
VOLUME /data
|
@ -1,122 +1,122 @@
|
||||
# Eynollah
|
||||
> Document Layout Analysis
|
||||
> Document Layout Analysis with Deep Learning and Heuristics
|
||||
|
||||
![](https://user-images.githubusercontent.com/952378/102350683-8a74db80-3fa5-11eb-8c7e-f743f7d6eae2.jpg)
|
||||
|
||||
## Introduction
|
||||
This tool performs document layout analysis (segmentation) from image data and returns the results as [PAGE-XML](https://github.com/PRImA-Research-Lab/PAGE-XML).
|
||||
|
||||
It can currently detect the following layout classes/elements:
|
||||
* [Border](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_BorderType.html)
|
||||
* [Textregion](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_TextRegionType.html)
|
||||
* [Textline](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_TextLineType.html)
|
||||
* [Image](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_ImageRegionType.html)
|
||||
* [Separator](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_SeparatorRegionType.html)
|
||||
* [Marginalia](https://ocr-d.de/en/gt-guidelines/trans/lyMarginalie.html)
|
||||
* [Initial (Drop Capital)](https://ocr-d.de/en/gt-guidelines/trans/lyInitiale.html)
|
||||
|
||||
In addition, the tool can be used to detect the _[ReadingOrder](https://ocr-d.de/en/gt-guidelines/trans/lyLeserichtung.html)_ of regions. The final goal is to feed the output to an OCR model.
|
||||
|
||||
The tool uses a combination of various models and heuristics (see flowchart below for the different stages and how they interact):
|
||||
* [Border detection](https://github.com/qurator-spk/eynollah#border-detection)
|
||||
* [Layout detection](https://github.com/qurator-spk/eynollah#layout-detection)
|
||||
* [Textline detection](https://github.com/qurator-spk/eynollah#textline-detection)
|
||||
* [Image enhancement](https://github.com/qurator-spk/eynollah#Image_enhancement)
|
||||
* [Scale classification](https://github.com/qurator-spk/eynollah#Scale_classification)
|
||||
* [Heuristic methods](https://https://github.com/qurator-spk/eynollah#heuristic-methods)
|
||||
|
||||
The first three stages are based on [pixel-wise segmentation](https://github.com/qurator-spk/sbb_pixelwise_segmentation).
|
||||
[![PyPI Version](https://img.shields.io/pypi/v/eynollah)](https://pypi.org/project/eynollah/)
|
||||
[![GH Actions Test](https://github.com/qurator-spk/eynollah/actions/workflows/test-eynollah.yml/badge.svg)](https://github.com/qurator-spk/eynollah/actions/workflows/test-eynollah.yml)
|
||||
[![License: ASL](https://img.shields.io/github/license/qurator-spk/eynollah)](https://opensource.org/license/apache-2-0/)
|
||||
[![DOI](https://img.shields.io/badge/DOI-10.1145%2F3604951.3605513-red)](https://doi.org/10.1145/3604951.3605513)
|
||||
|
||||
![](https://user-images.githubusercontent.com/952378/100619946-1936f680-331e-11eb-9297-6e8b4cab3c16.png)
|
||||
|
||||
## Border detection
|
||||
For the purpose of text recognition (OCR) and in order to avoid noise being introduced from texts outside the printspace, one first needs to detect the border of the printed frame. This is done by a binary pixel-wise-segmentation model trained on a dataset of 2,000 documents where about 1,200 of them come from the [dhSegment](https://github.com/dhlab-epfl/dhSegment/) project (you can download the dataset from [here](https://github.com/dhlab-epfl/dhSegment/releases/download/v0.2/pages.zip)) and the remainder having been annotated in SBB. For border detection, the model needs to be fed with the whole image at once rather than separated in patches.
|
||||
|
||||
## Layout detection
|
||||
As a next step, text regions need to be identified by means of layout detection. Again a pixel-wise segmentation model was trained on 131 labeled images from the SBB digital collections, including some data augmentation. Since the target of this tool are historical documents, we consider as main region types text regions, separators, images, tables and background - each with their own subclasses, e.g. in the case of text regions, subclasses like header/heading, drop capital, main body text etc. While it would be desirable to detect and classify each of these classes in a granular way, there are also limitations due to having a suitably large and balanced training set. Accordingly, the current version of this tool is focussed on the main region types background, text region, image and separator.
|
||||
![](https://user-images.githubusercontent.com/952378/102350683-8a74db80-3fa5-11eb-8c7e-f743f7d6eae2.jpg)
|
||||
|
||||
## Textline detection
|
||||
In a subsequent step, binary pixel-wise segmentation is used again to classify pixels in a document that constitute textlines. For textline segmentation, a model was initially trained on documents with only one column/block of text and some augmentation with regard to scaling. By fine-tuning the parameters also for multi-column documents, additional training data was produced that resulted in a much more robust textline detection model.
|
||||
## Features
|
||||
* Support for up to 10 segmentation classes:
|
||||
* background, [page border](https://ocr-d.de/en/gt-guidelines/trans/lyRand.html), [text region](https://ocr-d.de/en/gt-guidelines/trans/lytextregion.html#textregionen__textregion_), [text line](https://ocr-d.de/en/gt-guidelines/pagexml/pagecontent_xsd_Complex_Type_pc_TextLineType.html), [header](https://ocr-d.de/en/gt-guidelines/trans/lyUeberschrift.html), [image](https://ocr-d.de/en/gt-guidelines/trans/lyBildbereiche.html), [separator](https://ocr-d.de/en/gt-guidelines/trans/lySeparatoren.html), [marginalia](https://ocr-d.de/en/gt-guidelines/trans/lyMarginalie.html), [initial](https://ocr-d.de/en/gt-guidelines/trans/lyInitiale.html), [table](https://ocr-d.de/en/gt-guidelines/trans/lyTabellen.html)
|
||||
* Support for various image optimization operations:
|
||||
* cropping (border detection), binarization, deskewing, dewarping, scaling, enhancing, resizing
|
||||
* Text line segmentation to bounding boxes or polygons (contours) including for curved lines and vertical text
|
||||
* Detection of reading order (left-to-right or right-to-left)
|
||||
* Output in [PAGE-XML](https://github.com/PRImA-Research-Lab/PAGE-XML)
|
||||
* [OCR-D](https://github.com/qurator-spk/eynollah#use-as-ocr-d-processor) interface
|
||||
|
||||
## Image enhancement
|
||||
This is an image to image model which input was low quality of an image and label was actually the original image. For this one we did not have any GT, so we decreased the quality of documents in SBB and then feed them into model.
|
||||
:warning: Development is currently focused on achieving the best possible quality of results for a wide variety of historical documents and therefore processing can be very slow. We aim to improve this, but contributions are welcome.
|
||||
|
||||
## Scale classification
|
||||
This is simply an image classifier which classifies images based on their scales or better to say based on their number of columns.
|
||||
## Installation
|
||||
Python `3.8-3.11` with Tensorflow `<2.13` on Linux are currently supported.
|
||||
|
||||
## Heuristic methods
|
||||
Some heuristic methods are also employed to further improve the model predictions:
|
||||
* After border detection, the largest contour is determined by a bounding box, and the image cropped to these coordinates.
|
||||
* For text region detection, the image is scaled up to make it easier for the model to detect background space between text regions.
|
||||
* A minimum area is defined for text regions in relation to the overall image dimensions, so that very small regions that are noise can be filtered out.
|
||||
* Deskewing is applied on the text region level (due to regions having different degrees of skew) in order to improve the textline segmentation result.
|
||||
* After deskewing, a calculation of the pixel distribution on the X-axis allows the separation of textlines (foreground) and background pixels.
|
||||
* Finally, using the derived coordinates, bounding boxes are determined for each textline.
|
||||
For (limited) GPU support the CUDA toolkit needs to be installed.
|
||||
|
||||
## Installation
|
||||
`pip install .` or
|
||||
You can either install from PyPI
|
||||
|
||||
`pip install . -e` for editable installation
|
||||
```
|
||||
pip install eynollah
|
||||
```
|
||||
|
||||
Alternatively, you can also use `make` with these targets:
|
||||
or clone the repository, enter it and install (editable) with
|
||||
|
||||
`make install` or
|
||||
```
|
||||
git clone git@github.com:qurator-spk/eynollah.git
|
||||
cd eynollah; pip install -e .
|
||||
```
|
||||
|
||||
`make install-dev` for editable installation
|
||||
Alternatively, you can run `make install` or `make install-dev` for editable installation.
|
||||
|
||||
### Models
|
||||
## Models
|
||||
Pre-trained models can be downloaded from [qurator-data.de](https://qurator-data.de/eynollah/) or [huggingface](https://huggingface.co/SBB?search_models=eynollah).
|
||||
|
||||
In order to run this tool you also need trained models. You can download our pretrained models from [qurator-data.de](https://qurator-data.de/eynollah/).
|
||||
## Train
|
||||
🚧 **Work in progress**
|
||||
|
||||
Alternatively, running `make models` will download and extract models to `$(PWD)/models_eynollah`.
|
||||
In case you want to train your own model, have a look at [`sbb_pixelwise_segmentation`](https://github.com/qurator-spk/sbb_pixelwise_segmentation).
|
||||
|
||||
## Usage
|
||||
|
||||
The basic command-line interface can be called like this:
|
||||
The command-line interface can be called like this:
|
||||
|
||||
```sh
|
||||
eynollah \
|
||||
-i <image file name> \
|
||||
-o <directory to write output xml or enhanced image> \
|
||||
-m <directory of models> \
|
||||
-fl <if true, the tool will perform full layout analysis> \
|
||||
-ae <if true, the tool will resize and enhance the image and produce the resulting image as output> \
|
||||
-as <if true, the tool will check whether the document needs rescaling or not> \
|
||||
-cl <if true, the tool will extract the contours of curved textlines instead of rectangle bounding boxes> \
|
||||
-si <if a directory is given here, the tool will output image regions inside documents there>
|
||||
-i <single image file> | -di <directory containing image files> \
|
||||
-o <output directory> \
|
||||
-m <directory containing model files> \
|
||||
[OPTIONS]
|
||||
```
|
||||
|
||||
The tool does accept and works better on original images (RGB format) than binarized images.
|
||||
|
||||
### `--full-layout` vs `--no-full-layout`
|
||||
|
||||
Here are the difference in elements detected depending on the `--full-layout`/`--no-full-layout` command line flags:
|
||||
The following options can be used to further configure the processing:
|
||||
|
||||
| | `--full-layout` | `--no-full-layout` |
|
||||
| --- | --- | --- |
|
||||
| reading order | x | x |
|
||||
| header regions | x | - |
|
||||
| text regions | x | x |
|
||||
| text regions / text line | x | x |
|
||||
| drop-capitals | x | - |
|
||||
| marginals | x | x |
|
||||
| marginals / text line | x | x |
|
||||
| image region | x | x |
|
||||
| option | description |
|
||||
|-------------------|:-------------------------------------------------------------------------------|
|
||||
| `-fl` | full layout analysis including all steps and segmentation classes |
|
||||
| `-light` | lighter and faster but simpler method for main region detection and deskewing |
|
||||
| `-tab` | apply table detection |
|
||||
| `-ae` | apply enhancement (the resulting image is saved to the output directory) |
|
||||
| `-as` | apply scaling |
|
||||
| `-cl` | apply contour detection for curved text lines instead of bounding boxes |
|
||||
| `-ib` | apply binarization (the resulting image is saved to the output directory) |
|
||||
| `-ep` | enable plotting (MUST always be used with `-sl`, `-sd`, `-sa`, `-si` or `-ae`) |
|
||||
| `-eoi` | extract only images to output directory (other processing will not be done) |
|
||||
| `-ho` | ignore headers for reading order dectection |
|
||||
| `-si <directory>` | save image regions detected to this directory |
|
||||
| `-sd <directory>` | save deskewed image to this directory |
|
||||
| `-sl <directory>` | save layout prediction as plot to this directory |
|
||||
| `-sp <directory>` | save cropped page image to this directory |
|
||||
| `-sa <directory>` | save all (plot, enhanced/binary image, layout) to this directory |
|
||||
|
||||
### How to use
|
||||
If no option is set, the tool performs layout detection of main regions (background, text, images, separators and marginals).
|
||||
The best output quality is produced when RGB images are used as input rather than greyscale or binarized images.
|
||||
|
||||
First, this model makes use of up to 9 trained models which are responsible for different operations like size detection, column classification, image enhancement, page extraction, main layout detection, full layout detection and textline detection.That does not mean that all 9 models are always required for every document. Based on the document characteristics and parameters specified, different scenarios can be applied.
|
||||
#### Use as OCR-D processor
|
||||
🚧 **Work in progress**
|
||||
|
||||
* If none of the parameters is set to `true`, the tool will perform a layout detection of main regions (background, text, images, separators and marginals). An advantage of this tool is that it tries to extract main text regions separately as much as possible.
|
||||
Eynollah ships with a CLI interface to be used as [OCR-D](https://ocr-d.de) processor.
|
||||
|
||||
* If you set `-ae` (**a**llow image **e**nhancement) parameter to `true`, the tool will first check the ppi (pixel-per-inch) of the image and when it is less than 300, the tool will resize it and only then image enhancement will occur. Image enhancement can also take place without this option, but by setting this option to `true`, the layout xml data (e.g. coordinates) will be based on the resized and enhanced image instead of the original image.
|
||||
In this case, the source image file group with (preferably) RGB images should be used as input like this:
|
||||
|
||||
* For some documents, while the quality is good, their scale is very large, and the performance of tool decreases. In such cases you can set `-as` (**a**llow **s**caling) to `true`. With this option enabled, the tool will try to rescale the image and only then the layout detection process will begin.
|
||||
|
||||
* If you care about drop capitals (initials) and headings, you can set `-fl` (**f**ull **l**ayout) to `true`. With this setting, the tool can currently distinguish 7 document layout classes/elements.
|
||||
```
|
||||
ocrd-eynollah-segment -I OCR-D-IMG -O SEG-LINE -P models
|
||||
```
|
||||
|
||||
* In cases where the document includes curved headers or curved lines, rectangular bounding boxes for textlines will not be a great option. In such cases it is strongly recommended setting the flag `-cl` (**c**urved **l**ines) to `true` to find contours of curved lines instead of rectangular bounding boxes. Be advised that enabling this option increases the processing time of the tool.
|
||||
Any image referenced by `@imageFilename` in PAGE-XML is passed on directly to Eynollah as a processor, so that e.g.
|
||||
|
||||
* To crop and save image regions inside the document, set the parameter `-si` (**s**ave **i**mages) to true and provide a directory path to store the extracted images.
|
||||
```
|
||||
ocrd-eynollah-segment -I OCR-D-IMG-BIN -O SEG-LINE -P models
|
||||
```
|
||||
|
||||
* This tool is actively being developed. If problems occur, or the performance does not meet your expectations, we welcome your feedback via [issues](https://github.com/qurator-spk/eynollah/issues).
|
||||
uses the original (RGB) image despite any binarization that may have occured in previous OCR-D processing steps
|
||||
|
||||
#### Additional documentation
|
||||
Please check the [wiki](https://github.com/qurator-spk/eynollah/wiki).
|
||||
|
||||
## How to cite
|
||||
If you find this tool useful in your work, please consider citing our paper:
|
||||
|
||||
```bibtex
|
||||
@inproceedings{hip23rezanezhad,
|
||||
title = {Document Layout Analysis with Deep Learning and Heuristics},
|
||||
author = {Rezanezhad, Vahid and Baierer, Konstantin and Gerber, Mike and Labusch, Kai and Neudecker, Clemens},
|
||||
booktitle = {Proceedings of the 7th International Workshop on Historical Document Imaging and Processing {HIP} 2023,
|
||||
San José, CA, USA, August 25-26, 2023},
|
||||
publisher = {Association for Computing Machinery},
|
||||
address = {New York, NY, USA},
|
||||
year = {2023},
|
||||
pages = {73--78},
|
||||
url = {https://doi.org/10.1145/3604951.3605513}
|
||||
}
|
||||
```
|
||||
|
@ -1 +1 @@
|
||||
qurator/eynollah/ocrd-tool.json
|
||||
src/eynollah/ocrd-tool.json
|
@ -0,0 +1,43 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0", "wheel", "setuptools-ocrd"]
|
||||
|
||||
[project]
|
||||
name = "eynollah"
|
||||
authors = [
|
||||
{name = "Vahid Rezanezhad"},
|
||||
{name = "Staatsbibliothek zu Berlin - Preußischer Kulturbesitz"},
|
||||
]
|
||||
description = "Document Layout Analysis"
|
||||
readme = "README.md"
|
||||
license.file = "LICENSE"
|
||||
requires-python = ">=3.8"
|
||||
keywords = ["document layout analysis", "image segmentation"]
|
||||
|
||||
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]
|
||||
eynollah = "eynollah.cli:main"
|
||||
ocrd-eynollah-segment = "eynollah.ocrd_cli:main"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/qurator-spk/eynollah"
|
||||
Repository = "https://github.com/qurator-spk/eynollah.git"
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
dependencies = {file = ["requirements.txt"]}
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"*" = ["*.json", '*.yml', '*.xml', '*.xsd']
|
@ -1 +0,0 @@
|
||||
__import__("pkg_resources").declare_namespace(__name__)
|
@ -1 +0,0 @@
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
||||
# ocrd includes opencv, numpy, shapely, click
|
||||
ocrd >= 2.23.3
|
||||
keras >= 2.3.1, < 2.4
|
||||
numpy <1.24.0
|
||||
scikit-learn >= 0.23.2
|
||||
tensorflow-gpu >= 1.15, < 2
|
||||
tensorflow < 2.13
|
||||
imutils >= 0.5.3
|
||||
matplotlib
|
||||
setuptools >= 50
|
||||
|
@ -1,28 +0,0 @@
|
||||
from setuptools import setup, find_packages
|
||||
from json import load
|
||||
|
||||
install_requires = open('requirements.txt').read().split('\n')
|
||||
with open('ocrd-tool.json', 'r', encoding='utf-8') as f:
|
||||
version = load(f)['version']
|
||||
|
||||
setup(
|
||||
name='eynollah',
|
||||
version=version,
|
||||
long_description=open('README.md').read(),
|
||||
long_description_content_type='text/markdown',
|
||||
author='Vahid Rezanezhad',
|
||||
url='https://github.com/qurator-spk/eynollah',
|
||||
license='Apache License 2.0',
|
||||
namespace_packages=['qurator'],
|
||||
packages=find_packages(exclude=['tests']),
|
||||
install_requires=install_requires,
|
||||
package_data={
|
||||
'': ['*.json']
|
||||
},
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'eynollah=qurator.eynollah.cli:main',
|
||||
'ocrd-eynollah-segment=qurator.eynollah.ocrd_cli:main',
|
||||
]
|
||||
},
|
||||
)
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
def test_utils_import():
|
||||
import qurator.eynollah.utils
|
||||
import qurator.eynollah.utils.contour
|
||||
import qurator.eynollah.utils.drop_capitals
|
||||
import qurator.eynollah.utils.drop_capitals
|
||||
import qurator.eynollah.utils.is_nan
|
||||
import qurator.eynollah.utils.rotate
|
||||
import eynollah.utils
|
||||
import eynollah.utils.contour
|
||||
import eynollah.utils.drop_capitals
|
||||
import eynollah.utils.drop_capitals
|
||||
import eynollah.utils.is_nan
|
||||
import eynollah.utils.rotate
|
||||
|
Loading…
Reference in New Issue