mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-06-08 19:59:56 +02:00
cnnrnn Ocr: width of input textline image can not be zero!
This commit is contained in:
parent
4de441eaaa
commit
91b2201b07
1 changed files with 5 additions and 1 deletions
|
@ -4981,7 +4981,7 @@ class Eynollah_ocr:
|
||||||
self.model_ocr.to(self.device)
|
self.model_ocr.to(self.device)
|
||||||
|
|
||||||
else:
|
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)
|
model_ocr = load_model(self.model_ocr_dir , compile=False)
|
||||||
|
|
||||||
self.prediction_model = tf.keras.models.Model(
|
self.prediction_model = tf.keras.models.Model(
|
||||||
|
@ -5125,11 +5125,15 @@ class Eynollah_ocr:
|
||||||
def preprocess_and_resize_image_for_ocrcnn_model(self, img, image_height, image_width):
|
def preprocess_and_resize_image_for_ocrcnn_model(self, img, image_height, image_width):
|
||||||
ratio = image_height /float(img.shape[0])
|
ratio = image_height /float(img.shape[0])
|
||||||
w_ratio = int(ratio * img.shape[1])
|
w_ratio = int(ratio * img.shape[1])
|
||||||
|
|
||||||
if w_ratio <= image_width:
|
if w_ratio <= image_width:
|
||||||
width_new = w_ratio
|
width_new = w_ratio
|
||||||
else:
|
else:
|
||||||
width_new = image_width
|
width_new = image_width
|
||||||
|
|
||||||
|
if width_new == 0:
|
||||||
|
width_new = img.shape[1]
|
||||||
|
|
||||||
img = resize_image(img, image_height, width_new)
|
img = resize_image(img, image_height, width_new)
|
||||||
img_fin = np.ones((image_height, image_width, 3))*255
|
img_fin = np.ones((image_height, image_width, 3))*255
|
||||||
img_fin[:,:+width_new,:] = img[:,:,:]
|
img_fin[:,:+width_new,:] = img[:,:,:]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue