Image-Text-to-Text
Transformers
Safetensors
qwen3_5
ocr
pdf
markdown
layout
conversational
Eval Results
Instructions to use datalab-to/surya-ocr-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use datalab-to/surya-ocr-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="datalab-to/surya-ocr-2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("datalab-to/surya-ocr-2") model = AutoModelForImageTextToText.from_pretrained("datalab-to/surya-ocr-2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use datalab-to/surya-ocr-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "datalab-to/surya-ocr-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/surya-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/datalab-to/surya-ocr-2
- SGLang
How to use datalab-to/surya-ocr-2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "datalab-to/surya-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/surya-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "datalab-to/surya-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/surya-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use datalab-to/surya-ocr-2 with Docker Model Runner:
docker model run hf.co/datalab-to/surya-ocr-2
Move 28 demo images into assets/ subfolder
Browse files- README.md +10 -21
- corporate.png → assets/corporate.png +0 -0
- corporate_layout.png → assets/corporate_layout.png +0 -0
- corporate_reading.png → assets/corporate_reading.png +0 -0
- corporate_tablerec.png → assets/corporate_tablerec.png +0 -0
- corporate_text.png → assets/corporate_text.png +0 -0
- excerpt.png → assets/excerpt.png +0 -0
- excerpt_layout.png → assets/excerpt_layout.png +0 -0
- excerpt_text.png → assets/excerpt_text.png +0 -0
- form.png → assets/form.png +0 -0
- form_layout.png → assets/form_layout.png +0 -0
- form_reading.png → assets/form_reading.png +0 -0
- form_tablerec.png → assets/form_tablerec.png +0 -0
- form_text.png → assets/form_text.png +0 -0
- handwritten.png → assets/handwritten.png +0 -0
- handwritten_layout.png → assets/handwritten_layout.png +0 -0
- handwritten_reading.png → assets/handwritten_reading.png +0 -0
- handwritten_tablerec.png → assets/handwritten_tablerec.png +0 -0
- handwritten_text.png → assets/handwritten_text.png +0 -0
- newspaper.png → assets/newspaper.png +0 -0
- newspaper_layout.png → assets/newspaper_layout.png +0 -0
- newspaper_reading.png → assets/newspaper_reading.png +0 -0
- newspaper_text.png → assets/newspaper_text.png +0 -0
- olmocr_size_chart.png → assets/olmocr_size_chart.png +0 -0
- scanned_tablerec.png → assets/scanned_tablerec.png +0 -0
- textbook.png → assets/textbook.png +0 -0
- textbook_layout.png → assets/textbook_layout.png +0 -0
- textbook_reading.png → assets/textbook_reading.png +0 -0
- textbook_text.png → assets/textbook_text.png +0 -0
README.md
CHANGED
|
@@ -1,14 +1,3 @@
|
|
| 1 |
-
---
|
| 2 |
-
library_name: transformers
|
| 3 |
-
license: openrail
|
| 4 |
-
license_link: LICENSE
|
| 5 |
-
tags:
|
| 6 |
-
- ocr
|
| 7 |
-
- pdf
|
| 8 |
-
- markdown
|
| 9 |
-
- layout
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
<h1 align="center">Datalab</h1>
|
| 13 |
<p align="center">
|
| 14 |
<strong>State of the Art models for Document Intelligence</strong>
|
|
@@ -48,16 +37,16 @@ Commercial self-hosting of the model weights requires a license — see [Commerc
|
|
| 48 |
|
| 49 |
## Model Information
|
| 50 |
|
| 51 |
-
<img src="olmocr_size_chart.png" width="700"/>
|
| 52 |
|
| 53 |
|
| 54 |
| Detection | OCR |
|
| 55 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 56 |
-
| <img src="excerpt.png" width="280"/> | <img src="excerpt_text.png" width="280"/> |
|
| 57 |
|
| 58 |
| Layout | Table Recognition |
|
| 59 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 60 |
-
| <img src="excerpt_layout.png" width="280"/> | <img src="scanned_tablerec.png" width="280"/> |
|
| 61 |
|
| 62 |
|
| 63 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
|
@@ -68,11 +57,11 @@ Each row links to five annotated views of the same page: text-line detection, OC
|
|
| 68 |
|
| 69 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 70 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 71 |
-
| Newspaper | [Image](newspaper.png) | [Image](newspaper_text.png) | [Image](newspaper_layout.png) | [Image](newspaper_reading.png) | |
|
| 72 |
-
| Textbook | [Image](textbook.png) | [Image](textbook_text.png) | [Image](textbook_layout.png) | [Image](textbook_reading.png) | |
|
| 73 |
-
| Tax Form | [Image](form.png) | [Image](form_text.png) | [Image](form_layout.png) | [Image](form_reading.png) | [Image](form_tablerec.png) |
|
| 74 |
-
| Handwritten Notes | [Image](handwritten.png) | [Image](handwritten_text.png) | [Image](handwritten_layout.png) | [Image](handwritten_reading.png) | [Image](handwritten_tablerec.png) |
|
| 75 |
-
| Corporate Doc | [Image](corporate.png) | [Image](corporate_text.png) | [Image](corporate_layout.png) | [Image](corporate_reading.png) | [Image](corporate_tablerec.png) |
|
| 76 |
|
| 77 |
# Commercial usage
|
| 78 |
|
|
@@ -364,7 +353,7 @@ standard quality benchmark for document parsers.
|
|
| 364 |
|
| 365 |
## olmOCR-bench
|
| 366 |
|
| 367 |
-
|
| 368 |
|
| 369 |
| Model | Params | Score |
|
| 370 |
|-----------------------------|----------:|---------:|
|
|
@@ -416,7 +405,7 @@ Top 15 widely-spoken languages:
|
|
| 416 |
| `es` | Spanish | 90.7% |
|
| 417 |
| `vi` | Vietnamese | 73.2% |
|
| 418 |
|
| 419 |
-
See [https://github.com/datalab-to/surya/blob/
|
| 420 |
|
| 421 |
## Throughput
|
| 422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<h1 align="center">Datalab</h1>
|
| 2 |
<p align="center">
|
| 3 |
<strong>State of the Art models for Document Intelligence</strong>
|
|
|
|
| 37 |
|
| 38 |
## Model Information
|
| 39 |
|
| 40 |
+
<img src="assets/olmocr_size_chart.png" width="700"/>
|
| 41 |
|
| 42 |
|
| 43 |
| Detection | OCR |
|
| 44 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 45 |
+
| <img src="assets/excerpt.png" width="280"/> | <img src="assets/excerpt_text.png" width="280"/> |
|
| 46 |
|
| 47 |
| Layout | Table Recognition |
|
| 48 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 49 |
+
| <img src="assets/excerpt_layout.png" width="280"/> | <img src="assets/scanned_tablerec.png" width="280"/> |
|
| 50 |
|
| 51 |
|
| 52 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
|
|
|
| 57 |
|
| 58 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 59 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 60 |
+
| Newspaper | [Image](assets/newspaper.png) | [Image](assets/newspaper_text.png) | [Image](assets/newspaper_layout.png) | [Image](assets/newspaper_reading.png) | |
|
| 61 |
+
| Textbook | [Image](assets/textbook.png) | [Image](assets/textbook_text.png) | [Image](assets/textbook_layout.png) | [Image](assets/textbook_reading.png) | |
|
| 62 |
+
| Tax Form | [Image](assets/form.png) | [Image](assets/form_text.png) | [Image](assets/form_layout.png) | [Image](assets/form_reading.png) | [Image](assets/form_tablerec.png) |
|
| 63 |
+
| Handwritten Notes | [Image](assets/handwritten.png) | [Image](assets/handwritten_text.png) | [Image](assets/handwritten_layout.png) | [Image](assets/handwritten_reading.png) | [Image](assets/handwritten_tablerec.png) |
|
| 64 |
+
| Corporate Doc | [Image](assets/corporate.png) | [Image](assets/corporate_text.png) | [Image](assets/corporate_layout.png) | [Image](assets/corporate_reading.png) | [Image](assets/corporate_tablerec.png) |
|
| 65 |
|
| 66 |
# Commercial usage
|
| 67 |
|
|
|
|
| 353 |
|
| 354 |
## olmOCR-bench
|
| 355 |
|
| 356 |
+
Pareto-optimal on the size-vs-score frontier, and best in class under 3B params.
|
| 357 |
|
| 358 |
| Model | Params | Score |
|
| 359 |
|-----------------------------|----------:|---------:|
|
|
|
|
| 405 |
| `es` | Spanish | 90.7% |
|
| 406 |
| `vi` | Vietnamese | 73.2% |
|
| 407 |
|
| 408 |
+
See [https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md](https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md) for the full 91-language table.
|
| 409 |
|
| 410 |
## Throughput
|
| 411 |
|
corporate.png → assets/corporate.png
RENAMED
|
File without changes
|
corporate_layout.png → assets/corporate_layout.png
RENAMED
|
File without changes
|
corporate_reading.png → assets/corporate_reading.png
RENAMED
|
File without changes
|
corporate_tablerec.png → assets/corporate_tablerec.png
RENAMED
|
File without changes
|
corporate_text.png → assets/corporate_text.png
RENAMED
|
File without changes
|
excerpt.png → assets/excerpt.png
RENAMED
|
File without changes
|
excerpt_layout.png → assets/excerpt_layout.png
RENAMED
|
File without changes
|
excerpt_text.png → assets/excerpt_text.png
RENAMED
|
File without changes
|
form.png → assets/form.png
RENAMED
|
File without changes
|
form_layout.png → assets/form_layout.png
RENAMED
|
File without changes
|
form_reading.png → assets/form_reading.png
RENAMED
|
File without changes
|
form_tablerec.png → assets/form_tablerec.png
RENAMED
|
File without changes
|
form_text.png → assets/form_text.png
RENAMED
|
File without changes
|
handwritten.png → assets/handwritten.png
RENAMED
|
File without changes
|
handwritten_layout.png → assets/handwritten_layout.png
RENAMED
|
File without changes
|
handwritten_reading.png → assets/handwritten_reading.png
RENAMED
|
File without changes
|
handwritten_tablerec.png → assets/handwritten_tablerec.png
RENAMED
|
File without changes
|
handwritten_text.png → assets/handwritten_text.png
RENAMED
|
File without changes
|
newspaper.png → assets/newspaper.png
RENAMED
|
File without changes
|
newspaper_layout.png → assets/newspaper_layout.png
RENAMED
|
File without changes
|
newspaper_reading.png → assets/newspaper_reading.png
RENAMED
|
File without changes
|
newspaper_text.png → assets/newspaper_text.png
RENAMED
|
File without changes
|
olmocr_size_chart.png → assets/olmocr_size_chart.png
RENAMED
|
File without changes
|
scanned_tablerec.png → assets/scanned_tablerec.png
RENAMED
|
File without changes
|
textbook.png → assets/textbook.png
RENAMED
|
File without changes
|
textbook_layout.png → assets/textbook_layout.png
RENAMED
|
File without changes
|
textbook_reading.png → assets/textbook_reading.png
RENAMED
|
File without changes
|
textbook_text.png → assets/textbook_text.png
RENAMED
|
File without changes
|