Skip to content

feat: Added support for per-class confidence thresholds in layout detection.#50

Merged
JaredforReal merged 2 commits intozai-org:mainfrom
TeHelado:feat/threshold-by-class
Feb 5, 2026
Merged

feat: Added support for per-class confidence thresholds in layout detection.#50
JaredforReal merged 2 commits intozai-org:mainfrom
TeHelado:feat/threshold-by-class

Conversation

@TeHelado
Copy link
Contributor

@TeHelado TeHelado commented Feb 4, 2026

threshold_by_class option exist is config but it's not actually being used. This adds support to fine-tune layout detection with threshold_by_class.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for per-class confidence thresholds in layout detection. The threshold_by_class configuration option existed but was not being utilized in the code. This feature allows fine-tuning of detection confidence thresholds on a per-class basis, enabling more granular control over which layout elements are detected.

Changes:

  • Added _apply_per_class_threshold method to filter detections based on per-class confidence thresholds
  • Modified the process method to use a lower pre-threshold when per-class thresholds are configured, then apply per-class filtering afterward
  • Fixed incorrect comment in config.yaml (label 23 was incorrectly labeled as "text" instead of "vertical_text")
  • Added documentation examples showing both numeric and string key formats for threshold_by_class

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
glmocr/layout/layout_detector.py Implements per-class threshold filtering logic and integrates it into the detection pipeline
glmocr/config.yaml Fixes mislabeled comment for label 23 and adds documentation examples for string-based class keys

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@JaredforReal JaredforReal merged commit f23992b into zai-org:main Feb 5, 2026
2 checks passed
@TeHelado TeHelado deleted the feat/threshold-by-class branch February 5, 2026 15:51
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.

2 participants