wjbmattingly
commited on
Commit
•
cc83866
1
Parent(s):
110a8e7
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,83 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- es
|
5 |
+
datasets:
|
6 |
+
- CATMuS/medieval
|
7 |
+
tags:
|
8 |
+
- trocr
|
9 |
+
- image-to-text
|
10 |
+
widget:
|
11 |
+
- src: >-
|
12 |
+
https://huggingface.co/medieval-data/trocr-medieval-textualis/resolve/main/images/textualis-1.png
|
13 |
+
example_title: Hybrida 1
|
14 |
+
- src: >-
|
15 |
+
https://huggingface.co/medieval-data/trocr-medieval-textualis/resolve/main/images/textualis-2.png
|
16 |
+
example_title: Hybrida 2
|
17 |
+
- src: >-
|
18 |
+
https://huggingface.co/medieval-data/trocr-medieval-textualis/resolve/main/images/textualis-3.png
|
19 |
+
example_title: Hybrida 3
|
20 |
+
---
|
21 |
+
|
22 |
+
![logo](logo-hybrida.png)
|
23 |
+
|
24 |
+
# About
|
25 |
+
|
26 |
+
This is a TrOCR model for medieval Castilian, specifically the Hybrida script. The base model was [microsoft/trocr-base-handwritten](https://huggingface.co/microsoft/trocr-base-handwritten). The model was then finetuned to Caroline: [medieval-data/trocr-medieval-latin-caroline](https://huggingface.co/medieval-data/trocr-medieval-latin-caroline). From a saved checkpoint, the model was further finetuned to Textualis.
|
27 |
+
|
28 |
+
The dataset used for training was [CATMuS](https://huggingface.co/datasets/CATMuS/medieval).
|
29 |
+
|
30 |
+
The model has not been formally tested. Preliminary examination indicates that further finetuning is needed.
|
31 |
+
|
32 |
+
Finetuning was done with finetune.py found in this repository.
|
33 |
+
|
34 |
+
# Usage
|
35 |
+
|
36 |
+
```python
|
37 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
38 |
+
from PIL import Image
|
39 |
+
import requests
|
40 |
+
|
41 |
+
# load image from the IAM database
|
42 |
+
url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
|
43 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
44 |
+
|
45 |
+
processor = TrOCRProcessor.from_pretrained('medieval-data/trocr-medieval-castilian-hybrida')
|
46 |
+
model = VisionEncoderDecoderModel.from_pretrained('medieval-data/trocr-medieval-castilian-hybrida')
|
47 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
48 |
+
|
49 |
+
generated_ids = model.generate(pixel_values)
|
50 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
51 |
+
```
|
52 |
+
|
53 |
+
# BibTeX entry and citation info
|
54 |
+
|
55 |
+
## TrOCR Paper
|
56 |
+
|
57 |
+
```tex
|
58 |
+
@misc{li2021trocr,
|
59 |
+
title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
|
60 |
+
author={Minghao Li and Tengchao Lv and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
|
61 |
+
year={2021},
|
62 |
+
eprint={2109.10282},
|
63 |
+
archivePrefix={arXiv},
|
64 |
+
primaryClass={cs.CL}
|
65 |
+
}
|
66 |
+
```
|
67 |
+
|
68 |
+
## CATMuS Paper
|
69 |
+
|
70 |
+
```tex
|
71 |
+
@unpublished{clerice:hal-04453952,
|
72 |
+
TITLE = {{CATMuS Medieval: A multilingual large-scale cross-century dataset in Latin script for handwritten text recognition and beyond}},
|
73 |
+
AUTHOR = {Cl{\'e}rice, Thibault and Pinche, Ariane and Vlachou-Efstathiou, Malamatenia and Chagu{\'e}, Alix and Camps, Jean-Baptiste and Gille-Levenson, Matthias and Brisville-Fertin, Olivier and Fischer, Franz and Gervers, Michaels and Boutreux, Agn{\`e}s and Manton, Avery and Gabay, Simon and O'Connor, Patricia and Haverals, Wouter and Kestemont, Mike and Vandyck, Caroline and Kiessling, Benjamin},
|
74 |
+
URL = {https://inria.hal.science/hal-04453952},
|
75 |
+
NOTE = {working paper or preprint},
|
76 |
+
YEAR = {2024},
|
77 |
+
MONTH = Feb,
|
78 |
+
KEYWORDS = {Historical sources ; medieval manuscripts ; Latin scripts ; benchmarking dataset ; multilingual ; handwritten text recognition},
|
79 |
+
PDF = {https://inria.hal.science/hal-04453952/file/ICDAR24___CATMUS_Medieval-1.pdf},
|
80 |
+
HAL_ID = {hal-04453952},
|
81 |
+
HAL_VERSION = {v1},
|
82 |
+
}
|
83 |
+
```
|