Skip to content

Run re-recognition both for detection and recognitions#259

Merged
GreatV merged 2 commits into
PFCCLab:mainfrom
MuhammedOzdogan:bug/258-re-recognition-fix
Apr 24, 2026
Merged

Run re-recognition both for detection and recognitions#259
GreatV merged 2 commits into
PFCCLab:mainfrom
MuhammedOzdogan:bug/258-re-recognition-fix

Conversation

@MuhammedOzdogan
Copy link
Copy Markdown
Contributor

Resolves #258

@GreatV
Copy link
Copy Markdown
Collaborator

GreatV commented Apr 17, 2026

The original reRecognition iterates over self.canvas.shapes and only re-runs recognition on existing boxes. This intentionally preserves:

  • Manually drawn/adjusted bounding boxes
  • Boxes added to cover missed detections
  • Carefully fine-tuned polygon points

Your replacement calls self.ocr.predict(img) which generates entirely new detections from scratch, and the previous shapes are completely lost. In a labeling tool, manual annotations represent significant user effort. Overwriting them automatically is destructive and breaks user trust.

@MuhammedOzdogan
Copy link
Copy Markdown
Contributor Author

MuhammedOzdogan commented Apr 17, 2026

Hi @GreatV ,

Here is my use case:

I do the labeling for some amount of time and then do the training and get a new model for detection and recognition. When I open up the PPOCRLabel with the new models I would like to see how it performs on the pages that are Auto Detected already but not checked yet, those pages has auto-detection from the first model I used in the beginning of the training. ( I have many images in the same folder) I would like to see if my detection model performs better or worse so I can change the labeling/training strategy, at this moment if you have run auto detection already you can't test the new detection model in the same folder because it keeps the bounding boxes.

How do you or most people use the reRecognition feature could you please share?

When the user hit the shortcut for reRecognition we can show a popup and ask user: "Do you want to keep your bounding boxes or you want complete new reRecognition for this page?"

@GreatV
Copy link
Copy Markdown
Collaborator

GreatV commented Apr 17, 2026

Hi @MuhammedOzdogan,

I think we can solve this without changing the core behavior of reRecognition. The underlying issue is that PPOCRLabel caches auto-detection results, so even with a new model, it reloads the old boxes. A simpler and safer approach is clear the cache and re-open the image. PPOCRLabel stores cached results in files like Cache.cach and Label.txt in the image folder. If you delete these cache files for the images you want to re-evaluate, the tool will treat them as fresh images and run full detection + recognition with the new model.

@MuhammedOzdogan
Copy link
Copy Markdown
Contributor Author

Hi @GreatV,

I tried your method and deleted the Cache.cach file and run the PPOCRLabel in the same folder and openned an image which has no work done before and hit the reRecognition shortcut, if gives the warning the "Draw a box!".
So it doesn't run the reRecognition(detection+recognition) only for that image, the only way to do is using the "Auto Recognition" button on the lower left corner which does the auto recognition for the all unchecked images in the same folder and in my working folder I have many many images and this Auto Recognition button takes too long.

I think it's not too much to ask for feature/bugfix to run detection / recognition model in a particular image only.

Deleting Label.txt is not a good idea because this file stores all the valuable labeling data, if you delete it you will lose all your work.

@MuhammedOzdogan
Copy link
Copy Markdown
Contributor Author

Hi @GreatV,

I've restored the reRecognition method to its original logic. I also added a separate "Auto Recognition (Current Image)" action in the PaddleOCR menu. It prompts for confirmation before deleting any existing bounding boxes to run detection+recognition from scratch.

Please review when you have a chance. Thanks!

Copy link
Copy Markdown
Collaborator

@GreatV GreatV left a comment

Choose a reason for hiding this comment

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

LGTM

@GreatV GreatV merged commit 42362c8 into PFCCLab:main Apr 24, 2026
1 check passed
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.

Bug: Re-Recognition Doesn't run Detection Again

2 participants