Image-Text-to-Text
Safetensors
Transformers
English
Chinese
multilingual
dots_ocr
text-generation
image-to-text
ocr
document-parse
layout
table
formula
custom_code
conversational
Eval Results
Instructions to use rednote-hilab/dots.ocr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rednote-hilab/dots.ocr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="rednote-hilab/dots.ocr", trust_remote_code=True) 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 AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("rednote-hilab/dots.ocr", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rednote-hilab/dots.ocr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rednote-hilab/dots.ocr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rednote-hilab/dots.ocr", "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/rednote-hilab/dots.ocr
- SGLang
How to use rednote-hilab/dots.ocr 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 "rednote-hilab/dots.ocr" \ --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": "rednote-hilab/dots.ocr", "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 "rednote-hilab/dots.ocr" \ --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": "rednote-hilab/dots.ocr", "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 rednote-hilab/dots.ocr with Docker Model Runner:
docker model run hf.co/rednote-hilab/dots.ocr
fix autoprocessor
#30
by kingsley01 - opened
- configuration_dots.py +3 -1
- preprocessor_config.json +3 -0
configuration_dots.py
CHANGED
|
@@ -3,6 +3,7 @@ from transformers.configuration_utils import PretrainedConfig
|
|
| 3 |
from transformers.models.qwen2 import Qwen2Config
|
| 4 |
from transformers import Qwen2_5_VLProcessor, AutoProcessor
|
| 5 |
from transformers.models.auto.configuration_auto import CONFIG_MAPPING
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
class DotsVisionConfig(PretrainedConfig):
|
|
@@ -68,7 +69,8 @@ class DotsOCRConfig(Qwen2Config):
|
|
| 68 |
|
| 69 |
class DotsVLProcessor(Qwen2_5_VLProcessor):
|
| 70 |
def __init__(self, image_processor=None, tokenizer=None, chat_template=None, **kwargs):
|
| 71 |
-
|
|
|
|
| 72 |
self.image_token = "<|imgpad|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
|
| 73 |
|
| 74 |
|
|
|
|
| 3 |
from transformers.models.qwen2 import Qwen2Config
|
| 4 |
from transformers import Qwen2_5_VLProcessor, AutoProcessor
|
| 5 |
from transformers.models.auto.configuration_auto import CONFIG_MAPPING
|
| 6 |
+
from transformers.video_processing_utils import BaseVideoProcessor
|
| 7 |
|
| 8 |
|
| 9 |
class DotsVisionConfig(PretrainedConfig):
|
|
|
|
| 69 |
|
| 70 |
class DotsVLProcessor(Qwen2_5_VLProcessor):
|
| 71 |
def __init__(self, image_processor=None, tokenizer=None, chat_template=None, **kwargs):
|
| 72 |
+
dummy_processor = BaseVideoProcessor()
|
| 73 |
+
super().__init__(image_processor, tokenizer, video_processor=dummy_processor, chat_template=chat_template)
|
| 74 |
self.image_token = "<|imgpad|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
|
| 75 |
|
| 76 |
|
preprocessor_config.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
{
|
|
|
|
|
|
|
|
|
|
| 2 |
"min_pixels": 3136,
|
| 3 |
"max_pixels": 11289600,
|
| 4 |
"patch_size": 14,
|
|
|
|
| 1 |
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoProcessor": "configuration_dots.DotsVLProcessor"
|
| 4 |
+
},
|
| 5 |
"min_pixels": 3136,
|
| 6 |
"max_pixels": 11289600,
|
| 7 |
"patch_size": 14,
|