xmelus commited on
Commit
088b3b3
1 Parent(s): 87bc25c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -0
README.md CHANGED
@@ -4,3 +4,50 @@ Fine-tuned standard easyocr model using the following dataset: https://huggingfa
4
  train_log: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/log_train.txt
5
 
6
  options: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/opt.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  train_log: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/log_train.txt
5
 
6
  options: https://huggingface.co/fimu-docproc-research/standard_0.1.1_EasyOcrEngine/blob/main/opt.txt
7
+
8
+
9
+ ```python
10
+ >>> import easyocr
11
+ >>> import torch
12
+ >>> from huggingface_hub import hf_hub_download
13
+
14
+ >>> # Initialize default easyocr model
15
+ >>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'])
16
+ >>> # Download weights of recognition module.
17
+ >>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.1.1_EasyOcrEngine", filename="weights.pth")
18
+ >>> # Load the weights
19
+ >>> state_dict = torch.load(model_dir, map_location="cuda")
20
+ >>> # Load the state dictionary into the model
21
+ >>> reader.recognizer.load_state_dict(state_dict)
22
+
23
+ >>> # Typical usage of easyocr model to get predictions
24
+ >>> res = reader.readtext(input_img)
25
+ ```
26
+
27
+ ### Example usage (without GPU):
28
+
29
+ ```python
30
+ >>> from collections import OrderedDict
31
+
32
+ >>> import easyocr
33
+ >>> import torch
34
+ >>> from huggingface_hub import hf_hub_download
35
+
36
+ >>> # Initialize default easyocr model
37
+ >>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'], quantize=False, gpu=False)
38
+ >>> # Download weights of recognition module.
39
+ >>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.1.1_EasyOcrEngine", filename="weights.pth")
40
+ >>> # Load the weights
41
+ >>> state_dict = torch.load(model_dir, map_location="cpu")
42
+ >>> # There is need to remove first 7 characters due to easyocr library
43
+ >>> new_state_dict = OrderedDict()
44
+ >>> for key, value in state_dict.items():
45
+ >>> new_key = key[7:]
46
+ >>> new_state_dict[new_key] = value
47
+
48
+ >>> # Load the state dictionary into the model
49
+ >>> reader.recognizer.load_state_dict(new_state_dict)
50
+
51
+ >>> # Typical usage of easyocr model to get predictions
52
+ >>> res = reader.readtext(input_img)
53
+ ```