Skip to content

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

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

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

Conversation

@pdoup
Copy link

@pdoup pdoup commented Feb 8, 2026

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
Copy link
Contributor

github-actions bot commented Feb 8, 2026

DCO Check Passed

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

@mergify
Copy link

mergify bot commented Feb 8, 2026

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
Copy link
Author

pdoup commented Feb 18, 2026

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!

Copy link
Member

@nikos-livathinos nikos-livathinos left a comment

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
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>
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