/ Модель

Характеристики

Контекст
512 токенов
Лицензия
Apache 2.0
Архитектура
vision-encoder-decoder · dense
Базовая модель
trocr-base-handwritten
Библиотека
htrflow
Опубликована
15 авг 2024

trocr-base-handwritten-hist-swe-2

Описание изображенийИзображение → текст3 профессии

Модель TrOCR для распознавания рукописных строк на шведском языке в исторических документах XVII–XIX веков.

205 тыс.скачиваний за 30 дней18лайковвеса обновлены4 июн 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Распознавание текста» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Swedish Lion Libre — модель распознавания рукописного текста, разработанная Национальным архивом Швеции совместно с Городским архивом Стокгольма, Национальным архивом Финляндии и Jämtlands Fornskriftsällskap. Это дообученная модель TrOCR base handwritten с архитектурой vision-encoder-decoder, предназначенная для транскрибации отдельных строк на изображениях.

Сценарии применения

  • транскрибация строк из шведских архивных документов 1600–1900 годов
  • распознавание рукописей в судебных книгах и протоколах
  • оцифровка исторических писем и журналов
  • подготовка расшифровок для поиска по архивным коллекциям
  • дообучение на конкретной коллекции исторических шведских рукописей

Ограничения

Модель рассчитана на отдельные строки рукописного шведского текста 1600–1900 годов и требует предварительной сегментации документа на строки. Без дообучения она хуже работает с другими языками и печатным текстом; качество зависит от соответствия почерка и материала обучающему домену.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Swedish Lion Libre

An HTR model for historical Swedish developed by the Swedish National Archives in collaboration with the Stockholm City Archives, the Finnish National Archives and Jämtlands Fornskriftsällskap. The model is trained on Swedish handwriting from the period 1600-1900.

Model Details

Model Description

  • Developed by: The Swedish National Archives
  • Model type: TrOCR base handwritten
  • Language(s) (NLP): Historical Swedish handwriting
  • License: apache-2.0
  • Finetuned from model: trocr-base-handwritten

Uses

The model is trained on Swedish running-text handwriting dating from the start of the 17th century to the end of the 19th century. Like most current HTR models it operates on a text-line level, so its intended use is within an HTR pipeline that segments the text into text lines, which are transcribed by the model.

Direct Use

The model can be used without fine-tuning on all handwriting but performs best on the type of handwriting it was trained on, which is Swedish handwriting from 1600-1900. See below for detailed test and evaluation results.

Downstream Use

The model can be fine-tuned on other types of handwriting, or if you plan to use it to transcribe some specific material that is within it's domain but not included in the training data, for instance if you got a large letter collection dating from the 17th century, it can be fine-tuned on a small amount of manually transcribed in-domain data, say 20-50 letters, and then used to transcribe the entire collection.

Out-of-Scope Use

The model won't work well out-of-the-box for other languages than Swedish, and it won't work well for printed text.

How to Get Started with the Model

Use the code below to get started with the model, but bear in mind that the image has to be a single text line.

from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests

img_path = 'path/to/image'
image = Image.open(img_path)

processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
model = VisionEncoderDecoderModel.from_pretrained('Riksarkivet/trocr-base-handwritten-hist-swe-2')
pixel_values = processor(images=image, return_tensors="pt").pixel_values

generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]

If you want to transcribe entire pages, consider using HTRflow, a package developed by the Swedish National Archives and intended for streamlining large and small scale HTR/OCR-projects. Install the package, write a pipeline config yaml, where you specify the models to use by their huggingface id, add preprocessing or post-processing steps, and then run the pipeline with htrflow pipeline <path/to/yaml> <path/to/image>. A .yaml file for an entire pipeline, transcribing full pages, could look like this:


# Demo pipeline for running text

steps:

# Region segmentation
- step: Segmentation
  settings:
    model: yolo
    model_settings:
       model: Riksarkivet/yolov9-regions-1
    generation_settings:
       conf: 0.3
       batch_size: 32

# Line segmentation
- step: Segmentation
  settings:
    model: yolo
    model_settings:
       model: Riksarkivet/yolov9-lines-within-regions-1
    generation_settings:
       conf: 0.3
       batch_size: 16

- step: TextRecognition
  settings:
    model: WordLevelTrocr
    model_settings:
       model: Riksarkivet/trocr-base-handwritten-hist-swe-2
    generation_settings:
       batch_size: 16
       num_beams: 1

- step: ReadingOrderMarginalia
  settings:
    two_page: always

# Export to Alto and Page XML 
- step: Export
  settings:
    dest: outputs/alto
    format: alto

- step: Export
  settings:
    dest: outputs/page
    format: page

See the documentation for the HTRflow package for further instructions on specific steps and customizations.

Training Details

Training Data

We cannot publically release all data the model was trained on, since we ourselves haven't created all the data, but below are links to the datasets we can release publically:

Göteborgs poliskammare 1850-1900
Krigshovrättens domböcker
Svea hovrätt
Bergskollegium
Frihetstidens utskottshandlingar
Carl-Fredrik Påhlmans resejournaler
Trolldomskommissionen
Göta hovrätt
Bergmästaren i Nora
Älvsborgs lösen
Jönköpings rådhusrätt magistrat

Training Procedure

Preprocessing

The text line polygons were masked out and placed against a white background, with dimensions decided by the polygon's bounding box.

Training Hyperparameters

See config.json.

  • training regime: bf16
  • learning rate: 5e-5
  • weight decay: 0.01

Evaluation

In-Domain Evaluation Data (Sorted by CER)

