mirror of
https://github.com/mikegerber/ocrd_calamari.git
synced 2025-06-08 19:29:53 +02:00
Merge pull request #42 from OCR-D/file-ids-and-such
use make_file_id and assert_file_grp_cardinality
This commit is contained in:
commit
210c126003
2 changed files with 6 additions and 8 deletions
|
@ -20,6 +20,7 @@ from ocrd_models.ocrd_page import (
|
||||||
from ocrd_utils import (
|
from ocrd_utils import (
|
||||||
getLogger, concat_padded,
|
getLogger, concat_padded,
|
||||||
coordinates_for_segment, points_from_polygon, polygon_from_x0y0x1y1,
|
coordinates_for_segment, points_from_polygon, polygon_from_x0y0x1y1,
|
||||||
|
make_file_id, assert_file_grp_cardinality,
|
||||||
MIMETYPE_PAGE
|
MIMETYPE_PAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,17 +47,14 @@ class CalamariRecognize(Processor):
|
||||||
voter_params.type = VoterParams.Type.Value(self.parameter['voter'].upper())
|
voter_params.type = VoterParams.Type.Value(self.parameter['voter'].upper())
|
||||||
self.voter = voter_from_proto(voter_params)
|
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):
|
def process(self):
|
||||||
"""
|
"""
|
||||||
Performs the recognition.
|
Performs the recognition.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
assert_file_grp_cardinality(self.input_file_grp, 1)
|
||||||
|
assert_file_grp_cardinality(self.output_file_grp, 1)
|
||||||
|
|
||||||
self._init_calamari()
|
self._init_calamari()
|
||||||
|
|
||||||
for (n, input_file) in enumerate(self.input_files):
|
for (n, input_file) in enumerate(self.input_files):
|
||||||
|
@ -221,7 +219,7 @@ class CalamariRecognize(Processor):
|
||||||
for name in self.parameter.keys()])]))
|
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)
|
pcgts.set_pcGtsId(file_id)
|
||||||
self.workspace.add_file(
|
self.workspace.add_file(
|
||||||
ID=file_id,
|
ID=file_id,
|
||||||
|
|
|
@ -3,4 +3,4 @@ tensorflow-gpu == 1.15.*
|
||||||
calamari-ocr == 0.3.5
|
calamari-ocr == 0.3.5
|
||||||
setuptools >= 41.0.0 # tensorboard depends on this, but why do we get an error at runtime?
|
setuptools >= 41.0.0 # tensorboard depends on this, but why do we get an error at runtime?
|
||||||
click
|
click
|
||||||
ocrd >= 2.2.1
|
ocrd >= 2.13.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue