Funktionen und Möglichkeiten der OCR-D-Software

Clemens Neudecker & Konstantin Baierer
Staatsbibliothek zu Berlin (SBB)

OCR-D Abschlussworkshop, DFG
12.02.2020 | Wissenschaftszentrum Bonn


Inhalte

  1. Grundlegende Annahmen
  2. OCR-D Kernkomponenten
  3. Funktionen der OCR-D Software
  4. OCR-D Modulprojekte
  5. OCR-D Community
  6. Herausforderungen

Grundlegende Annahmen

> Anreicherung von METS Bilddigitalisaten mit OCR- und Metadaten


Grundlegende Annahmen

  • Maximale Tiefe an Information der OCR ermöglichen
  • Maximale Flexibilität für die Entwicklung garantieren
  • Maximale Kompatibilität zu state-of-the-art sicherstellen

> PAGE für OCR Ergebnisse
> Transformationen PAGE zu ALTO & TEI


Grundlegende Annahmen

  • FLOSS als Grundprinzip: Anforderungen, Entwicklung, Dokumentation transparent und über offene Plattformen

> Frühe Einbindung von Anwendern, Entwicklern
> Transparenz über die gesamte Entwicklung
> Nachvollziehbarkeit, Reproduzierbarkeit


OCR-D Kernkomponenten


OCR-D spec


OCR-D core

  • CLI für Download/Erzeugung/Verarbeitung von METS/Bildern/PAGE
  • Validierung verschiedener Datenformate
  • Bibliothek für die Entwicklung von Prozessoren in Python und Bash
  • Logging, Koordinatenarithmetik, APIs für METS/PAGE/ocrd-tool.json

OCR-D ocrd_all

  • Initiative von @stweil und @bertsky
  • Kombiniert core, spec und alle Modulprojekte
  • Makefile-basierte Lösung: make all um OCR-D komplett zu installieren
  • Erzeugen von Docker Images

OCR-D repository

  1. OCR-D-GT-Repositorium
    • Öffentlich verfügbares Repositorium aller Ground Truth Daten
    • BagIt Container für Ground Truth
    • Vielfältige Suchfunktionen
  2. Forschungsdatenrepositorium
    • Speicherung der Ergebnisse des Workflows & Provenienzinformationen
    • Nur intern verfügbar

OCR-D repository


OCR-D workflow

Mit Taverna können Workflows mit OCR-D-Prozessoren ausgeführt werden. Während der Ausführung werden

  • stdout
  • stderr
  • Provenienz (Prozessor, Version, Input, Output, Parameter, Start-/Endzeit)

geloggt und mit den Ergebnissen im Forschungsdatenrepositorium gespeichert


OCR-D workflow

Perspektivisch (KIT, work-in-progress):

Cross-Evaluation von verschiedenen Workflows

  • Höchste Erkennungsrate (mit/ohne GPU)
  • Schnellste Prozessierung (mit/ohne GPU)
  • Materialspezifische Optimierung

OCR-D workflow


OCR-D Framework

Das OCR-D Framework enthält alle Komponenten zur Ausführung eines kompletten Workflows.

  • Forschungsdatenrepositorium
  • Taverna Workflow Engine
  • Prozessoren

Es besteht aus mehreren Docker Containern.


Was kann die OCR-D Software


Digitalisat laden (METS)

$ ocrd workspace clone \
https://raw.githubusercontent.com/OCR-D/assets/master/data/communist_manifesto/data/mets.xml \
/tmp/workspace1

find /tmp/workspace1
/tmp/workspace1/mets.xml

Digitalisat laden (METS + Bilder)

$ ocrd workspace clone \
    --download \
    https://raw.githubusercontent.com/OCR-D/assets/master/data/communist_manifesto/data/mets.xml \
    /tmp/workspace2

find /tmp/workspace2
/tmp/workspace2/mets.xml
/tmp/workspace2/OCR-D-IMG
/tmp/workspace2/OCR-D-IMG/OCR-D-IMG_0015.png

Validieren von METS, PAGE, Images

$ ocrd workspace -d /tmp/workspace1 validate
<report valid="true">
  <notice>Image OCR-D-IMG_0015: xResolution (1 pixels per inches) is suspiciously low</notice>
  <notice>Image OCR-D-IMG_0015: yResolution (1 pixels per inches) is suspiciously low</notice>
</report>

Ohne METS [1]

  1. Erzeugen eines minimalen METS
$ ocrd workspace init /tmp/workspace-new

