Skip to content

Commit 9c8cfdb

Browse files
authored
Fix: Correct handling of page_orientation in orientation estimation (#1971)
1 parent d1974d9 commit 9c8cfdb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

doctr/models/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def estimate_orientation(
6363
thresh = img.astype(np.uint8)
6464

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

102102
# combine with the general orientation and the estimated angle
103-
if page_orientation and orientation_confidence >= min_confidence:
103+
if page_orientation is not None and orientation_confidence >= min_confidence:
104104
# special case where the estimated angle is mostly wrong:
105105
# case 1: - and + swapped
106106
# case 2: estimated angle is completely wrong

0 commit comments

Comments
 (0)