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

Trainable reading order #492

Merged
merged 69 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ba5444e
partial implementation of new xml parser
mittagessen Jan 23, 2023
c36c721
skip ROs in ALTO with sub-line elements
mittagessen Jan 26, 2023
b197705
wip
mittagessen Jan 30, 2023
65ad0ea
non-working xml parsing tests
mittagessen Feb 6, 2023
2a1be8b
Fix ALTO region order parsing
mittagessen Feb 22, 2023
bb4999e
working training code for RO
mittagessen Mar 3, 2023
b06ebe7
more training code
mittagessen Mar 3, 2023
145516b
remove metric ignore code in progress bar
mittagessen Mar 3, 2023
46d2c96
make checkpoint loading work for RO training
mittagessen Mar 3, 2023
c13b72c
add batch_size arg to ro cli again
mittagessen Mar 3, 2023
92dfb07
arrgh
mittagessen Mar 3, 2023
e1a932b
sketch of neural RO decoder
mittagessen Mar 3, 2023
3507a8e
Use spearman footrule distance as evaluation metric for RO training
mittagessen Mar 6, 2023
72caf7b
use original implementation hidden size
mittagessen Mar 6, 2023
583d36f
compute loss with logits
mittagessen Mar 8, 2023
845335c
logits not probits
mittagessen Mar 8, 2023
7af9a72
s/h,w/w,h/g
mittagessen Mar 9, 2023
c51e28d
some small new parser fixes
mittagessen Mar 23, 2023
898a1ed
more small fixes in lib/segmentation.py
mittagessen Mar 23, 2023
7be2aa0
decoder work
mittagessen Apr 3, 2023
1c283a9
add cls mapping to model params
mittagessen Apr 3, 2023
15820b4
coreml serialization of RO model
mittagessen Apr 4, 2023
b044928
some linter cleanup
mittagessen Apr 4, 2023
1326d09
remove unused failed_sample_threshold
mittagessen Apr 4, 2023
98faf22
more import fixes
mittagessen Apr 4, 2023
f36310b
syntax fix xml tests
mittagessen Apr 4, 2023
a7f1140
xml parsing tests files
mittagessen Apr 4, 2023
778c20b
lightning 2.0 changes to RO code
mittagessen Apr 16, 2023
c733b85
Code for adding RO models to segmentation models
mittagessen Apr 16, 2023
d4947af
Working inference
mittagessen Apr 16, 2023
9aca246
Segmentation data class in blla/pageseg
mittagessen Apr 21, 2023
cbc67cd
Switch over rpred.* to Segmentation class
mittagessen Apr 21, 2023
14f98c6
Use XMLPage in dataset/ro.py
mittagessen Apr 24, 2023
d4193e0
XMLPage in dataset/segmentation.py
mittagessen Apr 24, 2023
9b34c09
extract_polygons with dataclass
mittagessen Apr 25, 2023
0959156
Add new container classes
mittagessen May 11, 2023
5afb828
better _to_ptl_device
mittagessen May 11, 2023
24a0b85
strip container classes from rpred
mittagessen May 11, 2023
66127aa
Use new container classes in XMLPage
mittagessen May 11, 2023
9a78701
Use new container classes in blla.segment
mittagessen May 16, 2023
83b17fa
BBoxLine/Segmentation in legacy segmenter
mittagessen May 16, 2023
c390e68
UUIDs in blla lines
mittagessen May 16, 2023
b9753de
Segmentation/BBoxLine/BaselineLine containers in rpred
mittagessen May 16, 2023
11a3a19
Add to_container() method to XMLPage
mittagessen May 16, 2023
4210874
make compilation work with new container objects
mittagessen May 22, 2023
09ad27e
Fix imports in blla
mittagessen May 22, 2023
b491122
typo in ketos utils
mittagessen May 22, 2023
a9cfaf0
make path compilation work again
mittagessen May 23, 2023
7e8fcf7
add __getitem__ to the Baseline class
colibrisson Jun 17, 2023
8f34a9a
remove preparse_xml_data import statement
colibrisson Jun 17, 2023
fe897c7
Container classes in segmentation
mittagessen Jul 2, 2023
2cffebd
autoinstantiate baselineline/bboxline when loading segmentation from
mittagessen Jul 3, 2023
20a869a
Use new containers in rpred
mittagessen Jul 4, 2023
584ed68
Merge pull request #524 from colibrisson/feature/reading_order
mittagessen Jul 17, 2023
3aa34a8
serialization with new container classes
mittagessen Jul 18, 2023
4eef3c5
Add alternative reading orders to ALTO output
mittagessen Jul 18, 2023
c08edcb
docstrings
mittagessen Jul 19, 2023
6dcc004
more docstrings
mittagessen Jul 19, 2023
dd1b9ed
better default output name in ketos compile
mittagessen Jul 20, 2023
10c83d3
fix import in arrow_dataset
mittagessen Jul 20, 2023
e72f5ae
arrow dataset builder test skeleton
mittagessen Jul 21, 2023
260d047
Small fixes to RO dataset class
mittagessen Jul 24, 2023
7118f1e
forced alignment contrib script with container classes
mittagessen Jul 24, 2023
da6c4f6
extract_lines.py with container classes
mittagessen Jul 24, 2023
7cf2dc4
More contrib scripts with containers
mittagessen Jul 24, 2023
46d6c06
Switch recognition datasets to container classes
mittagessen Jul 26, 2023
a5a8a20
s/preparse_xml_data/XMLPage/g
mittagessen Aug 30, 2023
0fddaac
Move progress bar imports around to prevent torch import
mittagessen Sep 18, 2023
003568b
add threadpool limits to CLI drivers
mittagessen Sep 18, 2023
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
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ requirements:
- pyarrow
- pytorch-lightning~=2.0
- torchmetrics>=0.10.0
- conda-forge::threadpoolctl~=3.2.0
- albumentations
- rich
about:
Expand Down
227 changes: 130 additions & 97 deletions docs/api_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
API Reference
*************

