Image-Text-to-Text
MiniCPM-OCR
English
Chinese
minicpm_ocr
ocr
document-parsing
multimodal
vision-language
table-recognition
formula-recognition
conversational
Instructions to use FastFlowLM/MiniCPM-OCR-1.0-NPU2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MiniCPM-OCR
How to use FastFlowLM/MiniCPM-OCR-1.0-NPU2 with MiniCPM-OCR:
pip install "minicpm-ocr[all]" huggingface_hub # Deploy FastFlowLM/MiniCPM-OCR-1.0-NPU2 as a recognition service before running the Python example: # https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/vllm_deploy_en.md # vLLM: load the model above; use --port 8080, # --served-model-name minicpm-ocr and --max-model-len 40960. # Layout detection uses cuda:0; recognition runs on the deployed service.
from importlib.resources import files from pathlib import Path from minicpmvocr import load_config, pipelined_run from huggingface_hub import snapshot_download layout_model = snapshot_download("PaddlePaddle/PP-DocLayoutV3") cfg = load_config( str(files("minicpmvocr").joinpath("configs/minicpmvocr.yaml")), overrides={ "input": {"file_path": str(Path("demo.png").resolve())}, "engine": { "type": "vllm", "server_url": "http://127.0.0.1:8080", "model_name": "minicpm-ocr", "max_model_len": 40960, }, "layout": {"model_dir": layout_model, "device": "cuda:0"}, # Render PDFs in-process so this example also works without a main guard. "pipeline": {"overlap_layout": True, "render_workers": 1}, }, ) pipelined_run(cfg) - Notebooks
- Google Colab
- Kaggle
Download tokenizer_config.json from FastFlowLM/MiniCPM-OCR-1.0-NPU2: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/FastFlowLM/MiniCPM-OCR-1.0-NPU2/resolve/main/tokenizer_config.json
- Command line
-
hf download hf://FastFlowLM/MiniCPM-OCR-1.0-NPU2/tokenizer_config.json
-
curl -L -o tokenizer_config.json https://huggingface.co/FastFlowLM/MiniCPM-OCR-1.0-NPU2/resolve/main/tokenizer_config.json
1.54 kB
| { | |
| "add_prefix_space": false, | |
| "audio_bos_token": "<|audio_start|>", | |
| "audio_eos_token": "<|audio_end|>", | |
| "audio_token": "<|audio_pad|>", | |
| "backend": "tokenizers", | |
| "bos_token": "<|im_start|>", | |
| "clean_up_tokenization_spaces": false, | |
| "eos_token": "<|im_end|>", | |
| "errors": "replace", | |
| "extra_special_tokens": { | |
| "image_token": "<|image_pad|>", | |
| "video_token": "<|video_pad|>", | |
| "image_start_token": "<image>", | |
| "image_end_token": "</image>", | |
| "slice_start_token": "<slice>", | |
| "slice_end_token": "</slice>", | |
| "image_id_start_token": "<image_id>", | |
| "image_id_end_token": "</image_id>" | |
| }, | |
| "image_token": "<|image_pad|>", | |
| "model_max_length": 262144, | |
| "model_specific_special_tokens": { | |
| "audio_bos_token": "<|audio_start|>", | |
| "audio_eos_token": "<|audio_end|>", | |
| "audio_token": "<|audio_pad|>", | |
| "image_token": "<|image_pad|>", | |
| "video_token": "<|video_pad|>", | |
| "vision_bos_token": "<|vision_start|>", | |
| "vision_eos_token": "<|vision_end|>" | |
| }, | |
| "pad_token": "<|endoftext|>", | |
| "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+", | |
| "processor_class": "MiniCPMOcrProcessor", | |
| "split_special_tokens": false, | |
| "tokenizer_class": "TokenizersBackend", | |
| "unk_token": "<unk>", | |
| "video_token": "<|video_pad|>", | |
| "vision_bos_token": "<|vision_start|>", | |
| "vision_eos_token": "<|vision_end|>", | |
| "bos_token_id": 248045, | |
| "eos_token_id": [ | |
| 248044, | |
| 248046 | |
| ] | |
| } | |