From da16ec374b41b8df221736ee5a886774bdcf4fd7 Mon Sep 17 00:00:00 2001 From: Jan Razlaw Date: Wed, 25 Jun 2025 09:17:24 +0200 Subject: [PATCH] Fix: Correct handling of page_orientation in orientation estimation --- doctr/models/_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doctr/models/_utils.py b/doctr/models/_utils.py index 38e8823fec..9a83fb37e3 100644 --- a/doctr/models/_utils.py +++ b/doctr/models/_utils.py @@ -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) @@ -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