Segmentation
============

kraken.blla module
==================
------------------

.. note::

Expand All @@ -14,7 +17,7 @@ kraken.blla module
.. autoapifunction:: kraken.blla.segment

kraken.pageseg module
=====================
---------------------

.. note::

Expand All @@ -24,150 +27,141 @@ kraken.pageseg module

.. autoapifunction:: kraken.pageseg.segment

kraken.rpred module
===================
Recognition
===========

.. autoapifunction:: kraken.rpred.bidi_record
kraken.rpred module
-------------------

.. autoapiclass:: kraken.rpred.mm_rpred
:members:

.. autoapiclass:: kraken.rpred.ocr_record
:members:

.. autoapifunction:: kraken.rpred.rpred

Serialization
=============

kraken.serialization module
===========================
---------------------------

.. autoapifunction:: kraken.serialization.render_report

.. autoapifunction:: kraken.serialization.serialize

.. autoapifunction:: kraken.serialization.serialize_segmentation

kraken.lib.models module
========================
Default templates
-----------------

.. autoapiclass:: kraken.lib.models.TorchSeqRecognizer
:members:
ALTO 4.4
^^^^^^^^

.. autoapifunction:: kraken.lib.models.load_any
.. literalinclude:: ../../templates/alto
:language: xml+jinja

kraken.lib.vgsl module
======================
PageXML
^^^^^^^

.. autoapiclass:: kraken.lib.vgsl.TorchVGSLModel
:members:
.. literalinclude:: ../../templates/alto
:language: xml+jinja

kraken.lib.xml module
=====================
hOCR
^^^^

.. autoapifunction:: kraken.lib.xml.parse_xml
.. literalinclude:: ../../templates/alto
:language: xml+jinja

.. autoapifunction:: kraken.lib.xml.parse_page
ABBYY XML
^^^^^^^^^

.. autoapifunction:: kraken.lib.xml.parse_alto
.. literalinclude:: ../../templates/abbyyxml
:language: xml+jinja

