Swedish Lion OCR
A yolo26 instance segmentation model for segmenting text-lines. To be used directly on full page-images as part of an HTR-pipeline
Model Details
class_labels="textline"
Model Description
- Developed by: The Swedish National Archives
- Model type: Yolo26s
- Segmentation of: Text-lines in Historical handwritten text
- License: cc-by-4.0
This model was developed for segmenting text-lines in handwritten running-text documents. It is meant to be implemented in an HTR-pipeline where one first segment text-lines and then feed these text-lines to an HTR-model.
Version History
v1.0.0 (2026-09-28)
- Initial release
Uses
Segment text-lines as part of an HTR-pipeline for handwritten running-text documents
Can be used downstream 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
How to Get Started with the Model
Below is the Python code to load and use the trained YOLO26 instance segmentation model using the Ultralytics repo:
import torch
from ultralytics import YOLO
# Load the trained YOLOv9 model
model = YOLO('path/to/your/model.pt') # Update with the correct path to your trained model
# Load an image
img = 'path/to/your/image.jpg' # Update with the path to the image you want to use
# Perform instance segmentation
results = model(img)
# Display results
results.show() # Show image with predicted masks
# To get the raw predictions (bounding boxes, masks, etc.)
for result in results:
print(result.boxes) # Bounding boxes
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
Training Details
Training Data
The model is trained using a line-annotated dataset of 31 000 pages (~1.7M lines) of historical Swedish handwriting compiled by the National Archives of Sweden, the Stockholm City Archives, the National Archives of Finland and Jämtlands läns fornskriftssällskap.
Training Hyperparameters
See config.json and args.yaml
Evaluation
See training-results
Citation
@online{swedish_lion_2026,
author = {{The Swedish National Archives}},
title = {Swedish Lion},
year = {2026},
version = {v1.0.0},
publisher = {Hugging Face},
doi = {KLISTRA_IN_DOI},
url = {https://huggingface.co/Riksarkivet/yolo26s-handwritten-lines-2},
note = {Model version v1.0.0 (Git tag: v1.0.0)}
}
Software
Model Architecture
See config.json.