Image-Text-to-Text
Transformers
Safetensors
multilingual
English
Chinese
hunyuan_vl
ocr
vision-language-model
document-parsing
text-spotting
information-extraction
text-image-translation
conversational
Eval Results
Instructions to use tencent/HunyuanOCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tencent/HunyuanOCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tencent/HunyuanOCR") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("tencent/HunyuanOCR") model = AutoModelForMultimodalLM.from_pretrained("tencent/HunyuanOCR", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tencent/HunyuanOCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tencent/HunyuanOCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/HunyuanOCR", "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/tencent/HunyuanOCR
- SGLang
How to use tencent/HunyuanOCR 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 "tencent/HunyuanOCR" \ --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": "tencent/HunyuanOCR", "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 "tencent/HunyuanOCR" \ --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": "tencent/HunyuanOCR", "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 tencent/HunyuanOCR with Docker Model Runner:
docker model run hf.co/tencent/HunyuanOCR
Commit History
-
Update README.md
Verified signature3a5ad2d -
Update README (#6)
Verified signature- Update README (905a9fa416d5a5bb38fe26fb3413492914ab0a05) Co-authored-by: Ethannwan <EthannW@users.noreply.huggingface.co>7502740 -
Update README (#5)
Verified signature- Update README (11cce4750eedc4498ec026765a0037e47ce564ec) Co-authored-by: Ethannwan <EthannW@users.noreply.huggingface.co>7d53690
-
Update README.md
Verified signature885259f -
Update README.md
Verified signatured420772 -
Update generation_config.json
Verified signatureff93505 -
Change Title link (#2)
Verified signature- Change Title link (76081691fb97261dc4f579467a9b9da6be82320b) Co-authored-by: Ethannwan <EthannW@users.noreply.huggingface.co>ea397eb -
Update README (#1)
Verified signature- Update README (270e3f4a7c9e6f90d8a40049418dd74a1c22e8e9) Co-authored-by: Ethannwan <EthannW@users.noreply.huggingface.co>b28a172 -
Update README.md
Verified signaturec3bf532 -
Update README.md
Verified signature5bf2a1f
-
Update README.md
Verified signature4be5a16 -
Update README.md
Verified signaturee6bffef -
Update generation_config.json
Verified signaturebe60548 -
Update README.md
Verified signature8ffabbf -
Update README.md
Verified signature95b9278 -
Update README.md
Verified signature1ff0d18 -
Update README.md
Verified signature45f0473 -
Update README.md
Verified signatureeb4cfe8 -
Create README.md
Verified signature7b81346 -
Create LICENSE
Verified signaturef4cfd25
-
Upload tokenizer_config.json with huggingface_hub
Verified signature5a2a550 -
Upload preprocessor_config.json with huggingface_hub
Verified signature7fe1eae -
Upload config.json with huggingface_hub
Verified signature3aa00f1
-
Update config.json
Verified signature6c238ab -
Update config.json
Verified signatureb003ccd -
Update config.json
Verified signature3b83bf8 -
Update config.json
Verified signature8484eda -
Update config.json
Verified signature1437903
-
Update config.json
Verified signature80d1f30
-
Update tokenizer_config.json
Verified signature58867c0 -
Update preprocessor_config.json
Verified signature5a4e089 -
Update config.json
Verified signature6e3eb00 -
Upload tokenizer_config.json with huggingface_hub
Verified signature1d54202 -
Upload tokenizer.json with huggingface_hub
Verified signature03ae940 -
Upload special_tokens_map.json with huggingface_hub
Verified signatured8dee9a -
Upload preprocessor_config.json with huggingface_hub
Verified signature651da48 -
Upload model.safetensors.index.json with huggingface_hub
Verified signaturedebf6ff -
Upload model-00004-of-00004.safetensors with huggingface_hub
Verified signature9c3111a -
Upload model-00003-of-00004.safetensors with huggingface_hub
Verified signature00a8012 -
Upload model-00002-of-00004.safetensors with huggingface_hub
Verified signaturea013d66 -
Upload model-00001-of-00004.safetensors with huggingface_hub
Verified signature6eca78f -
Upload generation_config.json with huggingface_hub
Verified signatureb5e90a6 -
Upload config.json with huggingface_hub
Verified signaturee4fff5d -
Upload .gitignore with huggingface_hub
Verified signature62be2c6 -
initial commit
Verified signature3278ca4