Containers and Helpers
======================

kraken.lib.codec module
=======================
-----------------------

.. autoapiclass:: kraken.lib.codec.PytorchCodec
:members:

kraken.lib.train module
=======================
kraken.containers module
------------------------

Training Schedulers
-------------------
.. autoapiclass:: kraken.containers.Segmentation
:members:

.. autoapiclass:: kraken.lib.train.TrainScheduler
:members:
.. autoapiclass:: kraken.containers.BaselineLine
:members:

.. autoapiclass:: kraken.lib.train.annealing_step
:members:
.. autoapiclass:: kraken.containers.BBoxLine
:members:

.. autoapiclass:: kraken.lib.train.annealing_const
:members:
.. autoapiclass:: kraken.containers.ocr_record
:members:

.. autoapiclass:: kraken.lib.train.annealing_exponential
:members:
.. autoapiclass:: kraken.containers.BaselineOCRRecord
:members:

.. autoapiclass:: kraken.lib.train.annealing_reduceonplateau
:members:
.. autoapiclass:: kraken.containers.BBoxOCRRecord
:members:

.. autoapiclass:: kraken.lib.train.annealing_cosine
:members:
.. autoapiclass:: kraken.containers.ProcessingStep
:members:

.. autoapiclass:: kraken.lib.train.annealing_onecycle
:members:
kraken.lib.ctc_decoder
----------------------

Training Stoppers
-----------------
.. autoapifunction:: kraken.lib.ctc_decoder.beam_decoder

.. autoapiclass:: kraken.lib.train.TrainStopper
:members:
.. autoapifunction:: kraken.lib.ctc_decoder.greedy_decoder

.. autoapiclass:: kraken.lib.train.EarlyStopping
:members:
.. autoapifunction:: kraken.lib.ctc_decoder.blank_threshold_decoder

.. autoapiclass:: kraken.lib.train.EpochStopping
:members:
kraken.lib.exceptions
---------------------

.. autoapiclass:: kraken.lib.train.NoStopping
.. autoapiclass:: kraken.lib.exceptions.KrakenCodecException
:members:

Loss and Evaluation Functions
-----------------------------

.. autoapifunction:: kraken.lib.train.recognition_loss_fn

.. autoapifunction:: kraken.lib.train.baseline_label_loss_fn

.. autoapifunction:: kraken.lib.train.recognition_evaluator_fn

.. autoapifunction:: kraken.lib.train.baseline_label_evaluator_fn

Trainer
-------

.. autoapiclass:: kraken.lib.train.KrakenTrainer
.. autoapiclass:: kraken.lib.exceptions.KrakenStopTrainingException
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenEncodeException
:members:

kraken.lib.dataset module
=========================

Datasets
--------
.. autoapiclass:: kraken.lib.exceptions.KrakenRecordException
:members:

.. autoapiclass:: kraken.lib.dataset.BaselineSet
.. autoapiclass:: kraken.lib.exceptions.KrakenInvalidModelException
:members:

.. autoapiclass:: kraken.lib.dataset.PolygonGTDataset
.. autoapiclass:: kraken.lib.exceptions.KrakenInputException
:members:

.. autoapiclass:: kraken.lib.dataset.GroundTruthDataset
.. autoapiclass:: kraken.lib.exceptions.KrakenRepoException
:members:

Helpers
-------
.. autoapiclass:: kraken.lib.exceptions.KrakenCairoSurfaceException
:members:

.. autoapifunction:: kraken.lib.dataset.compute_error
kraken.lib.models module
------------------------

.. autoapifunction:: kraken.lib.dataset.preparse_xml_data
.. autoapiclass:: kraken.lib.models.TorchSeqRecognizer
:members:

.. autoapifunction:: kraken.lib.dataset.generate_input_transforms
.. autoapifunction:: kraken.lib.models.load_any

kraken.lib.segmentation module
------------------------------

.. autoapifunction:: kraken.lib.segmentation.reading_order

