-
Notifications
You must be signed in to change notification settings - Fork 489
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
[orientation] page orientation improvements #1553
Conversation
c08ddc5
to
f86d4b2
Compare
df4226c
to
32885b1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1553 +/- ##
==========================================
- Coverage 96.44% 96.41% -0.04%
==========================================
Files 164 164
Lines 7743 7773 +30
==========================================
+ Hits 7468 7494 +26
- Misses 275 279 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
37df762
to
3f93c5e
Compare
3f93c5e
to
7e7e6d4
Compare
9bb1376
to
dff1052
Compare
doctr/models/_utils.py
Outdated
if page_orientation and orientation_confidence >= min_confidence: | ||
# special case where the estimated angle is mostly wrong: | ||
# when estimated angle is + or - 90 degree, we should consider the general orientation | ||
if abs(estimated_angle) == 90 and abs(page_orientation) in [0, 90]: | ||
return page_orientation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand entirely this section. Here, estimated_angle == 90
, so according to your comment, it's wrong, so page_orientation
is returned but it's also 90
. It means there is no evident fallback to fix this issue ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the problem case is if estimated_angle is exact 90 or -90 it's mostly not correct (swapping - and + or complete wrong)
So we should check the page orientation also..
I think we can simplify this:
if abs(estimated_angle) == abs(page_orientation):
return page_orientation
wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what "mostly wrong" means here ? Based on your experimentations, if it's 90 or -90, it's completly wrong ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the most cases yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comes from:
elif w / h < 1 / ratio_threshold_for_lines: # if lines are vertical, substract 90 degree
angles.append(angle - 90)
but i don't have a better solution for this yet :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed a small update
tested again with a complex set of documents (mobile phone, receipts, etc) 30 samples
randomly rotated in range -180 - 180
it mostly varies between 22 - 25 correct from 30
before this integration / changes on the same set we have had 7 - 11 correct so as mentioned still some space for further improvements it's not perfect but already much better as before :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah.. if i lower the min_confidence we get ~27 - 29 correct xD trust the page orientation model xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it sounds good for a "first" iteration. We can improve later in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep i think the same
This PR:
OCRPredictor
logic (limit duplication)page_orientation_predictor
NOTE: Draft until TF orientation models are merged
Any feedback is welcome 🤗
Closes: #1460