### Install PaddleX Base Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_paddlex.md Installs the base version of the PaddleX library, which is a core dependency for using PaddlePaddle-based models. ```bash pip install "paddlex[base]" ``` -------------------------------- ### Install Datasets Package Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Installs the 'datasets' package, which is a prerequisite for some quantization processes. ```bash pip install datasets ``` -------------------------------- ### Install PaddlePaddle GPU (CUDA 11.8) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_paddlex.md Installs the GPU-accelerated version of PaddlePaddle, version 3.0.0, compatible with NVIDIA driver versions 450.80.02 or higher on Linux, or 452.39 or higher on Windows, using CUDA 11.8. ```bash python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ ``` -------------------------------- ### Run Gradio Demo with MonkeyOCR Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Start the interactive Gradio demo for MonkeyOCR. Access the demo via http://localhost:7860 once the script is running. ```bash python demo/demo_gradio.py ``` -------------------------------- ### Install Latest lmdeploy Development Version Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Installs the most recent development version of lmdeploy from its GitHub repository to resolve compatibility issues with newer models. ```bash pip install git+https://github.com/InternLM/lmdeploy.git ``` -------------------------------- ### Install Ubuntu using WSL (PowerShell) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Installs the Ubuntu Linux distribution on Windows using the Windows Subsystem for Linux command-line tool. This sets up the Linux environment for running applications. ```powershell wsl --install -d Ubuntu ``` -------------------------------- ### Install PaddlePaddle GPU (CUDA 12.6) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_paddlex.md Installs the GPU-accelerated version of PaddlePaddle, version 3.0.0, compatible with NVIDIA driver versions 550.54.14 or higher on Linux and Windows, using CUDA 12.6. ```bash python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/ ``` -------------------------------- ### Install Transformers Backend for CUDA Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Installs the transformers inference backend for MonkeyOCR, requiring CUDA 12.6. This includes installing a compatible PyTorch version and Flash Attention 2 for performance optimization. ```bash # Install PyTorch. Refer to https://pytorch.org/get-started/previous-versions/ for version compatibility pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu126 pip install -e . pip install flash-attn==2.7.4.post1 --no-build-isolation ``` -------------------------------- ### Download MonkeyOCR Model using Huggingface (Python) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Installs the huggingface_hub library and downloads the MonkeyOCR model using a Python script. This is a prerequisite for native Windows installation. ```python pip install huggingface_hub python tools/download_model.py ``` -------------------------------- ### Start MonkeyOCR FastAPI Service Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Launch the MonkeyOCR FastAPI service using uvicorn. The API documentation is available at http://localhost:8000/docs. Consider using 'vllm_async' for improved concurrency. ```bash uvicorn api.main:app --port 8000 ``` -------------------------------- ### Install PaddleX and MonkeyOCR Base Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Sets up a Conda environment, clones the MonkeyOCR repository, and installs PaddlePaddle with GPU support and the base PaddleX library. This is a prerequisite for using MonkeyOCR with CUDA. ```bash conda create -n MonkeyOCR python=3.10 conda activate MonkeyOCR git clone https://github.com/Yuliang-Liu/MonkeyOCR.git cd MonkeyOCR export CUDA_VERSION=126 # for CUDA 12.6 # export CUDA_VERSION=118 # for CUDA 11.8 pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu${CUDA_VERSION}/ # Execute the following command to install the base version of PaddleX. pip install "paddlex[base]" ``` -------------------------------- ### MonkeyOCR Install Transformers (CUDA 12.4/12.1) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda.md Installs MonkeyOCR with the transformers backend for CUDA 12.4 or 12.1. Includes Conda environment setup, repository cloning, installing the package, PyTorch with CUDA, and Flash Attention 2. ```bash conda create -n MonkeyOCR python=3.10 conda activate MonkeyOCR git clone https://github.com/Yuliang-Liu/MonkeyOCR.git cd MonkeyOCR pip install -e . ``` ```bash export CUDA_VERSION=124 # for CUDA 12.4 # export CUDA_VERSION=121 # for CUDA 12.1 # Install pytorch pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION} ``` ```bash pip install flash-attn==2.7.4.post1 --no-build-isolation ``` -------------------------------- ### Install vLLM Backend for CUDA Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Installs the vLLM inference backend for MonkeyOCR, supporting CUDA 12.6/11.8. It involves upgrading the 'uv' package and installing vLLM with the appropriate PyTorch backend. ```bash pip install uv --upgrade uv pip install vllm==0.9.1 --torch-backend=cu${CUDA_VERSION} pip install -e . ``` -------------------------------- ### Locate lmdeploy Library Directory Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md A command to find the installation directory of the lmdeploy library, useful for locating specific files like calibrate.py. ```bash python -c "import lmdeploy; import os; print(os.path.dirname(lmdeploy.__file__))" ``` -------------------------------- ### Manually Configure Model Weights Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_paddlex.md Specifies the local path for PP-DocLayout_plus-L model weights within the model configuration file. This allows for manual download and management of model files. ```yaml weights: PP-DocLayout_plus-L: Structure/PP-DocLayout_plus-L # The relative path of models_dir layout_config: model: PP-DocLayout_plus-L # PP-DocLayout_plus-L / doclayout_yolo ``` -------------------------------- ### Install LMDeploy Backend for CUDA Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Installs the LMDeploy inference backend, which is recommended for MonkeyOCR. It includes installing a compatible PyTorch version for the specified CUDA version and the lmdeploy package itself. Requires CUDA 12.6 or 11.8. ```bash # Install PyTorch. Refer to https://pytorch.org/get-started/previous-versions/ for version compatibility pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION} pip install -e . # CUDA 12.6 pip install lmdeploy==0.9.2 # CUDA 11.8 # pip install https://github.com/InternLM/lmdeploy/releases/download/v0.9.2/lmdeploy-0.9.2+cu118-cp310-cp310-manylinux2014_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu118 ``` -------------------------------- ### Configure PP-DocLayout_plus-L Model Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_paddlex.md Sets the layout model to PP-DocLayout_plus-L in the model configuration file. This is a required step to switch from the default doclayout_yolo model. ```yaml layout_config: model: PP-DocLayout_plus-L # PP-DocLayout_plus-L / doclayout_yolo ``` -------------------------------- ### Clone MonkeyOCR Repository (Git) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Clones the MonkeyOCR project repository from GitHub into the current directory within the WSL environment. This is the first step in building the Docker image or native installation. ```git git clone https://github.com/Yuliang-Liu/MonkeyOCR cd MonkeyOCR ``` -------------------------------- ### MonkeyOCR Install vLLM (CUDA 12.6/12.8/11.8) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda.md Installs MonkeyOCR with vLLM backend for CUDA 12.6, 12.8, or 11.8. Requires Conda, Git, and uv for package management. Sets CUDA version and installs vLLM with the specified PyTorch backend. ```bash conda create -n MonkeyOCR python=3.10 conda activate MonkeyOCR git clone https://github.com/Yuliang-Liu/MonkeyOCR.git cd MonkeyOCR pip install uv --upgrade export CUDA_VERSION=126 # for CUDA 12.6 # export CUDA_VERSION=128 # for CUDA 12.8 # export CUDA_VERSION=118 # for CUDA 11.8 uv pip install vllm==0.9.1 --torch-backend=cu${CUDA_VERSION} pip install -e . ``` -------------------------------- ### MonkeyOCR Install LMDeploy (CUDA 12.4/12.1) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda.md Installs MonkeyOCR with LMDeploy backend for CUDA 12.4 or 12.1. Requires Conda, Git, and specific PyTorch versions. Installs lmdeploy and optionally patches it to fix shared memory errors. ```bash conda create -n MonkeyOCR python=3.10 conda activate MonkeyOCR git clone https://github.com/Yuliang-Liu/MonkeyOCR.git cd MonkeyOCR export CUDA_VERSION=124 # for CUDA 12.4 # export CUDA_VERSION=121 # for CUDA 12.1 # Install PyTorch. Refer to https://pytorch.org/get-started/previous-versions/ for version compatibility pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION} pip install -e . pip install lmdeploy==0.8.0 ``` ```bash python tools/lmdeploy_patcher.py patch ``` ```bash python tools/lmdeploy_patcher.py restore ``` -------------------------------- ### MonkeyOCR Install LMDeploy (CUDA 11.8) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda.md Installs MonkeyOCR with LMDeploy backend for CUDA 11.8. Requires Conda, Git, and specific PyTorch versions. Installs LMDeploy using a specific wheel file for CUDA 11.8. ```bash conda create -n MonkeyOCR python=3.10 conda activate MonkeyOCR git clone https://github.com/Yuliang-Liu/MonkeyOCR.git cd MonkeyOCR # Install PyTorch. Refer to https://pytorch.org/get-started/previous-versions/ for version compatibility pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118 pip install -e . pip install https://github.com/InternLM/lmdeploy/releases/download/v0.8.0/lmdeploy-0.8.0+cu118-cp310-cp310-manylinux2014_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu118 ``` -------------------------------- ### Download MonkeyOCR Model using ModelScope (Python) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Installs the modelscope library and downloads the MonkeyOCR model using a Python script, specifying ModelScope as the source. This offers an alternative to Huggingface for model downloads. ```python pip install modelscope python tools/download_model.py -t modelscope ``` -------------------------------- ### Configure MonkeyOCR to Use Transformers Backend Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Updates the MonkeyOCR configuration file (`model_configs.yaml`) to specify 'transformers' as the inference backend and set the batch size. This is done after installing the transformers package and Flash Attention 2. ```yaml chat_config: backend: transformers batch_size: 10 # Adjust based on your available GPU memory ``` -------------------------------- ### Configure MonkeyOCR to Use vLLM Backend Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Updates the MonkeyOCR configuration file (`model_configs.yaml`) to specify 'vllm' as the inference backend. This is done after installing the vLLM package. ```yaml chat_config: backend: vllm ``` -------------------------------- ### Install Triton for Windows (Shell) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Installs or updates the Triton package specifically for Windows environments to version less than 3.4. This is a required step for running MonkeyOCR natively on Windows. ```shell pip install -U "triton-windows<3.4" ``` -------------------------------- ### MonkeyOCR Configuration Update Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda.md Updates the backend configuration in `model_configs.yaml` for MonkeyOCR. Shows how to set the backend to 'vllm' or 'transformers' and adjust parameters like batch_size. ```yaml chat_config: backend: vllm ``` ```yaml chat_config: backend: transformers batch_size: 10 # Adjust based on your available GPU memory ``` -------------------------------- ### Patch LMDeploy for Shared Memory Error Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/install_cuda_pp.md Applies a patch to the LMDeploy source code to resolve 'shared memory' errors encountered on NVIDIA 20/30/40 series or V100 GPUs. This is an optional step for specific hardware configurations. ```bash python tools/lmdeploy_patcher.py patch ``` ```bash python tools/lmdeploy_patcher.py restore ``` -------------------------------- ### Build and Run MonkeyOCR Docker Image Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Build the MonkeyOCR Docker image and run it using docker compose. Includes options for standard builds, patched builds for LMDeploy compatibility, running the Gradio demo, an interactive development environment, and the FastAPI service. ```bash cd docker bash env.sh docker compose build monkeyocr docker compose build monkeyocr-fix docker compose up monkeyocr-demo docker compose run --rm monkeyocr-dev docker compose up monkeyocr-api ``` -------------------------------- ### Perform AWQ Quantization Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Initiates the AWQ quantization process with specified model paths, calibration dataset, and quantization parameters. ```bash lmdeploy lite auto_awq \ ./model_weight/Recognition \ --calib-dataset 'ptb' \ --calib-samples 64 \ --calib-seqlen 1024 \ --w-bits 4 \ --w-group-size 128 \ --batch-size 1 \ --work-dir ./monkeyocr_quantization ``` -------------------------------- ### Manage Model Weight Directories Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Commands to rename the original model weight directory and replace it with the newly quantized model weights. ```bash mv model_weight/Recognition Recognition_backup ``` ```bash mv monkeyocr_quantization model_weight/Recognition ``` -------------------------------- ### Download MonkeyOCR Model from Huggingface (Python) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md This Python snippet demonstrates how to download MonkeyOCR model weights (e.g., MonkeyOCR-pro-3B) from Huggingface using the `huggingface_hub` library and a provided download script. ```python pip install huggingface_hub python tools/download_model.py -n MonkeyOCR-pro-3B # or MonkeyOCR ``` -------------------------------- ### Apply Patch Script for Qwen2.5VL AWQ Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Executes a Python script to automatically patch the lmdeploy library for Qwen2.5VL AWQ compatibility or restore the original state. ```bash python tools/fix_qwen2_5_vl_awq.py patch ``` ```bash python tools/fix_qwen2_5_vl_awq.py restore ``` -------------------------------- ### Enter WSL Environment (PowerShell) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Navigates into the Windows Subsystem for Linux environment and changes the directory to the home folder. This is the entry point for interacting with the Linux subsystem. ```powershell wsl cd ~ ``` -------------------------------- ### Advanced Configurations Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Applies advanced configurations such as custom model configurations, output directory, predicting abandon elements, and merging text blocks. ```APIDOC ## POST /process/advanced ### Description Processes files with advanced configurations, including custom model configs, output paths, and prediction options. ### Method POST ### Endpoint /process/advanced ### Parameters #### Query Parameters - **file_path** (string) - Required - Path to the input file or folder. - **config_path** (string) - Optional - Path to a custom model configuration YAML file. - **output_dir** (string) - Optional - Path to the directory for saving output files. - **predict_abandon** (boolean) - Optional - Enable predicting abandon elements. - **merge_blocks** (boolean) - Optional - Merge text blocks in the output. ### Request Example ```json { "file_path": "input.pdf", "config_path": "model_configs.yaml", "output_dir": "./out", "predict_abandon": true, "merge_blocks": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the advanced processing. - **details** (string) - Provides details about the processed files or operations. #### Response Example ```json { "status": "success", "details": "Advanced processing completed successfully." } ``` ``` -------------------------------- ### Advanced MonkeyOCR Configurations Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Utilize advanced configurations for MonkeyOCR, including custom model configurations, specifying output directories, enabling prediction of abandoned elements, and merging text blocks. ```python python parse.py input.pdf -c model_configs.yaml python parse.py /path/to/folder -g 15 -s -o ./out python parse.py input.pdf --pred-abandon python parse.py /path/to/folder -g 10 -m ``` -------------------------------- ### Troubleshoot Qwen2.5VL TextModel Error Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/Quantization.md Demonstrates a common RuntimeError when quantizing Qwen2.5VL models due to unsupported types and provides the specific code snippet that causes the issue in lmdeploy's calibrate.py. ```text RuntimeError: Currently, quantification and calibration of Qwen2_5_VLTextModel are not supported. The supported model types are InternLMForCausalLM, InternLM2ForCausalLM, InternLM3ForCausalLM, QWenLMHeadModel, Qwen2ForCausalLM, Qwen3ForCausalLM, BaiChuanForCausalLM, BaichuanForCausalLM, LlamaForCausalLM, LlavaLlamaForCausalLM,MGMLlamaForCausalLM, InternLMXComposer2ForCausalLM, Phi3ForCausalLM, ChatGLMForConditionalGeneration, MixtralForCausalLM, Qwen2VLForConditionalGeneration, Qwen2_5_VLForConditionalGeneration, MistralForCausalLM. ``` ```python if hasattr(vl_model, 'language_model'): # deepseek-vl, ... model = vl_model.language_model if hasattr(vl_model, 'llm'): # MiniCPMV, ... model = vl_model.llm ``` ```python # if hasattr(vl_model, 'language_model'): # deepseek-vl, ... # model = vl_model.language_model # if hasattr(vl_model, 'llm'): # MiniCPMV, ... # model = vl_model.llm ``` -------------------------------- ### Download MonkeyOCR Model from ModelScope (Python) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md This Python snippet shows how to download MonkeyOCR model weights from ModelScope using the `modelscope` library and a specific download script. ```python pip install modelscope python tools/download_model.py -t modelscope -n MonkeyOCR-pro-3B # or MonkeyOCR ``` -------------------------------- ### MonkeyOCR Parsing Commands (Bash) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md A collection of bash commands for running MonkeyOCR inference. These commands cover end-to-end parsing, parsing with group page numbers, single-task recognition, page splitting, and specifying output directories and config files. ```bash # End-to-end parsing python parse.py input_path # Parse files in a dir with specific group page num python parse.py input_path -g 20 # Single-task recognition (outputs markdown only) python parse.py input_path -t text/formula/table # Parse PDFs in input_path and split results by pages python parse.py input_path -s # Specify output directory and model config file python parse.py input_path -o ./output -c config.yaml ``` ```bash # Single file processing python parse.py input.pdf # Parse single PDF file python parse.py input.pdf -o ./output # Parse with custom output dir python parse.py input.pdf -s # Parse PDF with page splitting python parse.py image.jpg # Parse single image file ``` -------------------------------- ### Enable WSL2 and Virtual Machine Platform (PowerShell) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Enables necessary Windows features for WSL2, including the Virtual Machine Platform and the Windows Subsystem for Linux itself. Requires administrator privileges to run. ```powershell dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart # Restart your computer. ``` -------------------------------- ### Configure WSL Memory Limit (.wslconfig) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/docs/windows_support.md Sets the memory allocation for WSL2 environments by creating or modifying the .wslconfig file in the user's profile directory. This can help prevent memory-related issues. ```properties [wsl2] memory=24GB ``` -------------------------------- ### Multi-file Grouping and Batch Processing Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Group files for batch processing based on a maximum number of total pages. Supports page splitting and single task recognition within groups. ```python python parse.py /path/to/folder -g 5 python parse.py /path/to/folder -g 10 -s python parse.py /path/to/folder -g 8 -t text ``` -------------------------------- ### Folder Processing with MonkeyOCR Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Process all files within a specified folder. Options include parsing all files individually, enabling page splitting, or applying single task recognition to all files. ```python python parse.py /path/to/folder python parse.py /path/to/folder -s python parse.py /path/to/folder -t text ``` -------------------------------- ### Folder Processing Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Process all files within a specified folder, with options for splitting pages and performing single task recognition. ```APIDOC ## POST /process/folder ### Description Processes all files in a given folder. Can optionally split pages and perform single task recognition on all files. ### Method POST ### Endpoint /process/folder ### Parameters #### Query Parameters - **folder_path** (string) - Required - Path to the folder containing files to process. - **split_pages** (boolean) - Optional - If true, pages will be split for processing. - **task** (string) - Optional - Specifies a single task recognition type (e.g., 'text') for all files. ### Request Example ```json { "folder_path": "/path/to/folder", "split_pages": true, "task": "text" } ``` ### Response #### Success Response (200) - **results** (object) - A dictionary where keys are filenames and values are their processing results. #### Response Example ```json { "results": { "file1.jpg": "Processed content of file1.jpg...", "file2.pdf": "Processed content of file2.pdf..." } } ``` ``` -------------------------------- ### Multi-File Grouping (Batch Processing) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Groups files for batch processing based on a specified maximum number of pages per group. ```APIDOC ## POST /process/group ### Description Groups files from a folder for batch processing, with options for page splitting and single task recognition. ### Method POST ### Endpoint /process/group ### Parameters #### Query Parameters - **folder_path** (string) - Required - Path to the folder containing files. - **group_size** (integer) - Required - Maximum number of total pages for each group. - **split_pages** (boolean) - Optional - If true, pages will be split for processing. - **task** (string) - Optional - Specifies a single task recognition type (e.g., 'text') for grouped files. ### Request Example ```json { "folder_path": "/path/to/folder", "group_size": 5, "split_pages": false, "task": "formula" } ``` ### Response #### Success Response (200) - **grouped_results** (object) - A dictionary where keys are group identifiers and values are the results for each group. #### Response Example ```json { "grouped_results": { "group_1": "Processed content for group 1...", "group_2": "Processed content for group 2..." } } ``` ``` -------------------------------- ### Single Task Recognition with MonkeyOCR Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Perform specific recognition tasks like text, formula, or table extraction from images or PDF documents. Supports single image files and all pages of a PDF. ```python python parse.py image.jpg -t text python parse.py image.jpg -t formula python parse.py image.jpg -t table python parse.py document.pdf -t text ``` -------------------------------- ### Single Task Recognition Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md Perform specific recognition tasks on an image or PDF document. ```APIDOC ## POST /recognize/image ### Description Recognizes specified tasks (text, formula, table) from a given image file. ### Method POST ### Endpoint /recognize/image ### Parameters #### Query Parameters - **image_file** (file) - Required - The image file to process. - **task** (string) - Required - The type of recognition task (e.g., 'text', 'formula', 'table'). ### Request Example ```json { "task": "text" } ``` ### Response #### Success Response (200) - **result** (string) - The recognition result. #### Response Example ```json { "result": "Recognized text content..." } ``` ## POST /recognize/pdf ### Description Recognizes specified tasks from all pages of a PDF document. ### Method POST ### Endpoint /recognize/pdf ### Parameters #### Query Parameters - **pdf_file** (file) - Required - The PDF file to process. - **task** (string) - Required - The type of recognition task (e.g., 'text', 'formula', 'table'). ### Request Example ```json { "task": "text" } ``` ### Response #### Success Response (200) - **result** (string) - The recognition result for all pages. #### Response Example ```json { "result": "Recognized text content from all pages..." } ``` ``` -------------------------------- ### MonkeyOCR Citation (BibTeX) Source: https://github.com/yuliang-liu/monkeyocr/blob/main/README.md This BibTeX entry can be used to cite the MonkeyOCR document parsing framework in academic publications. It includes author, title, year, and other relevant details for proper referencing. ```BibTeX @misc{li2025monkeyocrdocumentparsingstructurerecognitionrelation, title={MonkeyOCR: Document Parsing with a Structure-Recognition-Relation Triplet Paradigm}, author={Zhang Li and Yuliang Liu and Qiang Liu and Zhiyin Ma and Ziyang Zhang and Shuo Zhang and Zidun Guo and Jiarui Zhang and Xinyu Wang and Xiang Bai}, year={2025}, eprint={2506.05218}, archivePrefix={arXiv}, primaryClass={cs.CV}, url={https://arxiv.org/abs/2506.05218}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.