lrqlrqlrq commited on
Commit
8f09406
1 Parent(s): 16d7aa0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -1
README.md CHANGED
@@ -1,3 +1,39 @@
1
  ---
2
  license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ pipeline_tag: image-to-text
4
+ ---
5
+
6
+ 该模型为中英文本混合公式与表格LaTeX OCR,详见:https://arxiv.org/abs/2406.17148。
7
+ This model is designed for mixed Chinese-English text, formula, and table LaTeX OCR. For more details, please refer to: https://arxiv.org/abs/2406.17148.
8
+
9
+ # 使用方法:
10
+ ```python
11
+ from transformers import AutoTokenizer, VisionEncoderDecoderModel, AutoImageProcessor
12
+ from PIL import Image
13
+ import requests
14
+
15
+ feature_extractor = AutoImageProcessor.from_pretrained("lrqlrqlrq/MixTex_Tiny_ZhEn_Latex_Math_OCR")
16
+ tokenizer = AutoTokenizer.from_pretrained("lrqlrqlrq/MixTex_Tiny_ZhEn_Latex_Math_OCR", max_len=296)
17
+ model = VisionEncoderDecoderModel.from_pretrained("lrqlrqlrq/MixTex_Tiny_ZhEn_Latex_Math_OCR")
18
+
19
+ imgen = Image.open(requests.get('https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/eOAym7FZDsjic_8ptsC-H.png', stream=True).raw)
20
+ #imgzh = Image.open(requests.get('https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/m-oVg8dsQbQZ1fDWbwKtO.png', stream=True).raw)
21
+ print(tokenizer.decode(model.generate(feature_extractor(imgen, return_tensors="pt").pixel_values)[0]).replace('\\[','\\begin{align*}').replace('\\]','\\end{align*}'))
22
+ ```
23
+
24
+ # 补充:
25
+ 建议图片尺寸:大约 (400, 500), (H, W)。
26
+ 建议输出字数:大约100-300个tokens。
27
+ Latex 环境:
28
+ ```
29
+ \usepackage{amssymb}
30
+ \usepackage{amsmath}
31
+ \usepackage{stmaryrd}
32
+ \usepackage{color}
33
+ ```
34
+ # 样例:
35
+
36
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/eOAym7FZDsjic_8ptsC-H.png)
37
+
38
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/m-oVg8dsQbQZ1fDWbwKtO.png)
39
+