Command line utility for generating hOCR files from an Islandora site. Segmentation is run via kraken and text recognition via TrOCR.
NOTE: This is alpha software and has not yet exposed all configuration options to the command line interface. At the moment it runs on a custom-trained YOLO26 OBB model (packaged as part of the software) and a version of TrOCR trained via transfer learning on 18th century handwritten English text.
This software has only been tested on native Linux (Ubuntu) and WSL. We presume that native Windows is not suppoted. Furthermore, it assumes you have access to a GPU. Usage on CPU is untested.
Clone the repo:
git clone git@github.com:AmericanPhilosophicalSociety/portal-htr.git
cd portal-htr
Install into a virtual environment with pip:
python3 -m venv .venv
source .venv/bin/activate
pip install . -e
Create an environment file and indicate your local variables by editing the file:
cp .env_example .env
If your Islandora site does not have the views needed for the script to work, you will need to create these as well.
This script is invoked through the command ocr. There are two valid ways of running it: first, you can supply Drupal nodes as arguments. Second, you can provide a file that contains a list of nodes. These options are mutually exclusive.
You can pass as many files as you would like at one time.
ocr 12345 23456 34567
ocr -f nodes.lst
nodes.lst should look like this:
12345
23456
34567