.. autoapifunction:: kraken.lib.segmentation.polygonal_reading_order
.. autoapifunction:: kraken.lib.segmentation.neural_reading_order

.. autoapifunction:: kraken.lib.segmentation.denoising_hysteresis_thresh
.. autoapifunction:: kraken.lib.segmentation.polygonal_reading_order

.. autoapifunction:: kraken.lib.segmentation.vectorize_lines

Expand All @@ -181,43 +175,82 @@ kraken.lib.segmentation module

.. autoapifunction:: kraken.lib.segmentation.extract_polygons

kraken.lib.vgsl module
----------------------

kraken.lib.ctc_decoder
======================
.. autoapiclass:: kraken.lib.vgsl.TorchVGSLModel
:members:

.. autoapifunction:: kraken.lib.ctc_decoder.beam_decoder
kraken.lib.xml module
---------------------

.. autoapifunction:: kraken.lib.ctc_decoder.greedy_decoder
.. autoapiclass:: kraken.lib.xml.XMLPage

.. autoapifunction:: kraken.lib.ctc_decoder.blank_threshold_decoder
Training
========

kraken.lib.exceptions
=====================
kraken.lib.train module
-----------------------

.. autoapiclass:: kraken.lib.exceptions.KrakenCodecException
:members:
Loss and Evaluation Functions
-----------------------------

.. autoapiclass:: kraken.lib.exceptions.KrakenStopTrainingException
.. autoapifunction:: kraken.lib.train.recognition_loss_fn

.. autoapifunction:: kraken.lib.train.baseline_label_loss_fn

.. autoapifunction:: kraken.lib.train.recognition_evaluator_fn

.. autoapifunction:: kraken.lib.train.baseline_label_evaluator_fn

Trainer
-------

.. autoapiclass:: kraken.lib.train.KrakenTrainer
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenEncodeException

kraken.lib.dataset module
-------------------------

Recognition datasets
^^^^^^^^^^^^^^^^^^^^

.. autoapiclass:: kraken.lib.dataset.ArrowIPCRecognitionDataset
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenRecordException
.. autoapiclass:: kraken.lib.dataset.BaselineSet
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenInvalidModelException
.. autoapiclass:: kraken.lib.dataset.GroundTruthDataset
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenInputException
Segmentation datasets
^^^^^^^^^^^^^^^^^^^^^

.. autoapiclass:: kraken.lib.dataset.PolygonGTDataset
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenRepoException
Reading order datasets
^^^^^^^^^^^^^^^^^^^^^^

.. autoapiclass:: kraken.lib.dataset.PairWiseROSet
:members:

.. autoapiclass:: kraken.lib.exceptions.KrakenCairoSurfaceException
.. autoapiclass:: kraken.lib.dataset.PageWiseROSet
:members:

Helpers
^^^^^^^

.. autoapiclass:: kraken.lib.dataset.ImageInputTransforms
:members:

.. autoapifunction:: kraken.lib.dataset.collate_sequences

.. autoapifunction:: kraken.lib.dataset.global_align

.. autoapifunction:: kraken.lib.dataset.compute_confusions

Legacy modules
==============
Expand Down
2 changes: 1 addition & 1 deletion docs/ketos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ option action
-F, \--savefreq Model save frequency in epochs during
training
-q, \--quit Stop condition for training. Set to `early`
for early stopping (default) or `dumb` for fixed
for early stopping (default) or `fixed` for fixed
number of epochs.
-N, \--epochs Number of epochs to train for.
\--min-epochs Minimum number of epochs to train for when using early stopping.
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
- pyarrow
- conda-forge::pytorch-lightning~=2.0.0
- conda-forge::torchmetrics>=0.10.0
- conda-forge::threadpoolctl~=3.2
- pip
- albumentations
- rich
Expand Down
1 change: 1 addition & 0 deletions environment_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- pyarrow
- conda-forge::pytorch-lightning~=2.0.0
- conda-forge::torchmetrics>=0.10.0
- conda-forge::threadpoolctl~=3.2
- pip
- albumentations
- rich
Expand Down
Loading