From 0d21b62aee91a8df9b196e3c0a3bd98aa6036141 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Fri, 10 Apr 2026 18:23:10 +0200 Subject: [PATCH] =?UTF-8?q?disable=20autosized=20prediction=20entirely=20(?= =?UTF-8?q?also=20for=20=5Fpatched)=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 338c4a0e wrapped all prediction models for automatic image size adaptation in CUDA, - tiling (`_patched`) was indeed faster - whole (`_resized`) was actually slower But CUDA-based tiling also increases GPU memory requirements a lot. And with the new parallel subprocess predictors, Numpy- based tiling is not necessarily slower anymore. --- src/eynollah/eynollah.py | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/eynollah/eynollah.py b/src/eynollah/eynollah.py index a385e2f..3b2d00e 100644 --- a/src/eynollah/eynollah.py +++ b/src/eynollah/eynollah.py @@ -179,9 +179,9 @@ class Eynollah: ] if self.input_binary: loadable.append("binarization") # todo: binarization_patched - loadable.append("textline_patched") # textline + loadable.append("textline") # textline_patched loadable.append("region_1_2") - loadable.append("region_1_2_patched") + #loadable.append("region_1_2_patched") if self.full_layout: loadable.append("region_fl_np") #loadable.append("region_fl_patched") @@ -914,10 +914,10 @@ class Eynollah: img = resize_image(img, int(img_height_h * 2500 / float(img_width_h)), 2500).astype(np.uint8) if patches: - prediction_regions, _ = self.do_prediction_new_concept_autosize( - img, self.model_zoo.get("region_fl_patched"), - # prediction_regions, _ = self.do_prediction_new_concept( - # True, img, self.model_zoo.get("region_fl"), + # prediction_regions, _ = self.do_prediction_new_concept_autosize( + # img, self.model_zoo.get("region_fl_patched"), + prediction_regions, _ = self.do_prediction_new_concept( + True, img, self.model_zoo.get("region_fl"), n_batch_inference=2, thresholding_for_heading=True) else: @@ -1075,10 +1075,10 @@ class Eynollah: thresholding_for_artificial_class=True, threshold_art_class=self.threshold_art_class_textline) if use_patches: - prediction_textline, _ = self.do_prediction_new_concept_autosize( - img, self.model_zoo.get("textline_patched"), **kwargs) - # prediction_textline, _ = self.do_prediction_new_concept( - # True, img, self.model_zoo.get("textline"), **kwargs) + # prediction_textline, _ = self.do_prediction_new_concept_autosize( + # img, self.model_zoo.get("textline_patched"), **kwargs) + prediction_textline, _ = self.do_prediction_new_concept( + True, img, self.model_zoo.get("textline"), **kwargs) else: prediction_textline, _ = self.do_prediction_new_concept( False, img, self.model_zoo.get("textline"), **kwargs) @@ -1136,12 +1136,13 @@ class Eynollah: if img_height_h / img_width_h > 2.5: self.logger.debug("resized to %dx%d for %d cols", img_resized.shape[1], img_resized.shape[0], num_col_classifier) - prediction_regions_org, confidence_matrix = \ - self.do_prediction_new_concept_autosize( - img_resized, self.model_zoo.get("region_1_2_patched"), - # self.do_prediction_new_concept( - # True, img_resized, self.model_zoo.get("region_1_2"), + prediction_regions_org, confidence_matrix = ( + # self.do_prediction_new_concept_autosize( + # img_resized, self.model_zoo.get("region_1_2_patched"), + self.do_prediction_new_concept( + True, img_resized, self.model_zoo.get("region_1_2"), **kwargs) + ) else: prediction_regions_org, confidence_matrix = \ self.do_prediction_new_concept( @@ -1154,12 +1155,13 @@ class Eynollah: self.logger.debug("resized to %dx%d (new_w=%d) for %d cols", img_resized.shape[1], img_resized.shape[0], new_w, num_col_classifier) - prediction_regions_org, confidence_matrix = \ - self.do_prediction_new_concept_autosize( - img_resized, self.model_zoo.get("region_1_2_patched"), - # self.do_prediction_new_concept( - # True, img_resized, self.model_zoo.get("region_1_2"), + prediction_regions_org, confidence_matrix = ( + # self.do_prediction_new_concept_autosize( + # img_resized, self.model_zoo.get("region_1_2_patched"), + self.do_prediction_new_concept( + True, img_resized, self.model_zoo.get("region_1_2"), **kwargs) + ) prediction_regions_org = resize_image(prediction_regions_org, img_height_h, img_width_h ) confidence_matrix = resize_image(confidence_matrix, img_height_h, img_width_h )