xmelus's picture
Update README.md
088b3b3
|
raw
history blame
2.01 kB
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)
```