ocrd workspace init /tmp/workspace-new
12:59:19.479 INFO ocrd.resolver - Writing METS to /tmp/workspace-new/mets.xml
12:59:19.480 INFO ocrd.workspace - Saving mets '/tmp/workspace-new/mets.xml'
/tmp/workspace-new
  1. Bilder hinzufügen
$ ocrd workspace add \
    --file-grp DEFAULT \
    --file-id page1_img \
    --mimetype image/tiff \
    --page-id page1 \
    page1.tiff

Ohne METS [2]

@@ -9,3 +9,6 @@
     <mets:div TYPE="physSequence">
-        </mets:div>
+      <mets:div TYPE="page" ID="page1">
+        <mets:fptr FILEID="page1_img"/>
+      </mets:div>
+    </mets:div>
   </mets:structMap>
@@ -22,3 +25,8 @@
   <mets:fileSec>
-    </mets:fileSec>
+    <mets:fileGrp USE="DEFAULT">
+      <mets:file MIMETYPE="image/tiff" ID="page1_img">
+        <mets:FLocat LOCTYPE="OTHER" OTHERLOCTYPE="FILE" xlink:href="page1.tiff"/>
+      </mets:file>
+    </mets:fileGrp>
+  </mets:fileSec>
 </mets:mets>
---


Mehr Helfer fuer die Arbeit mit METS

$ ocrd workspace --help
Commands:
  add           Add a file LOCAL_FILENAME to METS in a workspace.
  backup        Backing and restoring workspaces - dev edition
  clone         Create a workspace from a METS_URL and return the directory...                                                                   
  find          Find files.
  get-id        Get METS id if any
  init          Create a workspace with an empty METS file in DIRECTORY.
  list-group    List fileGrp USE attributes
  list-page     List page IDs
  prune-files   Removes mets:files that point to non-existing local files                                                                        
  remove        Delete file by ID from mets.xml
  remove-group  Delete a file group
  set-id        Set METS ID.
  validate      Validate a workspace


OCRD-ZIP aus Workspace generieren

$ ocrd zip bag -d /tmp/workspace1 --id 'https://ocr-d.de/gt/123'
13:05:27.502 INFO ocrd.workspace_bagger - Bagging /tmp/workspace1 to /tmp/workspace1.ocrd.zip (temp dir /tmp/ocrd-bagit-zcyaar_5)
13:05:27.502 INFO ocrd.workspace_bagger - Resolving OCR-D-IMG/OCR-D-IMG_0015.png (partial)
13:05:27.502 INFO ocrd.workspace_bagger - Resolved OCR-D-IMG/OCR-D-IMG_0015.png
13:05:27.805 INFO ocrd.workspace_bagger - Created bag at /tmp/workspace1.ocrd.zip

Beispiel in OCR-D/assets


OCRD-ZIP validieren

$ ocrd zip validate /tmp/workspace1.ocrd.zip
13:08:04.640 INFO bagit - Verifying checksum for file /tmp/ocrd-bagit-_9ydkekl/data/mets.xml
13:08:04.641 INFO bagit - Verifying checksum for file /tmp/ocrd-bagit-_9ydkekl/data/OCR-D-IMG/OCR-D-IMG_0015.png
13:08:04.664 INFO bagit - Verifying checksum for file /tmp/ocrd-bagit-_9ydkekl/manifest-sha512.txt
13:08:04.664 INFO bagit - Verifying checksum for file /tmp/ocrd-bagit-_9ydkekl/bagit.txt
13:08:04.664 INFO bagit - Verifying checksum for file /tmp/ocrd-bagit-_9ydkekl/bag-info.txt
OK

Hilfe zu jedem Prozessor

$ ocrd-cis-ocropy-binarize --help

Usage: ocrd-cis-ocropy-binarize [OPTIONS]

  Binarize (and optionally deskew/despeckle) pages / regions / lines with ocropy

Options:
  -V, --version                   Show version
  -l, --log-level [OFF|ERROR|WARN|INFO|DEBUG|TRACE]
                                  Log level
  -J, --dump-json                 Dump tool description as JSON and exit
  -p, --parameter TEXT            Parameters, either JSON string or path
                                  JSON file
  -g, --page-id TEXT              ID(s) of the pages to process
  -O, --output-file-grp TEXT      File group(s) used as output.
  -I, --input-file-grp TEXT       File group(s) used as input.
  -w, --working-dir TEXT          Working Directory
  -m, --mets TEXT                 METS to process
  -h, --help                      This help message

Parameters:
  "method" [string - ocropy] binarization method to use (only ocropy
      will include deskewing) Possible values: ["none", "global",
      "otsu", "gauss-otsu", "ocropy"]
  "grayscale" [boolean - False] for the ocropy method, produce
      grayscale-normalized instead of thresholded image
  "maxskew" [number - 0.0] modulus of maximum skewing angle to detect
      (larger will be slower, 0 will deactivate deskewing)
  "noise_maxsize" [number - 0] maximum pixel number for connected
      components to regard as noise (0 will deactivate denoising)
  "level-of-operation" [string - page] PAGE XML hierarchy level
      granularity to annotate images for Possible values: ["page",
      "region", "line"]

Default Wiring:
  ['OCR-D-IMG', 'OCR-D-SEG-BLOCK', 'OCR-D-SEG-LINE'] -> ['OCR-D-IMG-BIN', 'OCR-D-SEG-BLOCK', 'OCR-D-SEG-LINE']

Validieren einer PAGE-Datei

$ wget 'https://github.com/OCR-D/assets/raw/master/data/kant_aufklaerung_1784/data/OCR-D-GT-PAGE/PAGE_0017_PAGE.xml'
$ ocrd validate page \
    --check-coords \
    --check-baseline \
    --page-textequiv-consistency strict \
    PAGE_0017_PAGE.xml

Weitere Validierungen

$ ocrd validate
Usage: ocrd validate [OPTIONS] COMMAND [ARGS]...

  All the validation in one CLI

Options:
  --help  Show this message and exit.

Commands:
  page        Validate PAGE against OCR-D conventions
  parameters  Validate PARAM_JSON against parameter definition of
              EXECUTABLE...
  tasks       Validate a sequence of tasks passable to 'ocrd process'
  tool-json   Validate OCRD_TOOL as an ocrd-tool.json file.

Einfache serielle Workflows definieren

$ ocrd process --mets /pfad/zur/mets.xml \
	'binarize -I MAX -O BIN' \
	'segment -I BIN -O SEG' \
	'recognize -I SEG -O OCR'

Minimaler Workflow mit "Bordmitteln"

$ cp -r ~monorepo/assets/data/kant_aufklaerung_1784/data /tmp/ws1
$ cd /tmp/ws1
$ ocrd process \
    'cis-ocropy-binarize -I OCR-D-IMG -O BIN,BIN-IMG' \
    'anybaseocr-crop -I BIN -O CROP,CROP-IMG' \
    'cis-ocropy-deskew -I CROP -O DESKEW' \
    'tesserocr-segment-region -I DESKEW -O PAGE-REGION' \
    'tesserocr-segment-line -I PAGE-REGION -O PAGE-LINE' \
    'tesserocr-recognize -I PAGE-LINE -O OCR-TESS -p "{\"model\": \"GT4HistOCR_0.913_233896_953200\"}"'

OCR-D Modulprojekte

  • Funktionsmodell


OCR-D Modulprojekte


OCR-D MP1

Scalable Methods of Text and Structure Recognition for the Full-Text Digitization of Historical Prints, Part 1.B: Image Optimization (DFKI Kaiserslautern)

Ziele: Identifizierung, Entwicklung und Integration geeigneter Algorithmen für


Beispiel MP1

ocrd-anybaseocr-binarize \
	--mets /path/to/mets.xml \
	--input-file-grp MAX \
	--output-file-grp BIN-ANYBASE \
	-p '{"gray": false}'

Beispiel MP1


OCR-D MP2

Scalable Methods of Text and Structure Recognition for the Full-Text Digitization of Historical Prints, Part 2: Layout Analysis - DFKI Kaiserslautern

Ziele:


Beispiel MP2

ocrd-anybaseocr-block-segmentation \
    -I BIN \
    -O SEG-BLOCK-ANYBASEOCR \
	-p '{"operation_level": "page"}'


Beispiel MP2

ocrd-anybaseocr-block-segmentation \
    -I BIN \
    -O SEG-LINE-ANYBASEOCR \
	-p '{"operation_level": "region"}'

OCR-D MP3

Development of a semi-automatic open source tool for layout analysis and region extraction and region classificiation (LAREX) of early prints (Universität Würzburg)

Ziele:


Beispiel MP3


Beispiel MP3


OCR-D MP4

NN/FST - Unsupervised OCR-Postcorrection based on Neural Networks and Finite-state Transducers (Universität Leipzig)

Ziele:


Beispiel MP4


OCR-D MP5

Optimized use of OCR methods – Tesseract as a component of the OCR-D workflow (Universitätsbibliothek Mannheim)

Ziele:


Beispiel MP5

Tesseract Fraktur -> GT4HistOCR


OCR-D MP6

Automated postcorrection of OCRed historical printings with integrated optional interactive postcorrection (Universität München)

Ziele:

  • Entwicklung eines Machine-Learning basierten Systems zur vollautomatischen OCR-Nachkorrektur
  • Einbindung des Systems in den OCR-D Workflow

OCR-D MP6

Ziele (cont'd):

  • Nutzbarmachung der PoCoTo-Technologie für das ML-basierte System
  • Entwicklung und Integration zusätzlicher Analyseverfahren in OCR-D
    -> ocrd_cis
  • (optionale) interaktive Nachkorrektur -> PoCoTo, pocoweb

Beispiel MP6

$ ocrd-cis-ocropy-binarize -I OCR-D-IMG -O BIN

OCR-D MP7

Development of a Repository for OCR Models and an Automatic Font Recognition tool in OCR-D (Universitäten Erlangen, Mainz, Leipzig)

Ziele:


Beispiel MP7

okralact - a multi-engine Open Source OCR training system (HIP@ICDAR2019)


Beispiel MP7

Dataset of Pages from Early Printed Books with Multiple Font Groups (HIP@ICDAR2019)


OCR-D MP8

DPO-HP - Digital Preservation of OCR-D data for historical printings (SUB Göttingen, GWDG)

Ziele:

  • Integriertes Konzept für Langzeitarchivierung und persistente Identifizierung von OCR-Objekten inkl. Versionierung sowie Implementierung eines Proof-of-concept -> OLA-HD

Beispiel MP8



OCR-D Ergänzungen [1]


OCR-D Ergänzungen [2]


OCR-D Ergänzungen [3]

  • ocrd_fileformat - Transformation zwischen Formaten
    (PAGE, ALTO, TEI, hOCR, Text)
  • ocrd_keraslm - Zeichenbasiertes Sprachmodell für Keras

OCR-D ecosphere


Kooperation innerhalb und ausserhalb von OCR-D






OCR-D community - DHd AGs


OCR-D community - software


OCR-D community - international [1]


OCR-D community - international [2]


OCR-D community - Projekte

  • EU-Projekt READ / Transkribus
    • Fachlicher Austausch in Video- und Fachkonferenzen
  • BMBF-Projekt QURATOR
    • Bereitstellung von Komponenten für Binarisierung, Segmentierung, OCR & Evaluation entsprechend OCR-D Schnittstellen

OCR-D community - Internationales Interesse

  • British Library
  • Collegio de Mexico
  • Nationalbibliothek von Dänemark
  • Nationalbibliothek von Lettland
  • Nationalbibliothek von Luxemburg

Herausforderung: Qualitätssicherung

  • Ursprünglich eigenes Modul mit Aufgabe, Qualitätsprüfungsverfahren (ohne Ground Truth) zu entwickeln
  • Keine Förderung eingereichter Anträge, "Ersatzantrag" des Koordinierungsprojekt scheitert ebenfalls
  • Bereitstellung von OCR-D kompatiblem Evaluationsprozessor dinglehopper aus SBB/QURATOR für Ermittlung von CER/WER

Herausforderung: Modelltraining

  • Keine zentrale Umgebung zur Erstellung von Trainingsdaten
  • Modellinfrastruktur (MP7) liegt erst spät vor

Modelltraining - wie weiter?


Herausforderung: Ground Truth

  • Ausgehend von Anforderungen an wissenschaftlich nutzbare Volltexte umfangreiche Erweiterung und Systematisierung von Ground Truth Richtlinien
  • Transkriptionen des DTA nicht ohne Nachbearbeitung als Ground Truth verwendbar
  • Struktur vs Transkription, Menge vs Qualität

Herausforderung: Ground Truth

  • Ausschreibung (SBB) zur Erstellung von Ground Truth gemäß OCR-D Richtlinien
    • Markterkundung in 2017 ermittelt 3 Dienstleister
    • 1 Dienstleister zieht in der Vergabe zurück
    • 1 Dienstleister bricht nach Verzögerung und teilweiser Bearbeitung ab
    • Umfangreiche Korrektur- und Nacharbeiten erforderlich (SBB, work-in-progress)

Herausforderung: Ground Truth

  • Analyse verfügbaren Ground Truth verschiedener Einrichtungen (ÖNB Zeitungen, Universität Basel Journale, NZZ impresso, Nationalbibliothek von Luxemburg) zeigen bei genauer Prüfung dass Qualität noch nicht den Anforderungen für die Verwendung innerhalb OCR-D genügt

Ground Truth - wie weiter?

  • Festlegung und Erstellung von Transkriptionsrichtlinien
  • Konsolidierung und Harmonisierung von Ground Truth aus div. Quellen
Select a repo