horatio12 commited on
Commit
fbaae17
·
verified ·
1 Parent(s): e0f0c71

Upload model and card

Browse files
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Kansallisarkisto/multicentury-htr-model
4
+ pipeline_tag: image-to-text
5
+ library_name: transformers
6
+ language: en
7
+ tags: [trocr, htr, handwriting, genealogy, historical-documents, passenger-lists]
8
+ ---
9
+
10
+ # Passenger list handwriting reader
11
+
12
+ Reads one handwritten name from a strip cut out of a US ship passenger list. Fine-tuned from the National Archives of
13
+ Finland's [multicentury-htr-model](https://huggingface.co/Kansallisarkisto/multicentury-htr-model) on name strips
14
+ from New York arrival lists, 1897 to 1957 (National Archives microfilm T715, scanned on archive.org). Many names are
15
+ Eastern and Southern European, as written by American clerks and ship officers.
16
+
17
+ Part of [passenger-list-reader](https://github.com/jbyoung12/passenger-list-reader). Strips were cut with
18
+ [kraken](https://kraken.re)'s line finder, so it reads those best. For typed strips use
19
+ [passenger-list-typed-reader](https://huggingface.co/horatio12/passenger-list-typed-reader).
20
+
21
+ ## Use
22
+
23
+ ```python
24
+ from PIL import Image
25
+ from transformers import TrOCRProcessor, VisionEncoderDecoderModel
26
+
27
+ proc = TrOCRProcessor.from_pretrained("horatio12/passenger-list-handwriting-reader")
28
+ model = VisionEncoderDecoderModel.from_pretrained("horatio12/passenger-list-handwriting-reader").eval()
29
+ pix = proc(images=Image.open("strip.png").convert("RGB"), return_tensors="pt").pixel_values
30
+ ids = model.generate(pix, max_new_tokens=48, interpolate_pos_encoding=pix.shape[-1] != pix.shape[-2])
31
+ print(proc.batch_decode(ids, skip_special_tokens=True)[0])
32
+ ```
33
+
34
+ ## Results
35
+
36
+ On 23 handwritten pages from reels nothing was trained on, counting only names where two independent reads agree on the
37
+ truth: 559 of 744 words right (75.1%), 178 full names right, 7.5% of letters wrong.
38
+
39
+ ## Training labels
40
+
41
+ Each strip was read twice by Claude (some also by Gemini), and only names where the reads agreed were kept. They were
42
+ not checked by a person, so hard handwriting is underrepresented.
43
+
44
+ ## Limits
45
+
46
+ Tuned for short name strips, not for running handwriting. Untested on other ports. Hard or faded hands are
47
+ much less accurate than the average above.
48
+
49
+ ## License
50
+
51
+ Apache 2.0, the same as the base model.
config.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "VisionEncoderDecoderModel"
4
+ ],
5
+ "decoder": {
6
+ "_name_or_path": "",
7
+ "activation_dropout": 0.0,
8
+ "activation_function": "gelu",
9
+ "add_cross_attention": true,
10
+ "architectures": null,
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "chunk_size_feed_forward": 0,
14
+ "classifier_dropout": 0.0,
15
+ "cross_attention_hidden_size": 1024,
16
+ "d_model": 1024,
17
+ "decoder_attention_heads": 16,
18
+ "decoder_ffn_dim": 4096,
19
+ "decoder_layerdrop": 0.0,
20
+ "decoder_layers": 12,
21
+ "decoder_start_token_id": 2,
22
+ "dropout": 0.1,
23
+ "dtype": "float32",
24
+ "eos_token_id": 2,
25
+ "finetuning_task": null,
26
+ "id2label": {
27
+ "0": "LABEL_0",
28
+ "1": "LABEL_1"
29
+ },
30
+ "init_std": 0.02,
31
+ "is_decoder": true,
32
+ "is_encoder_decoder": false,
33
+ "label2id": {
34
+ "LABEL_0": 0,
35
+ "LABEL_1": 1
36
+ },
37
+ "layernorm_embedding": true,
38
+ "max_position_embeddings": 512,
39
+ "model_type": "trocr",
40
+ "output_attentions": false,
41
+ "output_hidden_states": false,
42
+ "pad_token_id": 1,
43
+ "prefix": null,
44
+ "problem_type": null,
45
+ "pruned_heads": {},
46
+ "return_dict": true,
47
+ "scale_embedding": false,
48
+ "sep_token_id": null,
49
+ "task_specific_params": null,
50
+ "tf_legacy_loss": false,
51
+ "tie_encoder_decoder": false,
52
+ "tie_word_embeddings": true,
53
+ "tokenizer_class": null,
54
+ "torchscript": false,
55
+ "use_bfloat16": false,
56
+ "use_cache": false,
57
+ "use_learned_position_embeddings": true,
58
+ "vocab_size": 50265
59
+ },
60
+ "decoder_start_token_id": 0,
61
+ "dtype": "float32",
62
+ "encoder": {
63
+ "_name_or_path": "",
64
+ "add_cross_attention": false,
65
+ "architectures": null,
66
+ "attention_probs_dropout_prob": 0.0,
67
+ "bos_token_id": null,
68
+ "chunk_size_feed_forward": 0,
69
+ "cross_attention_hidden_size": null,
70
+ "decoder_start_token_id": null,
71
+ "dtype": "float32",
72
+ "encoder_stride": 16,
73
+ "eos_token_id": null,
74
+ "finetuning_task": null,
75
+ "hidden_act": "gelu",
76
+ "hidden_dropout_prob": 0.0,
77
+ "hidden_size": 1024,
78
+ "id2label": {
79
+ "0": "LABEL_0",
80
+ "1": "LABEL_1"
81
+ },
82
+ "image_size": 384,
83
+ "initializer_range": 0.02,
84
+ "intermediate_size": 4096,
85
+ "is_decoder": false,
86
+ "is_encoder_decoder": false,
87
+ "label2id": {
88
+ "LABEL_0": 0,
89
+ "LABEL_1": 1
90
+ },
91
+ "layer_norm_eps": 1e-12,
92
+ "model_type": "vit",
93
+ "num_attention_heads": 16,
94
+ "num_channels": 3,
95
+ "num_hidden_layers": 24,
96
+ "output_attentions": false,
97
+ "output_hidden_states": false,
98
+ "pad_token_id": null,
99
+ "patch_size": 16,
100
+ "pooler_act": "tanh",
101
+ "pooler_output_size": 1024,
102
+ "prefix": null,
103
+ "problem_type": null,
104
+ "pruned_heads": {},
105
+ "qkv_bias": false,
106
+ "return_dict": true,
107
+ "sep_token_id": null,
108
+ "task_specific_params": null,
109
+ "tf_legacy_loss": false,
110
+ "tie_encoder_decoder": false,
111
+ "tie_word_embeddings": true,
112
+ "tokenizer_class": null,
113
+ "torchscript": false,
114
+ "use_bfloat16": false
115
+ },
116
+ "eos_token_id": 2,
117
+ "interpolate_pos_encoding": true,
118
+ "is_encoder_decoder": true,
119
+ "model_type": "vision-encoder-decoder",
120
+ "pad_token_id": 1,
121
+ "tie_word_embeddings": false,
122
+ "transformers_version": "5.12.1",
123
+ "vocab_size": 50265
124
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 0,
3
+ "decoder_start_token_id": 0,
4
+ "early_stopping": false,
5
+ "eos_token_id": 2,
6
+ "length_penalty": 1,
7
+ "max_length": 128,
8
+ "no_repeat_ngram_size": 3,
9
+ "num_beams": 1,
10
+ "pad_token_id": 1,
11
+ "transformers_version": "5.12.1",
12
+ "use_cache": false
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82d1c0db5e90040eef651ffee4ab7c502258b778e0317d5de3739fbd93a5b5ab
3
+ size 2232985336
processor_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "ViTImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "resample": 2,
18
+ "rescale_factor": 0.00392156862745098,
19
+ "size": {
20
+ "height": 192,
21
+ "width": 1024
22
+ }
23
+ },
24
+ "processor_class": "TrOCRProcessor"
25
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": true,
6
+ "cls_token": "<s>",
7
+ "do_resize": true,
8
+ "eos_token": "</s>",
9
+ "errors": "replace",
10
+ "is_local": true,
11
+ "local_files_only": false,
12
+ "mask_token": "<mask>",
13
+ "max_length": 48,
14
+ "model_max_length": 512,
15
+ "pad_to_multiple_of": null,
16
+ "pad_token": "<pad>",
17
+ "pad_token_type_id": 0,
18
+ "padding_side": "right",
19
+ "processor_class": "TrOCRProcessor",
20
+ "sep_token": "</s>",
21
+ "size": {
22
+ "height": 192,
23
+ "width": 1024
24
+ },
25
+ "stride": 0,
26
+ "tokenizer_class": "RobertaTokenizer",
27
+ "trim_offsets": true,
28
+ "truncation_side": "right",
29
+ "truncation_strategy": "longest_first",
30
+ "unk_token": "<unk>"
31
+ }