Instructions to use strangervisionhf/deepseek-ocr-2-transformers-v4.57.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use strangervisionhf/deepseek-ocr-2-transformers-v4.57.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use strangervisionhf/deepseek-ocr-2-transformers-v4.57.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/strangervisionhf/deepseek-ocr-2-transformers-v4.57.1
- SGLang
How to use strangervisionhf/deepseek-ocr-2-transformers-v4.57.1 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 "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use strangervisionhf/deepseek-ocr-2-transformers-v4.57.1 with Docker Model Runner:
docker model run hf.co/strangervisionhf/deepseek-ocr-2-transformers-v4.57.1
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", trust_remote_code=True, dtype="auto")This is a copy of the model weights from the https://huggingface.co/deepseek-ai/DeepSeek-OCR-2 model. These weights cannot be used for other purposes. If you wish to do so, please visit the original model page.
Previously, inference with the model https://huggingface.co/deepseek-ai/DeepSeek-OCR-2 ran smoothly on transformers==4.46.3. However, running it on newer versions of transformers caused compatibility issues. We have identified and fixed the problem, and the model now runs smoothly with the latest transformers (v4.57.1) and other compatible versions.
This page includes the updated model weights and corrected configuration, which resolve the issue and allow transformers inference to run smoothly.
Last updated: 11:50 AM (IST), February 12, 2026.
Quick Start with Transformers
Install the required packages
torch
torchvision
transformers==4.57.1
accelerate
matplotlib
einops
addict
easydict
Usage
from transformers import AutoModel, AutoTokenizer
import torch
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0'
model_name = 'strangervisionhf/deepseek-ocr-2-transformers-v4.57.1'
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModel.from_pretrained(model_name,
#_attn_implementation='flash_attention_2',
trust_remote_code=True,
use_safetensors=True)
model = model.eval().cuda().to(torch.bfloat16)
# prompt = "<image>\nFree OCR. "
prompt = "<image>\n<|grounding|>Convert the document to markdown. "
image_file = 'your_image.jpg'
output_path = 'your/output/dir'
res = model.infer(tokenizer, prompt=prompt, image_file=image_file, output_path = output_path, base_size = 1024, image_size = 768, crop_mode=True, save_results = True)
- Downloads last month
- 12
Model tree for strangervisionhf/deepseek-ocr-2-transformers-v4.57.1
Base model
deepseek-ai/DeepSeek-OCR-2
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="strangervisionhf/deepseek-ocr-2-transformers-v4.57.1", trust_remote_code=True)