Ressources numériques en sciences humaines et sociales OpenEdition Nos plateformes OpenEdition Books OpenEdition Journals Hypothèses Calenda Bibliothèques OpenEdition Freemium Suivez-nous

Switching from Transkribus to eScriptorium with Aspyre

Warning: the pipeline described below is no longer necessary to transfer data from Transkribus to eScriptorium. It is indeed preferrable to use PAGE XML, which is immediately compatible with eScriptorium. See our tutorial.

 

 

eScriptorium is a transcription platform currently being developed by SCRIPTA PSL. It provides Kraken with a GUI and an API, increasing the accessibility of this OCR software and broadening its functionalities1. Both eScriptorium and Kraken are free and open source, and so are the models created with them. This is important because it means that when using eScriptorium and/or Kraken you can save your model as a file and share it with whoever you want, however you want. This makes the effort put into creating the ground-truth all the more worthwhile2!

Additionally, Kraken produces two types of models:

  1. Segmenters which detect lines of text on an image; and
  2. Recognizers which transcribe these lines. 

Both types of models can be trained with your own data on the eScriptorium platform. Therefore, if your documents’ layout is too specific to be properly handled by a generic model, you can create one from scratch or finetune the default generic model in order for it to fit your own needs and objectives. In other words, compared to a platform like Transkribus, eScriptorium gives you more flexibility and more freedom to build your own models for the detection of the layout and the transcription of your documents. 

If you have started your project using Transkribus and wish to transfer your data to eScriptorium, it is possible. To address the complexities encountered and bridge the gap between these two platforms, we developed Aspyre, an easy-to-use solution leveraging ALTO XML as a hub.

This article is not a tutorial on how to use eScriptorium or Transkribus: rather, it is intended to be extended documentation on what to expect from and how to use Aspyre.

LectAuRep, a case example

Back in 2018, during an exploratory phase of the LectAuRep project which aimed at determining whether it was possible to automatically transcribe our documents3, we evaluated the performance of several transcription tools, including Transkribus and Kraken. 

A major issue we encountered was that of detecting the text on the documents and reproducing the table-like layout. We soon realized that the quality of segmentation weighs a lot in the quality of transcription. We were successful at training an acceptable transcription model in Transkribus4, but would spend too much time manually rendering the layout on this platform. 

It became necessary to find another solution to automatically detect the segments and Kraken and eScriptorium offered promising perspectives. 

As a result, we switched to Kraken while in the meantime leaving the data produced during phase 1 on Transkribus. Recently, we decided to retrieve the transcriptions created with Transkribus and transfer them to eScriptorium. Our intentions were to compare, given an identical dataset, the transcription performances of Kraken and Transkribus. Ideally, we also wanted to add the ground truth created during phase 1 to the rest of the data generated with eScriptorium.

Transferring the data from Transkribus to eScriptorium turned out to be more complicated than just exporting data from Transkribus and importing them to eScriptorium. A few changes needed to be made in the documents exported from Transkribus: we developed Aspyre to execute these modifications.

Okay, so what about Aspyre?

Aspyre is a Python library that will help import into eScriptorium data you exported from Transkribus. Because you may want to use Aspyre quickly without having to worry about a local installation, we also provide Aspyre as a service online (GUI) on a demo server5. We even created a ready-to-use script to run Aspyre as a CLI.

Aspyre uses ALTO XML because this standard is processed by both Transkribus and eScriptorium. However, by default the files produced by the former slightly differ from the files expected by the latter6. The three main issues are:

  1. Transkribus’ exports follow the ALTO 2 schema specifications, while eScriptorium is based on ALTO 4;
  2. Transkribus does not refer to the image associated with a transcription whereas eScriptorium relies on it to dynamically pair a transcription and the corresponding image;
  3. Transkribus exports only refer to a baseline coordinate from the y axis (“At which height on the image do we find the baseline?”) whereas eScriptorium will produce a baseline based on at least two x-y coordinates. 

To summarize Aspyre’s actions: it takes an archive exported from Transkribus and re-composes the information needed by eScriptorium. It injects the reference to the source image matched by the transcription and transforms the ALTO XML tree to conform to the correct schema specifications on top of fixing how baselines are specified. 

Using Aspyre: a walkthrough

The steps to run your data through Aspyre are fairly simple.

  1. Export your data in the “Transkribus Document” format, checking the “Export ALTO” and “Export Image” options (see screenshot below). You will now have a ZIP file.
  2. If you use Aspyre as a GUI, you need to keep your ZIP file under 500 MB. Conveniently, Aspyre does not need the images to run7 so you can eliminate them from the archive following your preferred method8
  3. Run Aspyre on your data from the CLI or upload the archive on Aspyre GUI following the documentation provided with each tool. You will obtain a new ZIP file containing modified ALTO XML files.
  4. After uploading your images on eScriptorium, import the transcriptions using the “Import Transcription” option and select the new ZIP file.
