A yolov9 instance segmentation model for segmenting text-regions in handwritten running-text documents
This model was developed for segmenting text-regions in handwritten running-text documents. It is meant to be implemented in an HTR-pipeline
where one first segment text-regions, then text-lines within the regions, and then feed these text-lines to an HTR-model.
As part of an HTR-pipeline for transcribing entire pages of handwritten running-text documents. See
Swedish Lion Libre
for example usage with the
HTRflow package
Below is the Python code to load and use the trained YOLOv9 instance segmentation model using the Ultralytics repo:
1import torch
2from ultralytics import YOLO
3
4# Load the trained YOLOv9 model
5model = YOLO('path/to/your/model.pt') # Update with the correct path to your trained model
6
7# Load an image
8img = 'path/to/your/image.jpg' # Update with the path to the image you want to use
9
10# Perform instance segmentation
11results = model(img)
12
13# Display results
14results.show() # Show image with predicted masks
15
16# To get the raw predictions (bounding boxes, masks, etc.)
17for result in results:
18 print(result.boxes) # Bounding boxes
19 print(result.masks) # Segmentation masks
See the model card for
Swedish Lion Libre
for example usage with the
HTRflow package, or refer to the documentation for
HTRflow
Standard metrics for instance segmentation. Note that evaluation of segmentation as part of an HTR-pipeline should be measured by what effect it
has on the following HTR, that is, CER and WER. For implementation and evaluation of entire HTR-pipelines, please check out
HTRflow,
the Swedish National Archive's open-source package for HTR and OCR projects.