wjbmattingly
commited on
Commit
•
e0d5eca
1
Parent(s):
4ed29bb
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,85 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- la
|
5 |
+
- fr
|
6 |
+
- esp
|
7 |
+
datasets:
|
8 |
+
- CATMuS/medieval
|
9 |
+
tags:
|
10 |
+
- trocr
|
11 |
+
- image-to-text
|
12 |
+
widget:
|
13 |
+
- src: >-
|
14 |
+
https://huggingface.co/medieval-data/trocr-medieval-semitextualis/resolve/main/images/semitextualis-1.png
|
15 |
+
example_title: Humanistica 1
|
16 |
+
- src: >-
|
17 |
+
https://huggingface.co/medieval-data/trocr-medieval-semitextualis/resolve/main/images/semitextualis-2.png
|
18 |
+
example_title: Humanistica 2
|
19 |
+
- src: >-
|
20 |
+
https://huggingface.co/medieval-data/trocr-medieval-semitextualis/resolve/main/images/semitextualis-3.png
|
21 |
+
example_title: Humanistica 3
|
22 |
+
---
|
23 |
+
|
24 |
+
![logo](logo-semitextualis.png)
|
25 |
+
|
26 |
+
# About
|
27 |
+
|
28 |
+
This is a TrOCR model for medieval Semitextualis. 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 Semitextualis.
|
29 |
+
|
30 |
+
The dataset used for training was [CATMuS](https://huggingface.co/datasets/CATMuS/medieval).
|
31 |
+
|
32 |
+
The model has not been formally tested. Preliminary examination indicates that further finetuning is needed.
|
33 |
+
|
34 |
+
Finetuning was done with finetune.py found in this repository.
|
35 |
+
|
36 |
+
# Usage
|
37 |
+
|
38 |
+
```python
|
39 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
40 |
+
from PIL import Image
|
41 |
+
import requests
|
42 |
+
|
43 |
+
# load image from the IAM database
|
44 |
+
url = 'https://huggingface.co/medieval-data/trocr-medieval-humanistica/resolve/main/images/semitextualis-1.png'
|
45 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
46 |
+
|
47 |
+
processor = TrOCRProcessor.from_pretrained('medieval-data/trocr-medieval-semitextualis')
|
48 |
+
model = VisionEncoderDecoderModel.from_pretrained('medieval-data/trocr-medieval-semitextualis')
|
49 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
50 |
+
|
51 |
+
generated_ids = model.generate(pixel_values)
|
52 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
53 |
+
```
|
54 |
+
|
55 |
+
# BibTeX entry and citation info
|
56 |
+
|
57 |
+
## TrOCR Paper
|
58 |
+
|
59 |
+
```tex
|
60 |
+
@misc{li2021trocr,
|
61 |
+
title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
|
62 |
+
author={Minghao Li and Tengchao Lv and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
|
63 |
+
year={2021},
|
64 |
+
eprint={2109.10282},
|
65 |
+
archivePrefix={arXiv},
|
66 |
+
primaryClass={cs.CL}
|
67 |
+
}
|
68 |
+
```
|
69 |
+
|
70 |
+
## CATMuS Paper
|
71 |
+
|
72 |
+
```tex
|
73 |
+
@unpublished{clerice:hal-04453952,
|
74 |
+
TITLE = {{CATMuS Medieval: A multilingual large-scale cross-century dataset in Latin script for handwritten text recognition and beyond}},
|
75 |
+
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},
|
76 |
+
URL = {https://inria.hal.science/hal-04453952},
|
77 |
+
NOTE = {working paper or preprint},
|
78 |
+
YEAR = {2024},
|
79 |
+
MONTH = Feb,
|
80 |
+
KEYWORDS = {Historical sources ; medieval manuscripts ; Latin scripts ; benchmarking dataset ; multilingual ; handwritten text recognition},
|
81 |
+
PDF = {https://inria.hal.science/hal-04453952/file/ICDAR24___CATMUS_Medieval-1.pdf},
|
82 |
+
HAL_ID = {hal-04453952},
|
83 |
+
HAL_VERSION = {v1},
|
84 |
+
}
|
85 |
+
```
|