From ed34c3c1783ca0d1ca1a229ac43083443627ff99 Mon Sep 17 00:00:00 2001 From: sharmy Date: Sun, 19 Oct 2025 19:48:47 +0800 Subject: [PATCH] set width/height ratio to 2 decimal places, to avoid OverflowError(cannot convert float infinity to integer) while other methods covert this ratio to int --- easyocr/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/easyocr/utils.py b/easyocr/utils.py index 987baf2c9a6..03cec539827 100644 --- a/easyocr/utils.py +++ b/easyocr/utils.py @@ -561,6 +561,8 @@ def calculate_ratio(width,height): ratio = width/height if ratio<1.0: ratio = 1./ratio + #set to 2 decimal places, to avoid OverflowError(cannot convert float infinity to integer) while other methods covert this ratio to int + ratio = round(ratio,3) return ratio def compute_ratio_and_resize(img,width,height,model_height):