From 91b2201b07b4a2c3860f17fc66789c18d60866b1 Mon Sep 17 00:00:00 2001
From: vahidrezanezhad <vahid631983@gmail.com>
Date: Tue, 1 Apr 2025 10:55:40 +0200
Subject: [PATCH] cnnrnn Ocr: width of input textline image can not be zero!

---
 src/eynollah/eynollah.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/eynollah/eynollah.py b/src/eynollah/eynollah.py
index 1534e7e..436ce84 100644
--- a/src/eynollah/eynollah.py
+++ b/src/eynollah/eynollah.py
@@ -4981,7 +4981,7 @@ class Eynollah_ocr:
             self.model_ocr.to(self.device)
 
         else:
-            self.model_ocr_dir = dir_models + "/model_step_50000_ocr"#"/model_0_ocr_cnnrnn"#"/model_23_ocr_cnnrnn"
+            self.model_ocr_dir = dir_models + "/model_step_150000_ocr"#"/model_0_ocr_cnnrnn"#"/model_23_ocr_cnnrnn"
             model_ocr = load_model(self.model_ocr_dir , compile=False)
             
             self.prediction_model = tf.keras.models.Model(
@@ -5125,10 +5125,14 @@ class Eynollah_ocr:
     def preprocess_and_resize_image_for_ocrcnn_model(self, img, image_height, image_width):
         ratio = image_height /float(img.shape[0])
         w_ratio = int(ratio * img.shape[1])
+        
         if w_ratio <= image_width:
             width_new = w_ratio
         else:
             width_new = image_width
+            
+        if width_new == 0:
+            width_new = img.shape[1]
         
         img = resize_image(img, image_height, width_new)
         img_fin = np.ones((image_height, image_width, 3))*255