Minimal configuration of the exports on Transkribus: check "Transkribus Document" and then "Export ALTO" and "Export Image".
Minimal configuration of the exports on Transkribus.

Dissecting Aspyre

Aspyre was developed as a library (aspyrelib), so you can add it to your own pipeline and call its main function (aspyrelib.main()). 

To run properly, Aspyre will take a directory with an architecture similar to the ones you can extract from Transkribus: at minimum, it shall contain a file named “mets.xml” and a directory named “alto/” containing ALTO XML files. The file “mets.xml” must contain a node such as “<ns3:fileGrp ID=”IMG”>” referring to image files, and a node such as “<ns3:fileGrp ID=”ALTO”>” referring to the ALTO XML files.

The ALTO XML file has a new schema declaration and includes a reference to the corresponding image after being processed by Aspyre.
The ALTO XML file has a new schema declaration and includes a reference to the corresponding image after being processed by Aspyre.

After Aspyre has listed the image files referred to in “mets.xml” and the XML files in the alto directory, each ALTO XML file is mapped with its corresponding source image. This is rendered by the creation of a “sourceImageInformation” node in the “Description” section of the ALTO XML file. 

The schema specifications are updated to ALTO 4 (currently an eScriptorium-flavored version9 ) and non-ALTO 4 elements are modified. Mainly, this results in “composedBlock” elements being removed, although their content is kept in the tree.

Additional modifications are made on the segment level. First, since complete baseline coordinates are key information for eScriptorium, Aspyre makes sure that they are properly expressed: it takes the unique value stored in the @BASELINE attributes  and extrapolates the correct coordinates based on the values associated with the corresponding @HPOS, @VPOS and @WIDTH attributes. @BASELINE attributes are then populated with the right coordinates. At the end of the process baseline coordinates are expressed as “xA yA xB yB” instead of “yA”. Unfortunately, for images where the text is crooked or tilted, this extrapolation may result in unsatisfying segments, forcing the user to later manually correct the imported segments. This aspect of the transformation will be improved in future developments.

After Aspyre is ran, BASELINE attributes refer to 4 x and y coordinates, calculated from the values in the original BASELINE, HPOS, VPOS and WIDTH.
After Aspyre is ran, BASELINE attributes refer to 4 x and y coordinates, calculated from the values in the original BASELINE, HPOS, VPOS and WIDTH.

Finally, since the ALTO 4 specifications used by eScriptorium currently differ slightly from the official schema, we want to point out that coordinates associated with the @BASELINE and @POINTS attributes must be expressed without any comma. The coordinates “xA,yA xB,yB” will thus become “xA yA xB yB”. This modification is handled by Aspyre as well and is easily reversed.

Commas are removed from the values of POINTS attributes, following eScriptorium's ALTO schema specifications.
Commas are removed from the values of POINTS attributes, following eScriptorium’s ALTO schema specifications.

Contribute!

The transformation scenario followed by Aspyre was tested against data produced in various contexts. However, your data and your practices may differ from ours. This can cause Aspyre to not exactly fit your needs or to somehow not be compatible with your data. Please, let us know if Aspyre has failed you! 

Aspyre is a work in progress and we would be happy to make updates so it is compatible with your data. Even if you have no idea why it didn’t work, we ask that you report the error by creating an issue on our development platform

Of course, you can also dig into the code yourself and find out what is causing the issue. In such cases, please, shoot us a pull request!

  1. For more information on eScriptorium and its functionalities, see https://escripta.hypotheses.org/ []
  2. For example, you can share your ground-truth via the HTR-United initiative:  https://htr-united.github.io/ []
  3. Digitized notary registers from Minutier Central’s collection at the Archives nationales. For more information on this collection, see http://www.archives-nationales.culture.gouv.fr/fr/web/guest/archives-des-notaires-de-paris  []
  4.  For more information on this phase, see Marie-Laurence Bonhomme. Répertoire des Notaires parisiens Segmentation automatique et reconnaissance d’écriture : Rapport exploratoire. Inria. 2018, pp.1-10. ⟨hal-01949198v2⟩. []
  5. Since this is a demo server, there is a limitation on the size of the files you can upload: 500 MB max! []
  6. Compare documents exported from each platform : https://github.com/alix-tz/aspyre-gt/tree/master/data/altos  []
  7. It only needs the mets.xml file to refer to them, this is the reason why you have to check “Export Image” in Transkribus. []
  8. You can use a software like 7-Zip or run this step from the command line. In any case, to remove the image from the archive, unzip it and rezip it keeping only the “alto” directory and the “mets.xml” file. []
  9. We believe this divergence from the official schema is only temporary and closely linked to future improvements in the ALTO 4 specifications.  []

OpenEdition vous propose de citer ce billet de la manière suivante :
alixchague (3 novembre 2020). Switching from Transkribus to eScriptorium with Aspyre. LECTAUREP. Consulté le 7 février 2025 à l’adresse https://doi.org/10.58079/qssg


Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.