From f746b73fd02436220f92bf46a1dce9d80c65cf72 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Thu, 6 Aug 2020 15:23:56 +0200 Subject: [PATCH] use make_file_id and assert_file_grp_cardinality --- ocrd_calamari/recognize.py | 12 +++++------- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ocrd_calamari/recognize.py b/ocrd_calamari/recognize.py index 5555d75..cf57e62 100644 --- a/ocrd_calamari/recognize.py +++ b/ocrd_calamari/recognize.py @@ -20,6 +20,7 @@ from ocrd_models.ocrd_page import ( from ocrd_utils import ( getLogger, concat_padded, coordinates_for_segment, points_from_polygon, polygon_from_x0y0x1y1, + make_file_id, assert_file_grp_cardinality, MIMETYPE_PAGE ) @@ -46,17 +47,14 @@ class CalamariRecognize(Processor): voter_params.type = VoterParams.Type.Value(self.parameter['voter'].upper()) self.voter = voter_from_proto(voter_params) - def _make_file_id(self, input_file, n): - file_id = input_file.ID.replace(self.input_file_grp, self.output_file_grp) - if file_id == input_file.ID: - file_id = concat_padded(self.output_file_grp, n) - return file_id - def process(self): """ Performs the recognition. """ + assert_file_grp_cardinality(self.input_file_grp, 1) + assert_file_grp_cardinality(self.output_file_grp, 1) + self._init_calamari() for (n, input_file) in enumerate(self.input_files): @@ -221,7 +219,7 @@ class CalamariRecognize(Processor): for name in self.parameter.keys()])])) - file_id = self._make_file_id(input_file, n) + file_id = make_file_id(input_file, self.output_file_grp) pcgts.set_pcGtsId(file_id) self.workspace.add_file( ID=file_id, diff --git a/requirements.txt b/requirements.txt index 0a426e0..58a0207 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ tensorflow-gpu == 1.15.* calamari-ocr == 0.3.5 setuptools >= 41.0.0 # tensorboard depends on this, but why do we get an error at runtime? click -ocrd >= 2.2.1 +ocrd >= 2.13.0