Image-Text-to-Text
Transformers
Safetensors
PaddleOCR
English
Chinese
multilingual
paddleocr_vl
ERNIE4.5
PaddlePaddle
ocr
conversational
Instructions to use merve/PaddleOCR-VL-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use merve/PaddleOCR-VL-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="merve/PaddleOCR-VL-hf") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("merve/PaddleOCR-VL-hf") model = AutoModelForMultimodalLM.from_pretrained("merve/PaddleOCR-VL-hf", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PaddleOCR
How to use merve/PaddleOCR-VL-hf with PaddleOCR:
# Please refer to the document for information on how to use the model. # https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/module_usage/module_overview.html
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use merve/PaddleOCR-VL-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "merve/PaddleOCR-VL-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "merve/PaddleOCR-VL-hf", "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/merve/PaddleOCR-VL-hf
- SGLang
How to use merve/PaddleOCR-VL-hf 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 "merve/PaddleOCR-VL-hf" \ --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": "merve/PaddleOCR-VL-hf", "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 "merve/PaddleOCR-VL-hf" \ --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": "merve/PaddleOCR-VL-hf", "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 merve/PaddleOCR-VL-hf with Docker Model Runner:
docker model run hf.co/merve/PaddleOCR-VL-hf
Upload processor
Browse files- .gitattributes +1 -0
- chat_template.jinja +43 -0
- processor_config.json +32 -0
- tokenizer.json +3 -0
- tokenizer_config.json +27 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if not add_generation_prompt is defined -%}
|
| 2 |
+
{%- set add_generation_prompt = true -%}
|
| 3 |
+
{%- endif -%}
|
| 4 |
+
{%- if not cls_token is defined -%}
|
| 5 |
+
{%- set cls_token = "<|begin_of_sentence|>" -%}
|
| 6 |
+
{%- endif -%}
|
| 7 |
+
{%- if not eos_token is defined -%}
|
| 8 |
+
{%- set eos_token = "</s>" -%}
|
| 9 |
+
{%- endif -%}
|
| 10 |
+
{{- cls_token -}}
|
| 11 |
+
{%- for message in messages -%}
|
| 12 |
+
{%- if message["role"] == "user" -%}
|
| 13 |
+
{{- "User: " -}}
|
| 14 |
+
{%- for content in message["content"] -%}
|
| 15 |
+
{%- if content["type"] == "image" -%}
|
| 16 |
+
{{ "<|IMAGE_START|><|IMAGE_PLACEHOLDER|><|IMAGE_END|>" }}
|
| 17 |
+
{%- endif -%}
|
| 18 |
+
{%- endfor -%}
|
| 19 |
+
{%- for content in message["content"] -%}
|
| 20 |
+
{%- if content["type"] == "text" -%}
|
| 21 |
+
{{ content["text"] }}
|
| 22 |
+
{%- endif -%}
|
| 23 |
+
{%- endfor -%}
|
| 24 |
+
{{ "\n" -}}
|
| 25 |
+
{%- elif message["role"] == "assistant" -%}
|
| 26 |
+
{{- "Assistant: " -}}
|
| 27 |
+
{%- for content in message["content"] -%}
|
| 28 |
+
{%- if content["type"] == "text" -%}
|
| 29 |
+
{{ content["text"] }}
|
| 30 |
+
{%- endif -%}
|
| 31 |
+
{%- endfor -%}
|
| 32 |
+
{{ eos_token -}}
|
| 33 |
+
{%- elif message["role"] == "system" -%}
|
| 34 |
+
{%- for content in message["content"] -%}
|
| 35 |
+
{%- if content["type"] == "text" -%}
|
| 36 |
+
{{ content["text"] + "\n" }}
|
| 37 |
+
{%- endif -%}
|
| 38 |
+
{%- endfor -%}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{%- endfor -%}
|
| 41 |
+
{%- if add_generation_prompt -%}
|
| 42 |
+
{{- "Assistant: " -}}
|
| 43 |
+
{%- endif -%}
|
processor_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"do_convert_rgb": true,
|
| 5 |
+
"do_normalize": true,
|
| 6 |
+
"do_rescale": true,
|
| 7 |
+
"do_resize": true,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "PaddleOCRVLImageProcessorFast",
|
| 14 |
+
"image_std": [
|
| 15 |
+
0.5,
|
| 16 |
+
0.5,
|
| 17 |
+
0.5
|
| 18 |
+
],
|
| 19 |
+
"max_pixels": 2822400,
|
| 20 |
+
"merge_size": 2,
|
| 21 |
+
"min_pixels": 147384,
|
| 22 |
+
"patch_size": 14,
|
| 23 |
+
"resample": 3,
|
| 24 |
+
"rescale_factor": 0.00392156862745098,
|
| 25 |
+
"size": {
|
| 26 |
+
"longest_edge": 2822400,
|
| 27 |
+
"shortest_edge": 147384
|
| 28 |
+
},
|
| 29 |
+
"temporal_patch_size": 1
|
| 30 |
+
},
|
| 31 |
+
"processor_class": "PaddleOCRVLProcessor"
|
| 32 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f90f04fd8e5eb6dfa380f37d10c87392de8438dccb6768a2486b5a96ee76dba6
|
| 3 |
+
size 11187679
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"AutoProcessor": "processing_paddleocr_vl.PaddleOCRVLProcessor"
|
| 5 |
+
},
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": "<s>",
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"cls_token": "<|begin_of_sentence|>",
|
| 10 |
+
"eos_token": "</s>",
|
| 11 |
+
"image_token": "<|IMAGE_PLACEHOLDER|>",
|
| 12 |
+
"is_local": true,
|
| 13 |
+
"legacy": true,
|
| 14 |
+
"mask_token": "<mask:1>",
|
| 15 |
+
"model_max_length": 131072,
|
| 16 |
+
"model_specific_special_tokens": {
|
| 17 |
+
"image_token": "<|IMAGE_PLACEHOLDER|>"
|
| 18 |
+
},
|
| 19 |
+
"pad_token": "<unk>",
|
| 20 |
+
"processor_class": "PaddleOCRVLProcessor",
|
| 21 |
+
"sep_token": "<|end_of_sentence|>",
|
| 22 |
+
"sp_model_kwargs": {},
|
| 23 |
+
"spaces_between_special_tokens": false,
|
| 24 |
+
"tokenizer_class": "TokenizersBackend",
|
| 25 |
+
"unk_token": "<unk>",
|
| 26 |
+
"use_default_system_prompt": false
|
| 27 |
+
}
|