From 93190fae3b3d8b5b9a68b37f604c43c34979e5d4 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Wed, 22 Jul 2020 16:03:10 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Recognize=20more=20than=20one=20lin?= =?UTF-8?q?e=20at=20a=20time=20(Fixes=20gh#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ocrd_calamari/recognize.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ocrd_calamari/recognize.py b/ocrd_calamari/recognize.py index 8ae0a17..d040550 100644 --- a/ocrd_calamari/recognize.py +++ b/ocrd_calamari/recognize.py @@ -72,13 +72,16 @@ class CalamariRecognize(Processor): textlines = region.get_TextLine() log.info("About to recognize %i lines of region '%s'", len(textlines), region.id) - for (line_no, line) in enumerate(textlines): - log.debug("Recognizing line '%s' in region '%s'", line.id, region.id) + line_images_np = [] + for (line_no, line) in enumerate(textlines): line_image, line_coords = self.workspace.image_from_segment(line, region_image, region_xywh) line_image_np = np.array(line_image, dtype=np.uint8) + line_images_np.append(line_image_np) + raw_results_all = self.predictor.predict_raw(line_images_np, progress_bar=False) + + for line, raw_results in zip(textlines, raw_results_all): - raw_results = list(self.predictor.predict_raw([line_image_np], progress_bar=False))[0] for i, p in enumerate(raw_results): p.prediction.id = "fold_{}".format(i)