TheoMoins commited on
Commit
20bd3f1
·
verified ·
1 Parent(s): e74de74

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +227 -3
README.md CHANGED
@@ -1,3 +1,227 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ datasets:
4
+ - CATMuS/medieval
5
+ - magistermilitum/Tridis
6
+ metrics:
7
+ - cer
8
+ - wer
9
+ pipeline_tag: image-to-text
10
+ tags:
11
+ - htr
12
+ - handwritten-text-recognition
13
+ - manuscripts
14
+ - medieval
15
+ - vision-language-model
16
+ - catmus
17
+ - qwen
18
+ ---
19
+
20
+ # MEDUSA 0.1 — Medieval European Documents Unified System for Automated text recognition
21
+
22
+ MEDUSA is a family of Vision Language Models (VLMs) fine-tuned for **multilingual medieval handwritten text recognition (HTR)** at the **line level**.
23
+ These models were developed at the [École nationale des chartes – PSL](https://www.chartes.psl.eu/) and submitted
24
+ to the [ICDAR 2026 Competition on Multilingual Medieval Handwritten Text Recognition (CMMHWR)](https://cmmhwr26.inria.fr/).
25
+
26
+ This repository contains two model variants:
27
+
28
+ | Model | Base | Version | Notes |
29
+ |---|---|---|---|
30
+ | `MEDUSA-4B-0.1` | Qwen3.5-4B | 0.1 | Model used at competition submission |
31
+ | `MEDUSA-9B-0.1` | Qwen3.5-9B | 0.1 | Best model at competition submission |
32
+ | `MEDUSA-4B-0.2` | Qwen3.5-4B | 0.2 | Improved post-competition iteration |
33
+ | `MEDUSA-9B-0.2` | Qwen3.5-9B | 0.2 | Improved post-competition iteration |
34
+
35
+ > **Note on versioning.** The `0.1` variants correspond exactly to the models evaluated in the ICDAR 2026 competition.
36
+ > The `0.2` variants incorporate additional training iterations and yield slightly better results.
37
+ > We release both to ensure full reproducibility of competition results.
38
+
39
+ ---
40
+
41
+ ## System report
42
+
43
+ For full details on data, training procedure, and results, see the [accompanying system report](https://enc.hal.science/hal-05600991).
44
+
45
+ ---
46
+
47
+ ## Languages and scripts
48
+
49
+ MEDUSA was trained on a corpus of over **640,000 lines** spanning more than twenty repositories, covering the following language families and scripts:
50
+
51
+ - **Romance / Latin**: Old French (`fro`), Occitan (`pro`), Old Italian (`ita`), Old Spanish (`osp`), Catalan (`cat`), Old Portuguese (`opor`), Navarrese (`nav`), Latin (`lat`), Venetian (`vec`), Galician (`glg`)
52
+ - **Germanic**: Middle High German (`gmh`), Middle Low German (`gml`), Old Icelandic (`ice`), Middle English (`enm`), Middle Dutch (`dum`), Old English (`ang`), Old Norwegian (`non`), Swedish (`swe`)
53
+ - **Celtic**: Welsh (`wlm`), Old Irish (`gle`)
54
+ - **Slavic**: Old Czech (`cze`), Old Polish (`pol`)
55
+
56
+ Mnuscripts dated roughly from the 9th to the 15th century.
57
+
58
+ ---
59
+
60
+ ## Results (ICDAR 2026 CMMHWR)
61
+
62
+ Unweighted average CER (%) and WER (%) on internal and official competition test sets. Lower is better.
63
+
64
+ | Model | Internal CER | Internal WER | Task 1 CER | Task 2 CER | Task 3 CER |
65
+ |---|---|---|---|---|---|
66
+ | kraken-CATMuS 1.6.0 *(baseline)* | 17.3 | 53.5 | 9.29 | 7.91 | 25.9 |
67
+ | **MEDUSA-4B 0.1** | **14.7** | **44.5** | 8.15 | 5.60 | 12.0 |
68
+ | **MEDUSA-9B 0.1** | **13.2** | **42.6** | 8.03 | **5.24** | **10.8** |
69
+
70
+ ---
71
+
72
+ ## Intended use
73
+
74
+ These models are designed for **line-level HTR** on pre-segmented medieval manuscript images.
75
+ They are **not** page-level OCR systems: they expect a cropped image of a single text line as input and return the transcription of that line.
76
+
77
+ The models target **CATMuS transcription guidelines**, which govern abbreviation expansion, allograph normalisation, and the character set used.
78
+
79
+ ---
80
+
81
+ ## Usage with DocWorkflow
82
+
83
+ The recommended way to use MEDUSA is via **[DocWorkflow](https://github.com/Enceintes-Chartes/docworkflow)**,
84
+ the document analysis framework developed at the École nationale des chartes.
85
+ DocWorkflow handles ALTO XML input/output, line image extraction, batching, CATMuS post-processing, and scoring in a unified pipeline.
86
+
87
+ ### Installation
88
+
89
+ ```bash
90
+ git clone https://github.com/TheoMoins/DocWorkflow
91
+ cd docworkflow
92
+ pip install -e .
93
+ ```
94
+
95
+ ### Configuration file
96
+
97
+ Create a YAML config file (e.g., `medusa_inference.yml`):
98
+
99
+ ```yaml
100
+ run_name: "Medusa0.1Line-9B"
101
+ output_dir: "results"
102
+ device: "cuda"
103
+ save_image: true
104
+
105
+ data:
106
+ test: "path/to/your/alto/data" # directory with ALTO XML + image pairs
107
+
108
+ tasks:
109
+ htr:
110
+ type: VLMLineHTR
111
+ config:
112
+ use_metadata: true
113
+ model_name: 'outputs/Medusa0.1Line-9B'
114
+ device_map: "auto"
115
+ max_new_tokens: 128
116
+ line_batch_size: 8
117
+ max_pixels: 401408
118
+
119
+ prompt: >
120
+ Transcribe the handwritten text in this line image.
121
+ Keep abbreviations as written, do not expand them.
122
+ Modernize word segmentation (split or join words following modern usage).
123
+ Use only u and i, never v and j, regardless of the original or modern usage.
124
+ Do not record allographic variants, use standard letter forms.
125
+ Output ONLY the transcription.
126
+
127
+ ```
128
+
129
+ > **Tip.** If your dataset follows dataset-specific transcription conventions, you can provide a `conventions.yml` file alongside your ALTO data.
130
+ > DocWorkflow will automatically inject the conventions into the prompt via a `{conventions}` placeholder.
131
+
132
+ ### Running inference
133
+
134
+ ```bash
135
+ docworkflow -c Medusa0.1Line-9B.yml predict -t htr -d test
136
+ ```
137
+
138
+ ## Direct usage with `transformers`
139
+
140
+ The models can also be used directly outside of DocWorkflow, though the CATMuS post-processing step will need to be applied manually if desired.
141
+
142
+ ```python
143
+ from transformers import AutoProcessor, AutoModelForImageTextToText
144
+ from PIL import Image
145
+
146
+ model_id = "ENC-PSL/Medusa0.1Line-9B"
147
+
148
+ processor = AutoProcessor.from_pretrained(model_id)
149
+ model = AutoModelForImageTextToText.from_pretrained(model_id, device_map="auto")
150
+
151
+ image = Image.open("path/to/line_image.jpg").convert("RGB")
152
+
153
+ prompt = "Transcribe the handwritten text in this line image.\nOutput ONLY the transcription."
154
+
155
+ messages = [
156
+ {
157
+ "role": "user",
158
+ "content": [
159
+ {"type": "text", "text": prompt},
160
+ {"type": "image", "image": image},
161
+ ],
162
+ }
163
+ ]
164
+
165
+ inputs = processor.apply_chat_template(
166
+ [messages],
167
+ tokenize=True,
168
+ add_generation_prompt=True,
169
+ return_dict=True,
170
+ enable_thinking=False,
171
+ return_tensors="pt",
172
+ ).to(model.device)
173
+
174
+ with torch.no_grad():
175
+ generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
176
+
177
+ trimmed = generated_ids[0][inputs["input_ids"].shape[1]:]
178
+ transcription = processor.decode(trimmed, skip_special_tokens=True).strip()
179
+ print(transcription)
180
+ ```
181
+
182
+ > **Important.** The model is optimised for the prompt given above. Results may degrade if the prompt is modified.
183
+ > The model outputs raw text; to enforce CATMuS compliance (character whitelist, allograph normalisation),
184
+ > apply the post-processing step provided in DocWorkflow (`src/tasks/htr/postprocessing.py`).
185
+
186
+ ---
187
+
188
+ ## CATMuS conventions
189
+
190
+ Transcriptions follow the [CATMuS guidelines](https://catmus-guidelines.github.io/).
191
+
192
+ ---
193
+
194
+ ## Citation
195
+
196
+ If you use MEDUSA in your research, please cite:
197
+
198
+ ```bibtex
199
+ @unpublished{moins:hal-05600991,
200
+ TITLE = {{MEDUSA 0.1: Medieval European Documents Unified System for Automated text recognition System Report for the ICDAR 2026 Competition on Multilingual Medieval Handwritten Text Recognition}},
201
+ AUTHOR = {Moins, Th{\'e}o and Cafiero, Florian and Camps, Jean-Baptiste and Conte, Lilla and Guidi, Emilie and Hensley, Brenna and Kapitan, Katarzyna and Macedo, Carolina and Peratello, Paola and Vermaas, Cecile and Vidal-Gor{\`e}ne, Chahan},
202
+ URL = {https://enc.hal.science/hal-05600991},
203
+ NOTE = {working paper or preprint},
204
+ YEAR = {2026},
205
+ MONTH = Apr,
206
+ PDF = {https://enc.hal.science/hal-05600991v1/file/MEDUSA__MEDieval_Universal_Script_Analysis-6.pdf},
207
+ HAL_ID = {hal-05600991},
208
+ HAL_VERSION = {v1},
209
+ }
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Funding
215
+
216
+ Funded by the European Union (ERC, LostMA, 101117408). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the
217
+ European Research Council. Neither the European Union nor the granting authority can be held responsible for them.
218
+
219
+ This work has received support under the Major Research Program of PSL Research University ``CultureLab'' launched by PSL Research University and implemented by ANR with the references ANR-10-IDEX-0001.
220
+
221
+ Ce travail a bénéficié d'une aide de l’État gérée par l'Agence Nationale de la Recherche au titre de France 2030 portant la référence « ANR-23-IACL-0008»).
222
+
223
+ Biblissima+ bénéficie d’une aide de l'Etat gérée par l'ANR au titre du Programme d’investissements d’avenir intégré à France 2030, portant la référence ANR-21-ESRE-0005.
224
+
225
+ This work was granted access to the HPC resources of IDRIS
226
+ under the allocation 2026-AD011015914R1 made by GENCI.
227
+