2023-03-23

Editing the layout in Transkribus


Transkribus
 is an AI-powered platform for automatic text recognition and transcription of historical (usually handwritten) documents.

Most Transkribus users probably do the automatic layout analysis and text recognition in one step or even upload, layout and text recognition all in one step.

However, you may have issues with the layout analysis, for example putting lines in the wrong order, breaking lines in the middle, or inventing non-existing lines. This is especially true of text in tables, where the columns are usually processed before the rows, contrary to what is usually desired.

That's why I routinely do the upload, layout analysis and text recognition in three separate steps and optimize the layout created by Transkribus manually before doing the automatic text recognition.

I use the web-based Transkribus App (also called Transkribus Lite) rather than Transkribus Expert (the standalone version that you install on your PC), which is no longer being further developed.

Transkribus changes the user interface often in their attempts to improve it, but that means parts of the following guide may become obsolete quickly. However, the main principles will no doubt be valid for some time.

Log in to Transkribus App.

Do not click "Text Recognition" in the menu on the left or "Select files" under "Quick Text Recognition" on the right.

Instead, choose "Upload" in the menu on the left.Choose "Image" or "PDF", then upload one or more files from your PC's file system.


Once you have uploaded the file(s), go to the overview of the page(s) in the document, but do not go to an individual page. You should see miniature views of the page(s) that you just uploaded. You will see checkboxes with the word "Select" to the lower left of the miniature views of the pages.


Click the checkbox of the first page you want to do the layout analysis for. The grayed out menu items on the left now become activated. Do not choose "Text Recognition".


Instead, choose "Layout Recognition".

At the time of this writing, you now have a choice among ""Printed Block Detection", "Preset Model", and "Choose Model", but this may change.

Choose "Preset Model" and click "Start".

As of this writing, a window now appears explaining what is currently being changed with the layout analysis models. Click "Start" again.


Close any open windows. Click "Jobs" in the menu on the left. Wait for the automatic layout analysis of the first job to finish.


When it is finished click on the document link in the column "Action".

Click on the miniature view of the page you just did the automatic layout analysis for.

At the time of this writing, a window explaining the new document editor is displayed. Close this window.

The layout of the page consists mainly of regions that contain lines that contain points.


The "Info" icon shows you a cheat sheet on how to edit the layout. Read this.

First check to see if the regions are OK. Often any text written in the margin is included in the same region as the main text and the lines may even run into each other.


So you need to create a new region for the text in the margin. Click the "Add Region" icon on the left. Define the new region by clicking on one corner with the mouse, then click on the opposite corner with the mouse.

If lines run into each other, you need to split the line. Mark the line by clicking on it with the mouse. Then hit the "V" key (for "vertical split"). While holding the "V" key move the mouse cursor till the vertical line is where you want to split the text line. Then tap the left mouse button.

Now mark the line that needs to go into the new region. Hit the line you marked with the right mouse button. A context-sensitive menu will open. Choose "Assign to new region"; then choose the new region with the mouse. Repeat with any other lines that need move to the new region because this does not automatically happen when you create the new region.

To split a region, mark the region with the mouse, hit the "H" key (for "horizontal split") then move the mouse cursor to where you want the split, and hit the left mouse button. You can also split a region vertically with the "V" key, but that is more seldom.

To delete a region, mark it with the mouse, then hit the "Del" key.

To combine regions, mark the first region with the mouse, then hit the "Ctrl" key, and mark the second region with the mouse. Then hit the "M" key (for "merge").

To redefine the size of a region, drag the corners of it with the mouse.


Save your work by hitting the "Save" icon near the top right (a diskette symbol) to . Do this often.


Now check the lines. For this part it is extremely helpful to see the line numbers in the image in the left-hand panel (not just in the right-hand panel). Click the "Configure" icon on the extreme bottom right. Click the "Layout" tab. Click "Show reading order". Close the window. Now you will see little numbers indicating the order of the regions and the order of the lines within the regions.

Click on the first line in the first region in the image. The corresponding line in the right-hand panel will also be marked, and vice versa. To move from one line to the next in the image, hit the "Ctrl" key. To move from one line to the next in the right-hand panel hit the down arrow key.


To add a line, hit the "Add Line" icon, click the left mouse button at the beginning of the line, and double-click the mouse button to end the line. If the line is jagged or curved, you can add points on the line with a click of the mouse button anywhere in between before double-clicking at the end.


To reorder lines, mark one of them, then hit the "Layout" icon on the left. Then drag the currently marked line to where it belongs with the mouse. Unfortunately the lines in this window are not numbered, so it can be confusing.

Splitting lines is explained above when explaining how to add a region.

To merge lines, mark the first one with the mouse, then hold the "Ctrl" key and mark the second one with the mouse, and hit the "M" key (for "merge").


To extend a line to the left or right, mark it with the mouse, then drag the first or last point to the left or right.

When you have finished editing the layout, don't forget to save your work.

If the layout is so wrong that optimizing it is too cumbersome, you can delete all the regions and all the lines, then add the regions and lines manually as described above. Or don't do the automatic layout analysis at all, and add the regions and lines manually.

Up to this point, no credits have been used.


Now you can do the text recognition by clicking the "Recognition" icon near the bottom left. This is when a credit is deducted.

2 comments: