File size: 7,396 Bytes
92b19a3
306ced6
3b3f7c0
92b19a3
3b3f7c0
 
306ced6
3b3f7c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3642f0d
306ced6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92b19a3
 
5dd5081
3b3f7c0
5dd5081
3b3f7c0
 
3642f0d
 
95ccd40
3b3f7c0
5d8063e
306ced6
 
 
 
 
 
 
5d8063e
3b3f7c0
 
306ced6
3b3f7c0
 
 
306ced6
3b3f7c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3642f0d
3b3f7c0
 
 
 
 
3642f0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b3f7c0
 
 
 
 
 
 
306ced6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
---
license: mit
base_model: microsoft/resnet-18
tags:
- generated_from_trainer
datasets:
- gaborcselle/font-examples
metrics:
- accuracy
model-index:
- name: font-identifier
  results:
  - task:
      name: Image Classification
      type: image-classification
    dataset:
      name: imagefolder
      type: imagefolder
      config: default
      split: test
      args: default
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.963265306122449
widget:
- text: What font is this?
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/ArchitectsDaughter-Regular_1.png
  example_title: Architects Daughter
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Arial%20Bold_39.png
  example_title: Arial Bold
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Courier_28.png
  example_title: Courier
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Helvetica_3.png
  example_title: Helvetica
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/IBMPlexSans-Regular_25.png
  example_title: IBM Plex Sans
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Inter-Regular_43.png
  example_title: Inter
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Lobster-Regular_25.png
  example_title: Lobster
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Merriweather-Regular_1.png
  example_title: Merriweather
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Poppins-Regular_22.png
  example_title: Poppins
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/RobotoMono-Regular_38.png
  example_title: Roboto Mono
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Times_New_Roman_Bold
    Italic_26.png
  example_title: Times New Roman Bold Italic
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Times_New_Roman_Italic_16.png
  example_title: Times New Roman Italic
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/TitilliumWeb-Regular_5.png
  example_title: Titillium Web
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Trebuchet_MS_Italic_47.png
  example_title: Trebuchet MS Italic
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Trebuchet_MS_11.png
  example_title: Trebuchet MS
- src: >-
    https://huggingface.co/gaborcselle/font-identifier/resolve/main/hf_samples/Verdana_Bold_43.png
  example_title: Verdana Bold
language:
- en
---


# font-identifier

This model is a fine-tuned version of [microsoft/resnet-18](https://huggingface.co/microsoft/resnet-18) on the imagefolder dataset.
It achieves the following results on the evaluation set:
- Loss: 0.1172
- Accuracy: 0.9633

## Model description

Identify the font used in an image. Visual classifier based on ResNet18.

I built this project in 1 day, with a minute-by-minute journal:
* [On Twitter/X](https://twitter.com/gabor/status/1722300841691103467)
* [On Pebble.social](https://pebble.social/@gabor/111376050835874755)
* [On Threads.net](https://www.threads.net/@gaborcselle/post/CzZJpJCpxTz)


## Intended uses & limitations

Identify any of 48 standard fonts from the training data.

## Training and evaluation data

Trained and eval'd on the [gaborcselle/font-examples](https://huggingface.co/datasets/gaborcselle/font-examples) dataset (80/20 split).

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- gradient_accumulation_steps: 4
- total_train_batch_size: 64
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- lr_scheduler_warmup_ratio: 0.1
- num_epochs: 50

### Training results

| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|:-------------:|:-----:|:----:|:---------------:|:--------:|
| 4.0243        | 0.98  | 30   | 3.9884          | 0.0204   |
| 3.7051        | 1.98  | 61   | 3.6012          | 0.0776   |
| 3.2036        | 2.99  | 92   | 2.9556          | 0.2939   |
| 2.6413        | 4.0   | 123  | 2.3054          | 0.4531   |
| 2.1015        | 4.98  | 153  | 1.7366          | 0.5224   |
| 1.6508        | 5.98  | 184  | 1.3509          | 0.6367   |
| 1.3986        | 6.99  | 215  | 1.0938          | 0.7163   |
| 1.1918        | 8.0   | 246  | 0.9012          | 0.7735   |
| 1.0633        | 8.98  | 276  | 0.7464          | 0.8143   |
| 0.8771        | 9.98  | 307  | 0.6569          | 0.8306   |
| 0.8309        | 10.99 | 338  | 0.5536          | 0.8551   |
| 0.7093        | 12.0  | 369  | 0.4795          | 0.8796   |
| 0.6579        | 12.98 | 399  | 0.4176          | 0.8837   |
| 0.5827        | 13.98 | 430  | 0.3888          | 0.8980   |
| 0.5418        | 14.99 | 461  | 0.3255          | 0.9122   |
| 0.5102        | 16.0  | 492  | 0.3139          | 0.9265   |
| 0.472         | 16.98 | 522  | 0.3141          | 0.9163   |
| 0.4273        | 17.98 | 553  | 0.2673          | 0.9245   |
| 0.384         | 18.99 | 584  | 0.2487          | 0.9265   |
| 0.3917        | 20.0  | 615  | 0.2353          | 0.9388   |
| 0.418         | 20.98 | 645  | 0.2113          | 0.9490   |
| 0.3662        | 21.98 | 676  | 0.2095          | 0.9327   |
| 0.3258        | 22.99 | 707  | 0.2139          | 0.9429   |
| 0.3268        | 24.0  | 738  | 0.1962          | 0.9449   |
| 0.3048        | 24.98 | 768  | 0.1935          | 0.9408   |
| 0.2696        | 25.98 | 799  | 0.2112          | 0.9408   |
| 0.2524        | 26.99 | 830  | 0.2310          | 0.9306   |
| 0.2491        | 28.0  | 861  | 0.1827          | 0.9449   |
| 0.2542        | 28.98 | 891  | 0.1720          | 0.9592   |
| 0.2898        | 29.98 | 922  | 0.1605          | 0.9490   |
| 0.2298        | 30.99 | 953  | 0.1326          | 0.9633   |
| 0.2137        | 32.0  | 984  | 0.1438          | 0.9571   |
| 0.2002        | 32.98 | 1014 | 0.1379          | 0.9551   |
| 0.2013        | 33.98 | 1045 | 0.1261          | 0.9653   |
| 0.1862        | 34.99 | 1076 | 0.1674          | 0.9408   |
| 0.1993        | 36.0  | 1107 | 0.1423          | 0.9571   |
| 0.2063        | 36.98 | 1137 | 0.1406          | 0.9592   |
| 0.2088        | 37.98 | 1168 | 0.1717          | 0.9429   |
| 0.1711        | 38.99 | 1199 | 0.1539          | 0.9510   |
| 0.1804        | 40.0  | 1230 | 0.1421          | 0.9571   |
| 0.1793        | 40.98 | 1260 | 0.0765          | 0.9776   |
| 0.2139        | 41.98 | 1291 | 0.1859          | 0.9449   |
| 0.1678        | 42.99 | 1322 | 0.1067          | 0.9796   |
| 0.1675        | 44.0  | 1353 | 0.0985          | 0.9735   |
| 0.1681        | 44.98 | 1383 | 0.1093          | 0.9653   |
| 0.1625        | 45.98 | 1414 | 0.1402          | 0.9592   |
| 0.1987        | 46.99 | 1445 | 0.1250          | 0.9673   |
| 0.1728        | 48.0  | 1476 | 0.1293          | 0.9633   |
| 0.1337        | 48.78 | 1500 | 0.1172          | 0.9633   |


### Framework versions

- Transformers 4.36.0.dev0
- Pytorch 2.0.0
- Datasets 2.12.0
- Tokenizers 0.14.1