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