File size: 2,005 Bytes
87bc25c
 
 
 
 
 
088b3b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
Fine-tuned standard easyocr model using the following dataset: https://huggingface.co/datasets/fimu-docproc-research/born_digital with addition of another 20 000 examples of generated IBANs/account numbers.


train_log: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/log_train.txt

options: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/opt.txt


```python
>>> import easyocr
>>> import torch
>>> from huggingface_hub import hf_hub_download

>>> # Initialize default easyocr model
>>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'])
>>> # Download weights of recognition module.
>>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.1.1_EasyOcrEngine", filename="weights.pth")
>>> # Load the weights
>>> state_dict = torch.load(model_dir, map_location="cuda")
>>> # Load the state dictionary into the model
>>> reader.recognizer.load_state_dict(state_dict)

>>> # Typical usage of easyocr model  to get predictions
>>> res = reader.readtext(input_img)
```

### Example usage (without GPU):

```python
>>> from collections import OrderedDict

>>> import easyocr
>>> import torch
>>> from huggingface_hub import hf_hub_download

>>> # Initialize default easyocr model
>>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'], quantize=False, gpu=False)
>>> # Download weights of recognition module.
>>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.1.1_EasyOcrEngine", filename="weights.pth")
>>> # Load the weights
>>> state_dict = torch.load(model_dir, map_location="cpu")
>>> # There is need to remove first 7 characters due to easyocr library
>>> new_state_dict = OrderedDict()
>>> for key, value in state_dict.items():
>>>     new_key = key[7:]
>>>     new_state_dict[new_key] = value

>>> # Load the state dictionary into the model
>>> reader.recognizer.load_state_dict(new_state_dict)

>>> # Typical usage of easyocr model  to get predictions
>>> res = reader.readtext(input_img)
```