Skip to content

Conversation

@nikos-livathinos
Copy link
Contributor

TL;DR

  • Produce confusion matrices and derivatives (precision, recall, f1 matrices and vectors) for the multi-label layout analysis.
  • Evaluate at the pixel level.
  • The method is applicable even if the layout model does not produce scores.
  • In case the predicted classes differ from the ones in the ground truth, it is still possible to produce block-matrices for confusion and derivatives.
  • Generate excel reports with visualizations that allow to inspect what kind of prediction mistakes have been done.
  • Fast, fully-vectorized implementation.

Detailed description

The PixelLayoutEvaluator computes confusion matrices for the multi-label layout analysis task at the pixel level.
The produced confusion matrices contain fractional counts of pixels, where values on the main diagonal are correct predictions (gains) and values outside of the main diagonal are mis-predictions (penalties). An additional class for the background has been added. Precision, recall and F1 matrices can be easily computed out of the confusion matrix and finally we can extract vectors with precision, recall, f1 values per class. Such matrices/vectors can be computed at each level (page, document, benchmark).

The generated matrices are visualized as colorized excel reports that allow to easily investigate the performance of the layout model and answer questions like:

  • Which classes are correctly predicted and to which extend.
  • For the mispredictions: Which classes have been predicted instead of the correct ones and to which extend.
  • How the predicted classes overlap with each other.
  • How well is background predicted.
  • etc.

Given that the method applies at a pixel level it is important to have a fast implementation. This is a fully vectorized implementation on top of numpy.

The method is inspired by the paper: https://csitcp.org/paper/10/108csit01.pdf

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
@nikos-livathinos nikos-livathinos self-assigned this Nov 12, 2025
@nikos-livathinos nikos-livathinos marked this pull request as draft November 12, 2025 17:59
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

DCO Check Passed

Thanks @nikos-livathinos, all your commits are properly signed off. 🎉

@mergify
Copy link

mergify bot commented Nov 12, 2025

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 Require two reviewer for test updates

This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

…it test

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…cts between the PixelLayoutEvaluator

and MultiLabelConfusionMatrix. Stabilize the outputs. Still need to work on save/export.

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Allow the pydantic types to serialize numpy arrays as lists. Integrate with main.

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…pixel_types.py

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…erated and excel export works.

Additional testing of the API and CLI is needed

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…ns in the `predictor_info`

field, not only the default ones.

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…del and add it in the reports

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
… for the f1 scores of the

pages with the full classes and the colapsed classes. Then use these fields in the visualisations
to make histograms.

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
@nikos-livathinos nikos-livathinos marked this pull request as ready for review November 14, 2025 14:26
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants