ctranslate2-4you commited on
Commit
76e5000
·
verified ·
1 Parent(s): 6c3d846

update readme

Browse files
Files changed (1) hide show
  1. README.md +117 -0
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: image-text-to-text
3
+ language:
4
+ - multilingual
5
+ tags:
6
+ - got
7
+ - vision-language
8
+ - ocr2.0
9
+ - custom_code
10
+ license: apache-2.0
11
+ ---
12
+
13
+ ## Same model as located at [stepfun-ai/GOT-OCR2_0](https://huggingface.co/stepfun-ai/GOT-OCR2_0) with customized source code that:
14
+ 1) Removes the `verovio` dependency since most people don't need to OCR musical annotation.
15
+ 2) Allows a user to use `float16` if their GPU doesn't support `bfloat`.
16
+ 3) Updated to support `Transformers==4.48.3` so it no longer gives a bunch of warning messages.
17
+
18
+ <details><summary>ORIGINAL MODEL CARD HERE</summary>
19
+
20
+
21
+ <h1>General OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model
22
+ </h1>
23
+
24
+ [🔋Online Demo](https://huggingface.co/spaces/ucaslcl/GOT_online) | [🌟GitHub](https://github.com/Ucas-HaoranWei/GOT-OCR2.0/) | [📜Paper](https://arxiv.org/abs/2409.01704)</a>
25
+
26
+
27
+ [Haoran Wei*](https://scholar.google.com/citations?user=J4naK0MAAAAJ&hl=en), Chenglong Liu*, Jinyue Chen, Jia Wang, Lingyu Kong, Yanming Xu, [Zheng Ge](https://joker316701882.github.io/), Liang Zhao, [Jianjian Sun](https://scholar.google.com/citations?user=MVZrGkYAAAAJ&hl=en), [Yuang Peng](https://scholar.google.com.hk/citations?user=J0ko04IAAAAJ&hl=zh-CN&oi=ao), Chunrui Han, [Xiangyu Zhang](https://scholar.google.com/citations?user=yuB-cfoAAAAJ&hl=en)
28
+
29
+
30
+
31
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6653eee7a2d7a882a805ab95/QCEFY-M_YG3Bp5fn1GQ8X.jpeg)
32
+
33
+
34
+
35
+ ## Usage
36
+ Inference using Huggingface transformers on NVIDIA GPUs. Requirements tested on python 3.10:
37
+ ```
38
+ torch==2.0.1
39
+ torchvision==0.15.2
40
+ transformers==4.37.2
41
+ tiktoken==0.6.0
42
+ verovio==4.3.1
43
+ accelerate==0.28.0
44
+ ```
45
+
46
+
47
+ ```python
48
+ from transformers import AutoModel, AutoTokenizer
49
+
50
+ tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
51
+ model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True, pad_token_id=tokenizer.eos_token_id)
52
+ model = model.eval().cuda()
53
+
54
+
55
+ # input your test image
56
+ image_file = 'xxx.jpg'
57
+
58
+ # plain texts OCR
59
+ res = model.chat(tokenizer, image_file, ocr_type='ocr')
60
+
61
+ # format texts OCR:
62
+ # res = model.chat(tokenizer, image_file, ocr_type='format')
63
+
64
+ # fine-grained OCR:
65
+ # res = model.chat(tokenizer, image_file, ocr_type='ocr', ocr_box='')
66
+ # res = model.chat(tokenizer, image_file, ocr_type='format', ocr_box='')
67
+ # res = model.chat(tokenizer, image_file, ocr_type='ocr', ocr_color='')
68
+ # res = model.chat(tokenizer, image_file, ocr_type='format', ocr_color='')
69
+
70
+ # multi-crop OCR:
71
+ # res = model.chat_crop(tokenizer, image_file, ocr_type='ocr')
72
+ # res = model.chat_crop(tokenizer, image_file, ocr_type='format')
73
+
74
+ # render the formatted OCR results:
75
+ # res = model.chat(tokenizer, image_file, ocr_type='format', render=True, save_render_file = './demo.html')
76
+
77
+ print(res)
78
+
79
+
80
+ ```
81
+ More details about 'ocr_type', 'ocr_box', 'ocr_color', and 'render' can be found at our GitHub.
82
+ Our training codes are available at our [GitHub](https://github.com/Ucas-HaoranWei/GOT-OCR2.0/).
83
+
84
+
85
+
86
+ ## More Multimodal Projects
87
+
88
+ 👏 Welcome to explore more multimodal projects of our team:
89
+
90
+ [Vary](https://github.com/Ucas-HaoranWei/Vary) | [Fox](https://github.com/ucaslcl/Fox) | [OneChart](https://github.com/LingyvKong/OneChart)
91
+
92
+ ## Citation
93
+
94
+ If you find our work helpful, please consider citing our papers 📝 and liking this project ❤️!
95
+
96
+ ```bib
97
+ @article{wei2024general,
98
+ title={General OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model},
99
+ author={Wei, Haoran and Liu, Chenglong and Chen, Jinyue and Wang, Jia and Kong, Lingyu and Xu, Yanming and Ge, Zheng and Zhao, Liang and Sun, Jianjian and Peng, Yuang and others},
100
+ journal={arXiv preprint arXiv:2409.01704},
101
+ year={2024}
102
+ }
103
+ @article{liu2024focus,
104
+ title={Focus Anywhere for Fine-grained Multi-page Document Understanding},
105
+ author={Liu, Chenglong and Wei, Haoran and Chen, Jinyue and Kong, Lingyu and Ge, Zheng and Zhu, Zining and Zhao, Liang and Sun, Jianjian and Han, Chunrui and Zhang, Xiangyu},
106
+ journal={arXiv preprint arXiv:2405.14295},
107
+ year={2024}
108
+ }
109
+ @article{wei2023vary,
110
+ title={Vary: Scaling up the Vision Vocabulary for Large Vision-Language Models},
111
+ author={Wei, Haoran and Kong, Lingyu and Chen, Jinyue and Zhao, Liang and Ge, Zheng and Yang, Jinrong and Sun, Jianjian and Han, Chunrui and Zhang, Xiangyu},
112
+ journal={arXiv preprint arXiv:2312.06109},
113
+ year={2023}
114
+ }
115
+ ```
116
+
117
+ </details>