From bdab016e2ce884839d7de0e6b391a127e293e205 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Wed, 2 Oct 2019 16:48:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20GT4HistOCR=5F2000000=20model?= =?UTF-8?q?=20from=20qurator-data=20for=20Tesseract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 23 +++++++++++++---------- build | 6 ++++-- data | 2 +- my_ocrd_workflow | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e536f5..31546df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,10 @@ FROM ubuntu:18.04 ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 -RUN mkdir /var/lib/calamari-models -COPY data/calamari-models/GT4HistOCR /var/lib/calamari-models/GT4HistOCR +ENV LEPTONICA_VERSION 1.78.0 +ENV TESSERACT_VERSION 4.1.0 +ENV TESSDATA_BEST_VERSION 4.0.0 +ENV TESSDATA_PREFIX /usr/local/share/tessdata RUN apt-get update && \ @@ -24,12 +26,6 @@ RUN apt-get update && \ # Build Leptonica and Tesseract. # XXX Use a multi stage build for this. -ENV LEPTONICA_VERSION 1.78.0 -ENV TESSERACT_VERSION 4.1.0 -ENV TESSDATA_BEST_VERSION 4.0.0 - -ENV TESSDATA_PREFIX /usr/local/share/tessdata - RUN curl -sSL -O https://github.com/DanBloomberg/leptonica/releases/download/$LEPTONICA_VERSION/leptonica-$LEPTONICA_VERSION.tar.gz && \ tar xvzf leptonica-$LEPTONICA_VERSION.tar.gz && \ cd leptonica-$LEPTONICA_VERSION && \ @@ -45,9 +41,16 @@ RUN curl -sSL -O https://github.com/tesseract-ocr/tesseract/archive/$TESSERACT_V RUN curl -sSL -O https://github.com/tesseract-ocr/tessdata_best/archive/$TESSDATA_BEST_VERSION.tar.gz && \ tar xvzf $TESSDATA_BEST_VERSION.tar.gz && \ mv tessdata_best-$TESSDATA_BEST_VERSION $TESSDATA_PREFIX && \ - rm -rf $TESSDATA_BEST_VERSION.tar.gz && \ - tesseract --list-langs + rm -rf $TESSDATA_BEST_VERSION.tar.gz + + +# Copy OCR models +RUN mkdir /var/lib/calamari-models +COPY data/calamari-models/GT4HistOCR /var/lib/calamari-models/GT4HistOCR +RUN mkdir $TESSDATA_PREFIX +COPY data/tesseract-models/GT4HistOCR/GT4HistOCR_2000000.traineddata $TESSDATA_PREFIX +RUN tesseract --list-langs COPY requirements.txt /tmp diff --git a/build b/build index 4037885..3b11557 100755 --- a/build +++ b/build @@ -3,8 +3,10 @@ set -e ( cd data - git annex get calamari-models/GT4HistOCR - git annex unlock calamari-models/GT4HistOCR # So they are not symlinks + git annex init + git annex upgrade + git annex get calamari-models/GT4HistOCR/*.ckpt* + git annex get tesseract-models/GT4HistOCR/*.traineddata ) docker build -t my_ocrd_workflow . diff --git a/data b/data index ca541f5..eb7412a 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit ca541f5ebb4593fde2aaef217bf606f7c2bf148a +Subproject commit eb7412a1efbcba53567ec37237732e96e839dbe8 diff --git a/my_ocrd_workflow b/my_ocrd_workflow index aa46b52..3d41391 100755 --- a/my_ocrd_workflow +++ b/my_ocrd_workflow @@ -79,7 +79,7 @@ do_linesegmentation() { do_ocr() { # Perform OCR on the segmented lines - ocrd_tesserocr_recognize_parameters='{ "model": "frk" }' # TODO mods:language + fontident → model + ocrd_tesserocr_recognize_parameters='{ "model": "GT4HistOCR_2000000" }' # TODO mods:language + fontident → model remove_filegrp OCR-D-OCR-TESS mets.xml ocrd-tesserocr-recognize -l $LOG_LEVEL \ -m mets.xml -I OCR-D-SEG-LINE -O OCR-D-OCR-TESS \