These are the character and word error rates on evaluation data taken from the same archives that was included in the training set. The evaluation samples are not part of the training data. The number of samples included in the training set give an indication of how the model improves by fine-tuning it on some specific material within the model's range.

DatasetWERCERTrain LinesEval Lines
krigshovrattens_dombocker_lines0.03300.007516,8871,877
stockholms_stadsarkiv_allmana_barnhuset_1700_lines0.06470.0120565142
stockholms_stadsarkiv_blandat_2_1700_lines0.08070.017025,0242,781
goteborgs_poliskammare_fore_1900_lines0.08000.0187339,29717,858
stockholms_stadsarkiv_stockholms_domkapitel_1700_lines0.09480.018796,4095,075
stockholms_stadsarkiv_politikollegiet_1700_lines0.11080.0225120,2386,329
bergskollegium_relationer_och_skrivelser_lines0.10560.025362,2016,912
stockholms_stadsarkiv_stadens_kamnarsratt_1700_lines0.12520.027838,3304,259
svea_hovratt_lines0.14840.031336,8844,099
stockholms_stadsarkiv_stockholms_domkapitel_1800_lines0.14000.03242,070230
stockholms_stadsarkiv_handelskollegiet_1600_1700_lines0.17850.03509,2011,023
frihetstidens_utskottshandlingar_lines0.14810.036213,4901,499
stockholms_stadsarkiv_kungliga_hovkonsistoriet_1700_lines0.15410.03645,753640
national_archives_finland_court_records_lines0.16070.0368147,4567,761
stockholms_stadsarkiv_blandat_1600_1700_lines0.15050.037916,1371,794
stockholms_stadsarkiv_blandat_3_1600_lines0.16330.040043,1424,794
stockholms_stadsarkiv_norra_forstadens_kamnarsratt_1600_1700_lines0.17550.046318,4742,053
carl_fredrik_pahlmans_resejournaler_lines0.17680.04827,081787
stockholms_stadsarkiv_sollentuna_haradsratt_1700_1800_lines0.19210.050519,0962,122
stockholms_stadsarkiv_byggningskollegium_1600_lines0.22620.05143,104345
ra_enstaka_sidor_lines0.19910.05385,078565
trolldomskommissionen_lines0.23210.060033,4983,722
stockholms_stadsarkiv_stockholms_domkapitel_1600_lines0.21700.060711,6191,292
stockholms_stadsarkiv_botkyrka_kyrkoarkiv_1600_1800_lines0.25480.06273,617402
gota_hovratt_lines0.24500.06302,421269
bergmastaren_i_nora_htr_lines0.25580.07097,916880
bergskollegium_advokatfiskalkontoret_lines0.29060.07222,411268
jl_fornsallskap_jamtlands_domsaga_lines0.25850.073260,5446,728
alvsborgs_losen_lines0.18960.08065,632626
jonkopings_radhusratt_och_magistrat_lines0.28640.08531,179131
national_archives_finland_letters_recipes_lines0.38570.1360651163

Testing Data

Out-of-Domain Test Data (Sorted by CER)

These are the model's CER and WER on the eval_htr_out_of_domain_lines evaluation set, which contains lines from archives that were not at all included in the training data. So these are the results one would expect if one uses this model out-of-the-box on just any running text document within the model's time span.

DatasetWERCEREval Lines
1792_R0002231_eval_lines0.11900.0250501
1794-1795_A0068546_eval_lines0.15030.0303510
1775-1786_A0068551_eval_lines0.22030.0543525
1841_Z0000017_eval_lines0.22470.0555470
1690_A0066756_eval_lines0.25710.0611249
1716_A0017151_eval_lines0.25170.0650558
1824_H0000743_eval_lines0.26840.0674260
1699-1700_C0113233_eval_lines0.27130.0691394
1845-1857_B0000011_eval_lines0.25460.0706153
1812_A0069332_eval_lines0.28680.079369
1659-1674_R0000568_eval_lines0.32780.0886304
1755-1756_C0112394_eval_lines0.34400.0918248
1723_H0000374_eval_lines0.31050.1140378
1887-1892_A0002409_eval_lines0.36700.1297784
1679_R0002397_eval_lines0.47680.142288
1800_C0101725_eval_lines0.44590.176737
1871_K0017448_eval_lines0.45040.1945331
1654_R0001308_eval_lines0.52000.2179199

Metrics

Character Error Rate (CER)

Character Error Rate (CER) is a metric used to evaluate the performance of a Handwritten Text Recognition (HTR) system by comparing the recognized text to the reference (ground truth) text at the character level.

The CER is calculated using the following formula:

$$ \text{CER} = \frac{S + D + I}{N} $$

Where:

  • S is the number of substitutions (incorrect characters)
  • D is the number of deletions (missing characters)
  • I is the number of insertions (extra characters)
  • N is the total number of characters in the reference text

A lower CER indicates better recognition accuracy.

Word Error Rate (WER)

Word Error Rate (WER) is a metric used to assess the accuracy of an HTR system at the word level by comparing the recognized text to the reference text.

The WER is calculated using the following formula:

$$ \text{WER} = \frac{S + D + I}{N} $$

Where:

  • S is the number of substitutions (incorrect words)
  • D is the number of deletions (missing words)
  • I is the number of insertions (extra words)
  • N is the total number of words in the reference text

Similar to CER, a lower WER indicates better word-level accuracy.

Technical Specifications

Model Architecture

See config.json.

More details can be found in the original TrOCR paper.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · htrflow

Можно запустить

Подбираем GPU…

Класс архитектуры
VisionEncoderDecoderModel
Ревизия весов
aa79fcb

0 моделей