-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Bug]: Different results between doctr and onnxtr models. #10
Comments
Hi @decadance-dance 👋, First a question: The issue comes from the preprocessing. docTR (pytorch): OnnxTR: We could test some interpolations to get a closer result but as a side effect this will slightly slowdown the pipe :) |
Ok i checked this also by changing the preproc to torch and it seems you are right - the pipe is fine it comes from the converted model i will check the diff again 👍 By using the
|
Also compared other models:
Compared to FAST models the diff is much smaller 👍 |
Having issues as well with this. Results are vastly different, but I can confirm it's not due to the exported models because I have my own implementation of running ONNX DocTR exports which works fine. |
Is there a workaround for this? |
Hi @milosacimovic 👋, Which models do you use ? |
They have been exported from docTR v0.8.1 |
It seems that in ONNXTR there are three things that are different in preprocessing. docTR:
onnxTR:
There also might be a bug/difference in how the initial resize (prior padding) is done |
Another thing I noticed is different in onnxtr vs doctr are the per postprocessor bin_thresh and box_thresh. For OnnxTR the default of 0.5 is used for both while in doctr e.g. LinkNetPostProcessor has 0.1 used as default for both. |
Hi @milosacimovic 👋 First you are right there was a bug in resizing: bin + box thresh values are directly set in the model files (same as in doctr)
:) |
Hi @felixdittrich92 my bad about bin_thresh, you're right, they're fine |
Looks much closer with the PR now: Overview: Before:
After:
The diff for the |
Unfortunately this destroys the idea to drop PIL as dependency because before it was only used to get the font now it's also needed for the preproc to overcome the interpolation diff between PIL and CV2 😅 |
@decadance-dance @milosacimovic Could you test it again please from main branch ? :) As mentioned the diff with
|
Works better thanks @felixdittrich92 , but still having some issue that I am having a problem to nail down which part is making the difference, the inputs are exactly the same but somehow, I'm getting different results. |
@milosacimovic great 👍 |
Bug description
It is expected that converting to onnx will not affect the results.
In my case (fast_base usage) this is not true and the onnx model works worse due to the fact that the regions of the probability mask are consistently narrower and sometimes this leads to artifacts.
Code snippet to reproduce the bug
Image:

Error traceback
Here I provided different results both prob and bbox levels:


onnx bboxes:
doctr bboxes:
onnx prob map:


doctr prob map:
Environment
Python 3.10.13
Ubuntu 20.04.5 LTS
onnxruntime 1.17.0
onnxruntime-gpu 1.17.1
onnxtr 0.1.2a0
The text was updated successfully, but these errors were encountered: