aoiandroid commited on
Commit
3cd1f83
·
verified ·
1 Parent(s): 92e556e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +107 -0
README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <h1>General OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model
14
+ </h1>
15
+
16
+ [🔋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>
17
+
18
+
19
+ [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)
20
+
21
+
22
+
23
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6653eee7a2d7a882a805ab95/QCEFY-M_YG3Bp5fn1GQ8X.jpeg)
24
+
25
+
26
+
27
+ ## Usage
28
+ Inference using Huggingface transformers on NVIDIA GPUs. Requirements tested on python 3.10:
29
+ ```
30
+ torch==2.0.1
31
+ torchvision==0.15.2
32
+ transformers==4.37.2
33
+ tiktoken==0.6.0
34
+ verovio==4.3.1
35
+ accelerate==0.28.0
36
+ ```
37
+
38
+
39
+ ```python
40
+ from transformers import AutoModel, AutoTokenizer
41
+
42
+ tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
43
+ 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)
44
+ model = model.eval().cuda()
45
+
46
+
47
+ # input your test image
48
+ image_file = 'xxx.jpg'
49
+
50
+ # plain texts OCR
51
+ res = model.chat(tokenizer, image_file, ocr_type='ocr')
52
+
53
+ # format texts OCR:
54
+ # res = model.chat(tokenizer, image_file, ocr_type='format')
55
+
56
+ # fine-grained OCR:
57
+ # res = model.chat(tokenizer, image_file, ocr_type='ocr', ocr_box='')
58
+ # res = model.chat(tokenizer, image_file, ocr_type='format', ocr_box='')
59
+ # res = model.chat(tokenizer, image_file, ocr_type='ocr', ocr_color='')
60
+ # res = model.chat(tokenizer, image_file, ocr_type='format', ocr_color='')
61
+
62
+ # multi-crop OCR:
63
+ # res = model.chat_crop(tokenizer, image_file, ocr_type='ocr')
64
+ # res = model.chat_crop(tokenizer, image_file, ocr_type='format')
65
+
66
+ # render the formatted OCR results:
67
+ # res = model.chat(tokenizer, image_file, ocr_type='format', render=True, save_render_file = './demo.html')
68
+
69
+ print(res)
70
+
71
+
72
+ ```
73
+ More details about 'ocr_type', 'ocr_box', 'ocr_color', and 'render' can be found at our GitHub.
74
+ Our training codes are available at our [GitHub](https://github.com/Ucas-HaoranWei/GOT-OCR2.0/).
75
+
76
+
77
+
78
+ ## More Multimodal Projects
79
+
80
+ 👏 Welcome to explore more multimodal projects of our team:
81
+
82
+ [Vary](https://github.com/Ucas-HaoranWei/Vary) | [Fox](https://github.com/ucaslcl/Fox) | [OneChart](https://github.com/LingyvKong/OneChart)
83
+
84
+ ## Citation
85
+
86
+ If you find our work helpful, please consider citing our papers 📝 and liking this project ❤️!
87
+
88
+ ```bib
89
+ @article{wei2024general,
90
+ title={General OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model},
91
+ 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},
92
+ journal={arXiv preprint arXiv:2409.01704},
93
+ year={2024}
94
+ }
95
+ @article{liu2024focus,
96
+ title={Focus Anywhere for Fine-grained Multi-page Document Understanding},
97
+ 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},
98
+ journal={arXiv preprint arXiv:2405.14295},
99
+ year={2024}
100
+ }
101
+ @article{wei2023vary,
102
+ title={Vary: Scaling up the Vision Vocabulary for Large Vision-Language Models},
103
+ 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},
104
+ journal={arXiv preprint arXiv:2312.06109},
105
+ year={2023}
106
+ }
107
+ ```