Skip to content

[Fix] Correct condition for image dilation in orientation estimation #1971

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doctr/models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def estimate_orientation(
thresh = img.astype(np.uint8)

page_orientation, orientation_confidence = general_page_orientation or (None, 0.0)
if page_orientation and orientation_confidence >= min_confidence:
if page_orientation is not None and orientation_confidence >= min_confidence:
# We rotate the image to the general orientation which improves the detection
# No expand needed bitmap is already padded
thresh = rotate_image(thresh, -page_orientation)
Expand Down Expand Up @@ -100,7 +100,7 @@ def estimate_orientation(
estimated_angle = -round(median) if abs(median) != 0 else 0

# combine with the general orientation and the estimated angle
if page_orientation and orientation_confidence >= min_confidence:
if page_orientation is not None and orientation_confidence >= min_confidence:
# special case where the estimated angle is mostly wrong:
# case 1: - and + swapped
# case 2: estimated angle is completely wrong
Expand Down
Loading