Image-Text-to-Text
PaddleOCR
Safetensors
English
Chinese
multilingual
paddleocr_vl
ERNIE4.5
PaddlePaddle
image-to-text
ocr
document-parse
layout
table
formula
chart
conversational
custom_code
Eval Results
Instructions to use PaddlePaddle/PaddleOCR-VL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PaddleOCR
How to use PaddlePaddle/PaddleOCR-VL with PaddleOCR:
# See https://www.paddleocr.ai/latest/version3.x/pipeline_usage/PaddleOCR-VL.html to installation from paddleocr import PaddleOCRVL pipeline = PaddleOCRVL(pipeline_version="v1") output = pipeline.predict("path/to/document_image.png") for res in output: res.print() res.save_to_json(save_path="output") res.save_to_markdown(save_path="output") - Notebooks
- Google Colab
- Kaggle
docs: Readme Updated for optimized Usage with transformers library (#60)
Browse files- docs: Readme Updated for optimized Usage with transformers library (1787ca52c80733e53e8bc59b5b8b3aa9ee7f7018)
- update (4fe79f670d8ec01d412f85db24881a50e732378e)
- update (d7d1f3777c5f5dc95028e0e4bad350d88d214f7d)
- update (e9b397128dde328b68890f838538606f9ab55999)
- merge (f96dabf21b5f97deeb1636adfcfb0d5987de71bf)
Co-authored-by: Sayed Gamal <sayed99@users.noreply.huggingface.co>
Files changed (2)
- README.md+76-5
- image_processing.py+6
72 unmodified lines73747576777887 unmodified lines1661671681691701711721731741 unmodified line1761771781791801811821835 unmodified lines1891901911921931941952 unmodified lines1981992002012022032041 unmodified line20620720820921021172 unmodified lines## News* ```2025.11.04``` π PaddleOCR-VL-0.9B is now officially supported on `vLLM` .* ```2025.10.29``` π€ Supports calling the core module PaddleOCR-VL-0.9B of PaddleOCR-VL via the `transformers` library.* ```2025.10.16``` π We release [PaddleOCR-VL](https://github.com/PaddlePaddle/PaddleOCR), β a multilingual documents parsing via a 0.9B Ultra-Compact Vision-Language Model with SOTA performance.87 unmodified linesimport torchfrom transformers import AutoModelForCausalLM, AutoProcessorDEVICE = "cuda" if torch.cuda.is_available() else "cpu"CHOSEN_TASK = "ocr" # Options: 'ocr' | 'table' | 'chart' | 'formula'PROMPTS = {"ocr": "OCR:","table": "Table Recognition:",1 unmodified line"chart": "Chart Recognition:",}model_path = "PaddlePaddle/PaddleOCR-VL"image_path = "test.png"image = Image.open(image_path).convert("RGB")model = AutoModelForCausalLM.from_pretrained(5 unmodified lines{"role": "user","content": [{"type": "image", "image": image},{"type": "text", "text": PROMPTS[CHOSEN_TASK]},]}]2 unmodified linestokenize=True,add_generation_prompt=True,return_dict=True,return_tensors="pt").to(DEVICE)outputs = model.generate(**inputs, max_new_tokens=1024)1 unmodified lineprint(outputs)```## Performance### Page-Level Document Parsing72 unmodified lines7374757677787987 unmodified lines1671681691701711721731741751761771781791801 unmodified line1821831841851861875 unmodified lines1931941951961971981992 unmodified lines2022032042052062072081 unmodified line21021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128272 unmodified lines## News* ```2025.11.07``` π Enabled `flash-attn` in the `transformers` library to achieve faster inference with PaddleOCR-VL-0.9B.* ```2025.11.04``` π PaddleOCR-VL-0.9B is now officially supported on `vLLM` .* ```2025.10.29``` π€ Supports calling the core module PaddleOCR-VL-0.9B of PaddleOCR-VL via the `transformers` library.* ```2025.10.16``` π We release [PaddleOCR-VL](https://github.com/PaddlePaddle/PaddleOCR), β a multilingual documents parsing via a 0.9B Ultra-Compact Vision-Language Model with SOTA performance.87 unmodified linesimport torchfrom transformers import AutoModelForCausalLM, AutoProcessor# ---- Settings ----model_path = "PaddlePaddle/PaddleOCR-VL"image_path = "test.png"task = "ocr" # Options: 'ocr' | 'table' | 'chart' | 'formula'# ------------------DEVICE = "cuda" if torch.cuda.is_available() else "cpu"PROMPTS = {"ocr": "OCR:","table": "Table Recognition:",1 unmodified line"chart": "Chart Recognition:",}image = Image.open(image_path).convert("RGB")model = AutoModelForCausalLM.from_pretrained(5 unmodified lines{"role": "user","content": [{"type": "image", "image": image},{"type": "text", "text": PROMPTS[task]},]}]2 unmodified linestokenize=True,add_generation_prompt=True,return_dict=True,return_tensors="pt").to(DEVICE)outputs = model.generate(**inputs, max_new_tokens=1024)1 unmodified lineprint(outputs)```<details><summary>π Click to expand: Use flash-attn to boost performance and reduce memory usage</summary>```shell# ensure the flash-attn2 is installedpip install flash-attn --no-build-isolation``````pythonimport torchfrom transformers import AutoModelForCausalLM, AutoProcessorfrom PIL import Image# ---- Settings ----model_path = "PaddlePaddle/PaddleOCR-VL"image_path = "test.png"task = "ocr" # β change to "table" | "chart" | "formula"# ------------------DEVICE = "cuda" if torch.cuda.is_available() else "cpu"model = AutoModelForCausalLM.from_pretrained(model_path,trust_remote_code=True,torch_dtype=torch.bfloat16,attn_implementation="flash_attention_2",).to(dtype=torch.bfloat16, device=DEVICE).eval()processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)PROMPTS = {"ocr": "OCR:","table": "Table Recognition:","chart": "Chart Recognition:","formula": "Formula Recognition:",}messages = [{"role": "user","content": [{"type": "image", "image": Image.open(image_path).convert("RGB")},{"type": "text", "text": PROMPTS[task]}]}]inputs = processor.apply_chat_template(messages,tokenize=True,add_generation_prompt=True,return_dict=True,return_tensors="pt").to(DEVICE)with torch.inference_mode():out = model.generate(**inputs,max_new_tokens=1024,do_sample=False,use_cache=True)outputs = processor.batch_decode(out, skip_special_tokens=True)[0]print(outputs)```</details>## Performance### Page-Level Document Parsing
140 unmodified lines141142143144145146147148149150151152140 unmodified lines3. The aspect ratio of the image is maintained as closely as possible."""if height < factor:width = round((width * factor) / height)height = factorif width < factor:height = round((height * factor) / width)width = factor140 unmodified lines141142143144145146147148149150151152153154155156157158140 unmodified lines3. The aspect ratio of the image is maintained as closely as possible."""# if height < factor or width < factor:# raise ValueError(f"height:{height} or width:{width} must be larger than factor:{factor}")# if int(height < factor//4) + int(width < factor//4):# raise ValueError(f"height:{height} or width:{width} must be larger than factor:{factor//4}")if height < factor:print(f"smart_resize: height={height} < factor={factor}, reset height=factor")width = round((width * factor) / height)height = factorif width < factor:print(f"smart_resize: width={width} < factor={factor}, reset width=factor")height = round((height * factor) / width)width = factor
README.md+76-5
image_processing.py+6