reading order on given layout

This commit is contained in:
vahidrezanezhad 2025-08-18 02:31:13 +02:00
parent 20614d1678
commit 8dc2fab9fa
2 changed files with 1158 additions and 24 deletions

View file

@ -4,6 +4,7 @@ from ocrd_utils import initLogging, getLevelName, getLogger
from eynollah.eynollah import Eynollah, Eynollah_ocr from eynollah.eynollah import Eynollah, Eynollah_ocr
from eynollah.sbb_binarize import SbbBinarizer from eynollah.sbb_binarize import SbbBinarizer
from eynollah.image_enhancer import Enhancer from eynollah.image_enhancer import Enhancer
from eynollah.mb_ro_on_layout import machine_based_reading_order_on_layout
@click.group() @click.group()
def main(): def main():
@ -13,38 +14,37 @@ def main():
@click.option( @click.option(
"--dir_xml", "--dir_xml",
"-dx", "-dx",
help="directory of GT page-xml files", help="directory of page-xml files",
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
) )
@click.option( @click.option(
"--dir_out_modal_image", "--xml_file",
"-domi", "-xml",
help="directory where ground truth images would be written", help="xml filename",
type=click.Path(exists=True, dir_okay=False),
)
@click.option(
"--dir_out",
"-do",
help="directory for output images",
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
) )
@click.option( @click.option(
"--dir_out_classes", "--model",
"-docl", "-m",
help="directory where ground truth classes would be written", help="directory of models",
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
required=True,
) )
@click.option(
"--input_height", def machine_based_reading_order(dir_xml, xml_file, dir_out, model):
"-ih", raedingorder_object = machine_based_reading_order_on_layout(model, dir_out=dir_out, logger=getLogger('enhancement'))
help="input height",
) if dir_xml:
@click.option( raedingorder_object.run(dir_in=dir_xml)
"--input_width", else:
"-iw", raedingorder_object.run(xml_filename=xml_file)
help="input width",
)
@click.option(
"--min_area_size",
"-min",
help="min area size of regions considered for reading order training.",
)
def machine_based_reading_order(dir_xml, dir_out_modal_image, dir_out_classes, input_height, input_width, min_area_size):
xml_files_ind = os.listdir(dir_xml)
@main.command() @main.command()
@click.option('--patches/--no-patches', default=True, help='by enabling this parameter you let the model to see the image in patches.') @click.option('--patches/--no-patches', default=True, help='by enabling this parameter you let the model to see the image in patches.')

File diff suppressed because it is too large Load diff