Image-Text-to-Text
Transformers
Safetensors
MLX
multilingual
hunyuan_vl
text-generation
ocr
hunyuan
vision-language
image-to-text
1B
end-to-end
conversational
Instructions to use hadeseus/HunyuanOCR-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hadeseus/HunyuanOCR-mlx with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="hadeseus/HunyuanOCR-mlx") 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 AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("hadeseus/HunyuanOCR-mlx", dtype="auto") - MLX
How to use hadeseus/HunyuanOCR-mlx with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("hadeseus/HunyuanOCR-mlx") config = load_config("hadeseus/HunyuanOCR-mlx") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
- vLLM
How to use hadeseus/HunyuanOCR-mlx with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hadeseus/HunyuanOCR-mlx" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hadeseus/HunyuanOCR-mlx", "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/hadeseus/HunyuanOCR-mlx
- SGLang
How to use hadeseus/HunyuanOCR-mlx 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 "hadeseus/HunyuanOCR-mlx" \ --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": "hadeseus/HunyuanOCR-mlx", "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 "hadeseus/HunyuanOCR-mlx" \ --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": "hadeseus/HunyuanOCR-mlx", "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 hadeseus/HunyuanOCR-mlx with Docker Model Runner:
docker model run hf.co/hadeseus/HunyuanOCR-mlx
| { | |
| "architectures": [ | |
| "HunYuanVLForConditionalGeneration" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "attention_head_dim": 128, | |
| "bos_token_id": 120000, | |
| "dtype": "bfloat16", | |
| "eod_token_id": 120020, | |
| "eos_token_id": [ | |
| 120007, | |
| 120020 | |
| ], | |
| "head_dim": 128, | |
| "hidden_act": "silu", | |
| "hidden_size": 1024, | |
| "image_end_token_id": 120119, | |
| "image_newline_token_id": 120121, | |
| "image_start_token_id": 120118, | |
| "image_token_id": 120120, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 3584, | |
| "max_position_embeddings": 32768, | |
| "mlp_bias": false, | |
| "model_type": "hunyuan_vl", | |
| "norm_type": "rms", | |
| "num_attention_heads": 16, | |
| "num_experts": 1, | |
| "num_hidden_layers": 24, | |
| "num_key_value_heads": 8, | |
| "org_vocab_size": 120818, | |
| "pad_id": 120002, | |
| "pad_token_id": -1, | |
| "pretraining_tp": 1, | |
| "rms_norm_eps": 1e-05, | |
| "rope_scaling": { | |
| "alpha": 1000.0, | |
| "beta_fast": 32, | |
| "beta_slow": 1, | |
| "factor": 1.0, | |
| "mscale": 1.0, | |
| "mscale_all_dim": 1.0, | |
| "type": "xdrope", | |
| "xdrope_section": [ | |
| 16, | |
| 16, | |
| 16, | |
| 16 | |
| ] | |
| }, | |
| "rope_theta": 10000.0, | |
| "routed_scaling_factor": 1.0, | |
| "sep_token_id": 0, | |
| "text_end_id": 8, | |
| "text_start_id": 7, | |
| "tie_word_embeddings": true, | |
| "transformers_version": "4.49.0", | |
| "use_cache": true, | |
| "use_cla": false, | |
| "use_qk_norm": true, | |
| "vision_config": { | |
| "add_patchemb_bias": true, | |
| "attention_dropout": 0.0, | |
| "cat_extra_token": 1, | |
| "hidden_act": "gelu", | |
| "hidden_dropout": 0.0, | |
| "hidden_size": 1152, | |
| "img_max_token_num": 4096, | |
| "intermediate_size": 4304, | |
| "interpolate_mode": "bilinear", | |
| "max_image_size": 2048, | |
| "max_vit_seq_len": 16384, | |
| "num_attention_heads": 16, | |
| "num_channels": 3, | |
| "num_hidden_layers": 27, | |
| "out_hidden_size": 1024, | |
| "patch_size": 16, | |
| "rms_norm_eps": 1e-05, | |
| "spatial_merge_size": 2 | |
| }, | |
| "vocab_size": 120818 | |
| } |