PaddleOCR api call results on inference model don't make any sense #14285
Replies: 2 comments
-
|
The issue you're facing, where the inference results of your PaddleOCR-trained model differ significantly from the validation results, is a common issue and often stems from discrepancies between the training and inference configurations. Based on your description and the provided references, here are some potential causes and troubleshooting steps: 1. Ensure Consistency Between Training and Inference ConfigurationsWhen exporting a trained model for inference, it's crucial that the configurations used during training (e.g., image preprocessing, character dictionary, model architecture) match those used during inference. Specifically:
2. Verify Model Export ProcessThe process of converting a trained model to an inference model can sometimes introduce issues. Make sure:
3. Debugging the Inference Results
4. Preprocessing DifferencesDiscrepancies in preprocessing during training and inference can significantly impact results. Check:
5. Evaluate Overfitting or Data IssuesAlthough your model achieves 100% accuracy on both training and validation datasets, it might still be overfitting. This can happen if:
6. Check PaddleOCR Version CompatibilityEnsure that the PaddleOCR version used during training matches the version used during inference. Changes in the library between versions can lead to unexpected behavior. For example, you're using PaddleOCR version 7. Related DiscussionsHere are some relevant references from PaddleOCR's GitHub Discussions that might help:
Suggested Next Steps
By following these steps, you should be able to diagnose and resolve the issue. Let me know if you need further assistance! Response generated by 🤖 feifei-bot | chatgpt-4o-latest |
Beta Was this translation helpful? Give feedback.
-
Issue: High Validation Accuracy but Garbage Inference in PP-OCRv5 (Solved)I fine-tuned PP-OCRv5 on a custom dataset (English alphabets, numerals, and some symbols).
But when I ran inference (even on images from training/validation sets), the predictions were totally wrong. I double-checked everything:
At this point, I was stuck because evaluation showed 99% accuracy, but inference was useless. Root CauseTurns out the problem was due to mismatch in image preprocessing between training and inference. In my training config sampler:
name: MultiScaleSampler
scales: [[320, 32], [320, 48], [320, 64]]So during training, images were dynamically resized to 3 different shapes:
But in my exported PreProcess:
transform_ops:
- DecodeImage:
channel_first: false
img_mode: BGR
- MultiLabelEncode:
gtc_encode: NRTRLabelEncode
- RecResizeImg:
image_shape:
- 3
- 48
- 320Notice the mismatch?
That mismatch caused the network to completely fail at inference. ✅ FixI manually adjusted the
So the fix was: Final fix: PreProcess:
transform_ops:
- DecodeImage:
channel_first: false
img_mode: BGR
- MultiLabelEncode:
gtc_encode: NRTRLabelEncode
- RecResizeImg:
image_shape:
- 3
- 32
- 320TakeawayIf you’re fine-tuning PP-OCR models with This should save people from wasting days like I did. 🙃 Want me to polish this into a proper GitHub issue comment format (with Markdown headings + code blocks, short and punchy)? Or do you want it more like a blog-style post with more storytelling? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been using PaddleOCR training capabilities in a small dataset of digits, after 25 epochs the accuracy of the model reaches 100%, I then evaluate the model and I get an accuracy of 100% too. The problem is that when I try to test the model on the exact same images I used to eval, I get completely different results, of course Iexported the best weights from the trained recognition model
from PaddleOCR.paddleocr import PaddleOCR
ocr = PaddleOCR(
use_gpu=False,
rec_char_dict_path='./digit_dict.txt',
rec_model_dir="./PaddleOCR/inference/rec_digits", # Path to the saved model
)
result = ocr.ocr(image_path)
notes: digit_dict refers to a small text file containing the numbers from 0 to 9
I tried to use infer_rec.py but the results were no good at all again with data that we already used to validate, not sure what I should do next.
Beta Was this translation helpful? Give feedback.
All reactions