Prince-1 commited on
Commit
82b0980
·
verified ·
1 Parent(s): 95a45cf

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. README.md +141 -0
  2. onnx/vpm.blocks.1.attn.qkv.bias +0 -0
  3. onnx/vpm.blocks.1.norm1.weight +0 -0
  4. onnx/vpm.blocks.10.attn.qkv.bias +0 -0
  5. onnx/vpm.blocks.11.mlp.linear_fc2.bias +0 -0
  6. onnx/vpm.blocks.12.mlp.linear_fc1.bias +0 -0
  7. onnx/vpm.blocks.13.attn.qkv.bias +0 -0
  8. onnx/vpm.blocks.14.norm1.bias +0 -0
  9. onnx/vpm.blocks.15.attn.proj.bias +0 -0
  10. onnx/vpm.blocks.15.mlp.linear_fc2.bias +0 -0
  11. onnx/vpm.blocks.15.norm1.bias +0 -0
  12. onnx/vpm.blocks.15.norm1.weight +0 -0
  13. onnx/vpm.blocks.15.norm2.bias +0 -0
  14. onnx/vpm.blocks.16.mlp.linear_fc1.bias +0 -0
  15. onnx/vpm.blocks.16.norm2.bias +0 -0
  16. onnx/vpm.blocks.17.norm2.bias +0 -0
  17. onnx/vpm.blocks.18.attn.qkv.bias +0 -0
  18. onnx/vpm.blocks.19.attn.proj.bias +0 -0
  19. onnx/vpm.blocks.19.attn.qkv.bias +0 -0
  20. onnx/vpm.blocks.19.norm1.weight +0 -0
  21. onnx/vpm.blocks.19.norm2.weight +0 -0
  22. onnx/vpm.blocks.20.mlp.linear_fc1.bias +0 -0
  23. onnx/vpm.blocks.20.mlp.linear_fc2.bias +0 -0
  24. onnx/vpm.blocks.20.norm1.bias +0 -0
  25. onnx/vpm.blocks.21.mlp.linear_fc1.bias +0 -0
  26. onnx/vpm.blocks.22.mlp.linear_fc2.bias +0 -0
  27. onnx/vpm.blocks.22.norm1.bias +0 -0
  28. onnx/vpm.blocks.23.attn.proj.bias +0 -0
  29. onnx/vpm.blocks.24.mlp.linear_fc1.bias +0 -0
  30. onnx/vpm.blocks.24.norm1.bias +0 -0
  31. onnx/vpm.blocks.25.attn.proj.bias +0 -0
  32. onnx/vpm.blocks.25.mlp.linear_fc1.bias +0 -0
  33. onnx/vpm.blocks.25.norm1.weight +0 -0
  34. onnx/vpm.blocks.26.norm2.weight +0 -0
  35. onnx/vpm.blocks.3.attn.qkv.bias +0 -0
  36. onnx/vpm.blocks.3.norm2.weight +0 -0
  37. onnx/vpm.blocks.4.attn.proj.bias +0 -0
  38. onnx/vpm.blocks.4.attn.qkv.bias +0 -0
  39. onnx/vpm.blocks.4.mlp.linear_fc1.bias +0 -0
  40. onnx/vpm.blocks.4.mlp.linear_fc2.bias +0 -0
  41. onnx/vpm.blocks.5.norm1.weight +0 -0
  42. onnx/vpm.blocks.6.attn.qkv.bias +0 -0
  43. onnx/vpm.blocks.7.mlp.linear_fc2.bias +0 -0
  44. onnx/vpm.blocks.7.norm2.bias +0 -0
  45. onnx/vpm.blocks.7.norm2.weight +0 -0
  46. onnx/vpm.blocks.8.mlp.linear_fc1.bias +0 -0
  47. onnx/vpm.blocks.9.mlp.linear_fc2.bias +0 -0
  48. onnx/vpm.deepstack_merger_list.0.norm.weight +0 -0
  49. onnx/vpm.merger.linear_fc1.bias +0 -0
  50. onnx/vpm.merger.linear_fc2.bias +0 -0
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail
3
+ library_name: rkllm
4
+ datalab-to/chandra
5
+ tags:
6
+ - rkllm
7
+ base_model:
8
+ - datalab-to/chandra
9
+ ---
10
+
11
+ # Chandra
12
+
13
+ Chandra is an OCR model that outputs markdown, HTML, and JSON. It is highly accurate at extracting text from images and PDFs, while preserving layout information.
14
+
15
+ You can try Chandra in the free playground [here](https://www.datalab.to/playground), or at a hosted API [here](https://www.datalab.to/).
16
+
17
+ ## Features
18
+
19
+ - Convert documents to markdown, html, or json with detailed layout information
20
+ - Good handwriting support
21
+ - Reconstructs forms accurately, including checkboxes
22
+ - Good support for tables, math, and complex layouts
23
+ - Extracts images and diagrams, with captions and structured data
24
+ - Support for 40+ languages
25
+
26
+ ## Quickstart
27
+
28
+ The easiest way to start is with the CLI tools:
29
+
30
+ ```shell
31
+ pip install chandra-ocr
32
+
33
+ # With VLLM
34
+ chandra_vllm
35
+ chandra input.pdf ./output
36
+
37
+ # With HuggingFace
38
+ chandra input.pdf ./output --method hf
39
+
40
+ # Interactive streamlit app
41
+ chandra_app
42
+ ```
43
+
44
+ ## Benchmarks
45
+
46
+ We used the olmocr benchmark, which seems to be the most reliable current OCR benchmark in our testing.
47
+
48
+ <img src="bench.png" width="600px"/>
49
+
50
+ | **Model** | ArXiv | Old Scans Math | Tables | Old Scans | Headers and Footers | Multi column | Long tiny text | Base | Overall | Source |
51
+ |:----------|:--------:|:--------------:|:--------:|:---------:|:-------------------:|:------------:|:--------------:|:----:|:--------------:|:------:|
52
+ | Datalab Chandra v0.1.0 | 82.2 | **80.3** | **88.0** | **50.4** | 90.8 | 81.2 | **92.3** | **99.9** | **83.1 ± 0.9** | Own benchmarks |
53
+ | Datalab Marker v1.10.0 | **83.8** | 69.7 | 74.8 | 32.3 | 86.6 | 79.4 | 85.7 | 99.6 | 76.5 ± 1.0 | Own benchmarks |
54
+ | Mistral OCR API | 77.2 | 67.5 | 60.6 | 29.3 | 93.6 | 71.3 | 77.1 | 99.4 | 72.0 ± 1.1 | olmocr repo |
55
+ | Deepseek OCR | 75.2 | 72.3 | 79.7 | 33.3 | 96.1 | 66.7 | 80.1 | 99.7 | 75.4 ± 1.0 | Own benchmarks |
56
+ | GPT-4o (Anchored) | 53.5 | 74.5 | 70.0 | 40.7 | 93.8 | 69.3 | 60.6 | 96.8 | 69.9 ± 1.1 | olmocr repo |
57
+ | Gemini Flash 2 (Anchored) | 54.5 | 56.1 | 72.1 | 34.2 | 64.7 | 61.5 | 71.5 | 95.6 | 63.8 ± 1.2 | olmocr repo |
58
+ | Qwen 3 VL | 70.2 | 75.1 | 45.6 | 37.5 | 89.1 | 62.1 | 43.0 | 94.3 | 64.6 ± 1.1 | Own benchmarks |
59
+ | olmOCR v0.3.0 | 78.6 | 79.9 | 72.9 | 43.9 | **95.1** | 77.3 | 81.2 | 98.9 | 78.5 ± 1.1 | olmocr repo |
60
+ | dots.ocr | 82.1 | 64.2 | 88.3 | 40.9 | 94.1 | **82.4** | 81.2 | 99.5 | 79.1 ± 1.0 | dots.ocr repo |
61
+
62
+ ## Examples
63
+
64
+ <img src="handwritten_form.png" width="600px"/>
65
+
66
+ | Type | Name | Link |
67
+ |------|------|------|
68
+ | Tables | Water Damage Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/water_damage.png) |
69
+ | Tables | 10K Filing | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/10k.png) |
70
+ | Forms | Handwritten Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/handwritten_form.png) |
71
+ | Forms | Lease Agreement | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/lease.png) |
72
+ | Handwriting | Doctor Note | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/doctor_note.png) |
73
+ | Handwriting | Math Homework | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/math_hw.png) |
74
+ | Books | Geography Textbook | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/books/geo_textbook_page.png) |
75
+ | Books | Exercise Problems | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/books/exercises.png) |
76
+ | Math | Attention Diagram | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/attn_all.png) |
77
+ | Math | Worksheet | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/worksheet.png) |
78
+ | Math | EGA Page | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/ega.png) |
79
+ | Newspapers | New York Times | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/newspapers/nyt.png) |
80
+ | Newspapers | LA Times | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/newspapers/la_times.png) |
81
+ | Other | Transcript | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/transcript.png) |
82
+ | Other | Flowchart | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/flowchart.png) |
83
+
84
+ ## Usage
85
+
86
+ ### Installation
87
+
88
+ ```shell
89
+ pip install chandra-ocr
90
+ ```
91
+
92
+ ### From code
93
+
94
+ ```python
95
+
96
+ from chandra.model import InferenceManager
97
+ from chandra.model.schema import BatchInputItem
98
+
99
+ # Run chandra_vllm to start a vLLM server first if you pass vllm, else pass hf
100
+ # you can also start your own vllm server with the datalab-to/chandra model
101
+ manager = InferenceManager(method="vllm")
102
+ batch = [
103
+ BatchInputItem(
104
+ image=PIL_IMAGE,
105
+ prompt_type="ocr_layout"
106
+ )
107
+ ]
108
+ result = manager.generate(batch)[0]
109
+ print(result.markdown)
110
+ ```
111
+
112
+ ### With transformers
113
+
114
+ ```python
115
+ from transformers import AutoModel, AutoProcessor
116
+ from chandra.model.hf import generate_hf
117
+ from chandra.model.schema import BatchInputItem
118
+ from chandra.output import parse_markdown
119
+
120
+ model = AutoModel.from_pretrained("datalab-to/chandra").cuda()
121
+ model.processor = AutoProcessor.from_pretrained("datalab-to/chandra")
122
+
123
+ batch = [
124
+ BatchInputItem(
125
+ image=PIL_IMAGE,
126
+ prompt_type="ocr_layout"
127
+ )
128
+ ]
129
+
130
+ result = generate_hf(batch, model)[0]
131
+ markdown = parse_markdown(result.raw)
132
+ ```
133
+
134
+ # Credits
135
+
136
+ Thank you to the following open source projects:
137
+
138
+ - [Huggingface Transformers](https://github.com/huggingface/transformers)
139
+ - [VLLM](https://github.com/vllm-project/vllm)
140
+ - [olmocr](github.com/allenai/olmocr)
141
+ - [Qwen 3 VL](https://github.com/QwenLM/Qwen3)
onnx/vpm.blocks.1.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.1.norm1.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.10.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.11.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.12.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.13.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.14.norm1.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.15.attn.proj.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.15.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.15.norm1.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.15.norm1.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.15.norm2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.16.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.16.norm2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.17.norm2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.18.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.19.attn.proj.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.19.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.19.norm1.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.19.norm2.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.20.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.20.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.20.norm1.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.21.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.22.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.22.norm1.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.23.attn.proj.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.24.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.24.norm1.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.25.attn.proj.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.25.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.25.norm1.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.26.norm2.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.3.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.3.norm2.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.4.attn.proj.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.4.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.4.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.4.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.5.norm1.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.6.attn.qkv.bias ADDED
Binary file (13.8 kB). View file
 
onnx/vpm.blocks.7.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.7.norm2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.7.norm2.weight ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.blocks.8.mlp.linear_fc1.bias ADDED
Binary file (17.2 kB). View file
 
onnx/vpm.blocks.9.mlp.linear_fc2.bias ADDED
Binary file (4.61 kB). View file
 
onnx/vpm.deepstack_merger_list.0.norm.weight ADDED
Binary file (18.4 kB). View file
 
onnx/vpm.merger.linear_fc1.bias ADDED
Binary file (18.4 kB). View file
 
onnx/vpm.merger.linear_fc2.bias ADDED
Binary file (16.4 kB). View file