Skip to content

fix: UnboundLocalError in predict_dummy when no bboxes are detected#147

Open
pdoup wants to merge 3 commits into
docling-project:mainfrom
pdoup:main
Open

fix: UnboundLocalError in predict_dummy when no bboxes are detected#147
pdoup wants to merge 3 commits into
docling-project:mainfrom
pdoup:main

Conversation

@pdoup

@pdoup pdoup commented Feb 8, 2026

Copy link
Copy Markdown

Description

This PR fixes an UnboundLocalError that occurs in the predict_dummy method of tf_predictor.py when the model fails to predict any bounding boxes.

Currently, the variable tf_output is initialized and assigned only within the if len(prediction["bboxes"]) > 0: block. If the model does not populate prediction["bboxes"], this block is skipped, and the subsequent return tf_output, matching_details statement raises a "cannot access local variable" error because tf_output has not been defined.

The fix initializes tf_output as an empty list [] prior to the conditional block, ensuring the variable is always defined and the method returns a valid empty result when no predictions are found.

Changes

  • Modified tf_predictor.py: Added initialization of tf_output = [] in predict_dummy to handle cases with no predicted bounding boxes.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Signed-off-by: Panagiotis Doupidis <72436005+pdoup@users.noreply.github.com>
@github-actions

github-actions Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @pdoup, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

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

🟢 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)(?:\(.+\))?(!)?:

@pdoup
pdoup marked this pull request as draft February 15, 2026 15:17
@pdoup
pdoup marked this pull request as ready for review February 15, 2026 15:18
@pdoup

pdoup commented Feb 18, 2026

Copy link
Copy Markdown
Author

Hi @nikos-livathinos and @cau-git, just wanted to check in on this PR when you have a moment. I’m happy to make any adjustments or provide more context if needed. Thanks for your time!

@nikos-livathinos nikos-livathinos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me

add new line at the end

Signed-off-by: Panagiotis Doupidis <72436005+pdoup@users.noreply.github.com>
html_tags = [self._rev_word_map[ind] for ind in seq[1:-1]]

return html_tags

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added newline at the end to fix black formatter error

@pdoup
pdoup requested a review from nikos-livathinos March 3, 2026 18:05
Signed-off-by: Panagiotis Doupidis <72436005+pdoup@users.noreply.github.com>
@codecov

codecov Bot commented Mar 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...models/tableformer/data_management/tf_predictor.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@pdoup

pdoup commented May 29, 2026

Copy link
Copy Markdown
Author

Hi @cau-git, just checking in on this PR when you have a moment. Since it's been a couple of months, I'm happy to update the branch or make any changes you need to get this ready for merge.

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