From 1a308a5522195aa2743e8fdadd1826ccd1eb8257 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Thu, 30 Jul 2020 20:55:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Use=20OCR-D's=20-P,=20remove=20n?= =?UTF-8?q?ow=20redundant=20validation=20and=20remove=20now=20unnecessary?= =?UTF-8?q?=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- my_ocrd_workflow | 93 +++++------------------------------------------- 1 file changed, 8 insertions(+), 85 deletions(-) diff --git a/my_ocrd_workflow b/my_ocrd_workflow index 18c096d..833b0cd 100755 --- a/my_ocrd_workflow +++ b/my_ocrd_workflow @@ -53,107 +53,30 @@ do_validate() { fi } -do_binarization() { - # Binarize the images - - ocrd_olena_binarize_parameters='{ - "impl": "sauvola-ms-split" - }' - ocrd-olena-binarize --overwrite -I $INPUT_FILE_GRP -O OCR-D-IMG-BINPAGE,OCR-D-IMG-BIN -p "$ocrd_olena_binarize_parameters" -} - -do_linesegmentation_tesserocr() { - # Segment the lines in the binarized images - - ocrd-tesserocr-segment-region --overwrite -I OCR-D-IMG-BINPAGE -O OCR-D-SEG-REGION - ocrd-tesserocr-segment-line --overwrite -I OCR-D-SEG-REGION -O OCR-D-SEG-LINE -} - -do_linesegmentation_sbb() { - # Segment the lines in the images - - ocrd_sbb_textline_detector_parameters='{ - "model": "/var/lib/textline_detection" - }' - ocrd-sbb-textline-detector --overwrite -I OCR-D-IMG-BINPAGE -O OCR-D-SEG-LINE -p "$ocrd_sbb_textline_detector_parameters" -} - -do_ocr() { - # Perform OCR on the segmented lines - - ocrd_tesserocr_recognize_parameters='{ - "model": "GT4HistOCR_2000000", - "textequiv_level": "'$TEXTEQUIV_LEVEL'" - }' - ocrd-tesserocr-recognize --overwrite -I OCR-D-SEG-LINE -O OCR-D-OCR-TESS -p "$ocrd_tesserocr_recognize_parameters" -} - -do_ocr_calamari() { - # Perform OCR on the segmented lines - - ocrd_calamari_recognize_parameters='{ - "checkpoint": "/var/lib/calamari-models/GT4HistOCR/2019-07-22T15:49+0200/*.ckpt.json", - "textequiv_level": "'$TEXTEQUIV_LEVEL'" - }' - ocrd-calamari-recognize --overwrite -I OCR-D-SEG-LINE -O OCR-D-OCR-CALAMARI -p "$ocrd_calamari_recognize_parameters" -} - -page_validate_xml() { - # Validate all PAGE XML against the XML schema - - filegrp=$1 - - local file - for file in `ocrd workspace find -G $filegrp`; do - XSD_DIR=`dirname $0`/xsd - if [ ! -d "$XSD_DIR" ]; then - XSD_DIR=/usr/share/xml - fi - xmllint --noout --schema $XSD_DIR/pagecontent.2019-07-15.xsd $file - done -} - -page_upgrade_to_2019() { - # Upgrade PAGE files to 2019-07-15 - - filegrp=$1 - - local file - for file in `ocrd workspace find -G $filegrp`; do - sed -i 's#pagecontent/[0-9-]*#pagecontent/2019-07-15#g' $file - done -} - main() { do_validate - do_binarization - do_validate - - do_linesegmentation_sbb - page_upgrade_to_2019 OCR-D-SEG-LINE - page_validate_xml OCR-D-SEG-REGION - page_validate_xml OCR-D-SEG-LINE + ocrd-olena-binarize --overwrite -I $INPUT_FILE_GRP -O OCR-D-IMG-BINPAGE,OCR-D-IMG-BIN -P impl "sauvola-ms-split" do_validate - do_ocr_calamari + #ocrd-tesserocr-segment-region --overwrite -I OCR-D-IMG-BINPAGE -O OCR-D-SEG-REGION + #ocrd-tesserocr-segment-line --overwrite -I OCR-D-SEG-REGION -O OCR-D-SEG-LINE + ocrd-sbb-textline-detector --overwrite -I OCR-D-IMG-BINPAGE -O OCR-D-SEG-LINE -P model "/var/lib/textline_detection" + do_validate - do_ocr + ocrd-calamari-recognize --overwrite -I OCR-D-SEG-LINE -O OCR-D-OCR-CALAMARI -P checkpoint "/var/lib/calamari-models/GT4HistOCR/2019-07-22T15:49+0200/*.ckpt.json" -P textequiv_level "$TEXTEQUIV_LEVEL" + ocrd-tesserocr-recognize --overwrite -I OCR-D-SEG-LINE -O OCR-D-OCR-TESS -P model "GT4HistOCR_2000000" -P textequiv_level "$TEXTEQUIV_LEVEL" + do_validate for ocr_filegrp in OCR-D-OCR-CALAMARI OCR-D-OCR-TESS; do - - page_validate_xml $ocr_filegrp - do_validate - if ocrd workspace list-group | grep -q OCR-D-GT-PAGE; then ocrd-dinglehopper --overwrite -I OCR-D-GT-PAGE,$ocr_filegrp -O $ocr_filegrp-EVAL fi - done }