Skip to content

Fixed deduplication in picodet_postprocess #15025

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trueMiskin
Copy link

Hi,

When I tested your OCR with layout analysis I ran into a weird bug. I had this image:
Input image
Firstly, I ran the model with a score threshold 0.4 and the output was this image:
result_0 4
I was a little bit upset that the model did not find the title with high confidence so I lowered the threshold to 0.3 and the result is this image:
result_0 3
When I saw it, I knew that something was going wrong. When the threshold is lowered, the same or more bboxes can appear, but they cannot disappear.

I thought there was some bug in the nms function but I found a bug in the deduplication function. The function iterates bboxes and computes iou with all other bboxes. If there are overlapping bboxes one persists and the other is removed (marked as duplicate) but this approach is wrong. For example in this case:
result
In the first loop iteration, bboxes 0, 1, and 3 are removed. This does not make any sense. Bboxes 1 and 3 do not overlap at all. Additionally these bboxes overlap with only bbox 0 which is removed in the same iteration as well. The correct approach is to remove only tested bbox 0.

After this fix, the output is as expected:
result

Copy link

paddle-bot bot commented Apr 16, 2025

Thanks for your contribution!

@CLAassistant
Copy link

CLAassistant commented Apr 16, 2025

CLA assistant check
All committers have signed the CLA.

@GreatV GreatV requested a review from Copilot April 19, 2025 08:58
Copy link

@Copilot 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 fixes the deduplication process in picodet_postprocess by changing how duplicate bounding boxes are marked, ensuring that only the tested bbox is removed if it is not the highest scoring one.

  • Simplifies the duplicate marking by checking if the current index differs from the kept index.
  • Eliminates the unnecessary extension of duplicate indices using the overlaps list.
Comments suppressed due to low confidence (1)

ppocr/postprocess/picodet_postprocess.py:295

  • The updated deduplication logic now only marks the currently tested bbox (i) as duplicate if it is not the highest scoring one (keep). Please double-check that this approach fully addresses the issue of incorrectly removing non-overlapping bboxes and that it does not inadvertently remove boxes that should be preserved.
if keep != i:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants