2020-10-28 17:20:02 +01:00
ocrd-galley
===========
2019-06-25 17:54:16 +02:00
2020-10-28 17:20:02 +01:00
[](https://travis-ci.com/qurator-spk/ocrd-galley)
A Dockerized test environment for OCR-D processors 🚢
2020-02-10 18:01:25 +01:00
2020-02-21 16:54:10 +01:00
WIP. Given a OCR-D workspace with document images in the OCR-D-IMG file group,
2020-10-28 17:20:47 +01:00
the example workflow produces:
2019-06-25 17:54:16 +02:00
2020-02-21 16:54:10 +01:00
* Binarized images
* Line segmentation
* OCR text (using Calamari and Tesseract, both with GT4HistOCR models)
* (Given ground truth in OCR-D-GT-PAGE, also an OCR text evaluation report)
2020-08-25 18:56:31 +02:00
If you're interested in the exact processors, versions and parameters, please
take a look at the [script ](my_ocrd_workflow ) and possibly the individual
Dockerfiles.
2020-02-21 16:54:10 +01:00
Goal
----
2020-08-25 18:56:31 +02:00
Provide a **test environment** to produce OCR output for historical prints,
using OCR-D, especially [ocrd_calamari ](https://github.com/OCR-D/ocrd_calamari )
and
[sbb_textline_detection ](https://github.com/qurator-spk/sbb_textline_detection ),
including all dependencies in Docker.
2020-02-21 16:54:10 +01:00
How to use
----------
2020-08-25 18:56:31 +02:00
It's easiest to use it as pre-built containers. To run the containers on an
2020-03-02 18:52:34 +01:00
example workspace:
2019-06-25 17:54:16 +02:00
~~~
2020-09-25 17:46:55 +02:00
# Update to the latest stable containers
2020-10-28 19:05:32 +01:00
(cd ~/devel/ocrd-galley/; ./run-docker-hub-update)
2020-09-25 17:46:55 +02:00
2020-02-21 13:21:06 +01:00
# Download an example workspace
cd /tmp
wget https://qurator-data.de/examples/actevedef_718448162.first-page.zip
unzip actevedef_718448162.first-page.zip
# Run the workflow on it
cd actevedef_718448162.first-page
2020-10-28 19:05:32 +01:00
~/devel/ocrd-galley/run-docker-hub
2020-03-02 18:52:34 +01:00
~~~
2020-08-25 18:56:31 +02:00
### Build the containers yourself
To build the containers yourself using Docker:
2020-03-02 18:52:34 +01:00
~~~
2020-10-28 19:05:32 +01:00
cd ~/devel/ocrd-galley/
2020-03-02 18:52:34 +01:00
./build
2019-06-25 17:54:16 +02:00
~~~
2020-08-25 18:56:31 +02:00
You may then use the script `run` to use your self-built containers, analogous to
2020-03-02 18:52:34 +01:00
the example above.
2020-02-21 13:21:06 +01:00
2020-02-21 16:54:10 +01:00
### Viewing results
2020-02-21 13:21:06 +01:00
You may then examine the results using
[PRImA's PAGE Viewer ](https://www.primaresearch.org/tools/PAGEViewer ):
~~~
2020-08-05 11:16:36 +02:00
java -jar /path/to/JPageViewer.jar \
--resolve-dir . \
OCR-D-OCR-CALAMARI/OCR-D-OCR-CALAMARI_00000024.xml
2020-02-21 13:21:06 +01:00
~~~
2020-10-28 17:20:47 +01:00
The example workflow also produces OCR evaluation reports using
2020-02-21 13:21:06 +01:00
[dinglehopper ](https://github.com/qurator-spk/dinglehopper ), if ground truth was
2020-02-21 16:54:10 +01:00
available:
2020-02-21 13:21:06 +01:00
~~~
firefox OCR-D-OCR-CALAMARI-EVAL/OCR-D-OCR-CALAMARI-EVAL_00000024.html
~~~
2020-05-22 17:23:49 +02:00
ppn2ocr
-------
2020-10-09 16:45:44 +02:00
The `ppn2ocr` script produces a workspace and METS file with the best images for
a given document in the State Library Berlin (SBB)'s digitized collection.
2020-09-03 17:55:58 +02:00
2020-09-03 18:01:20 +02:00
Install it with an up-to-date pip (otherwise this will fail due to [a opencv-python-headless build failure ](https://github.com/skvark/opencv-python#frequently-asked-questions )):
2020-05-22 17:23:49 +02:00
~~~
2020-10-28 19:05:32 +01:00
pip install -r ~/devel/ocrd-galley/requirements-ppn2ocr.txt
2020-09-03 17:55:58 +02:00
~~~
The document must be specified by its PPN, for example:
~~~
2020-10-28 19:05:32 +01:00
~/devel/ocrd-galley/ppn2ocr PPN77164308X
2020-06-03 11:17:18 +02:00
cd PPN77164308X
2020-10-28 19:05:32 +01:00
~/devel/ocrd-galley/run-docker-hub -I BEST --skip-validation
2020-05-22 17:23:49 +02:00
~~~
This produces a workspace directory `PPN77164308X` with the OCR results in it;
the results are viewable as explained above.
2020-10-09 16:45:44 +02:00
ppn2ocr requires properly set up environment variables for the proxy
configuration. At SBB, please read `howto/docker-proxy.md` and
`howto/proxy-settings-for-shell+python.md` (in qurator's mono-repo).
ocrd-workspace-from-images
--------------------------
The `ocrd-workspace-from-images` script produces a OCR-D workspace (incl. METS)
for the given images.
~~~
2020-10-28 19:05:32 +01:00
~/devel/ocrd-galley/ocrd-workspace-from-images 0005.png
2020-10-09 16:55:33 +02:00
cd workspace-xxxxx # output by the last command
2020-10-28 19:05:32 +01:00
~/devel/ocrd-galley/run-docker-hub
2020-10-09 16:45:44 +02:00
~~~
This produces a workspace from the files and then runs the OCR workflow on it.