Copy of ocr-benchmarking repo for ML4Science project
0
stars
1
commits
Jupyter Notebook
primary language
Jan 20, 2026
updated
A comprehensive OCR benchmarking framework for comparing multiple state-of-the-art OCR engines and document processors on standardized HuggingFace datasets. This project enables systematic evaluation of OCR performance across various document types including invoices, receipts, handwritten text, scientific papers, and charts.
This benchmarking suite provides a unified pipeline to:
| Engine | Type | Script | Status |
|---|---|---|---|
| PaddleOCR | Traditional OCR | run_paddle.py | Active |
| Docling | Document AI | run_docling.py | Active |
| MMoRe | Multimodal Reasoning | run_mmore.py | Active |
| OlmOCR | Vision-Language Model | run_olmocr.py | Active |
| RolmOCR | Vision-Language Model | run_rolmocr.py | Active |
| DotsOCR | LLM-based OCR | run_dots.py | Active |
| FolioForge | Document Parser | run_folio.py | Active |
| DeepSeek | Vision-Language Model | run_deepseek.py | Active |
Datasets are sourced from HuggingFace Hub and cover diverse document types:
| Dataset | Type | Samples | Focus Area |
|---|---|---|---|
mychen76/invoices-and-receipts_ocr_v1 | Invoices & Receipts | Variable | Structured documents, financial data |
Teklia/IAM-line | Handwriting | ~13k lines | Handwritten text recognition |
naver-clova-ix/cord-v2 | Receipts | 800+ | Korean/English receipts |
MosRat2333/ZhEn-latex | Scientific | Variable | Mathematical formulas, Chinese/English |
HuggingFaceM4/ChartQA | Charts | 9k+ | Chart and graph understanding |
merve/doclaynet-small | Documents | Variable | Document layout analysis |
getomni-ai/ocr-benchmark | General | Variable | General OCR benchmark |
git clone <repository-url>
cd project-2-ocr-benchmarking
python -m venv my_env
source my_env/bin/activate # On Windows: my_env\Scripts\activate
pip install -r requirements.txt
Note: The
requirements.txtcontains merge conflict markers. Resolve them before installation:
- Option A (GPU support): Keep the DeepSeek/PyTorch dependencies for GPU acceleration
- Option B (Lightweight): Keep only pandas, jiwer, matplotlib, and core utilities
- For CUDA 12.1 with GPU, use:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
cd scripts
python run_paddle.py # Run PaddleOCR on default dataset
Results will be saved as CSV files in the results/ directory.
project-2-ocr-benchmarking/
├── scripts/ # OCR engine runners & utilities
│ ├── run_paddle.py # PaddleOCR benchmark
│ ├── run_docling.py # Docling benchmark
│ ├── run_mmore.py # MMoRe benchmark
│ ├── run_olmocr.py # OlmOCR benchmark
│ ├── run_rolmocr.py # RolmOCR benchmark
│ ├── run_dots.py # DotsOCR benchmark
│ ├── run_folio.py # FolioForge benchmark
│ ├── run_deepseek.py # DeepSeek benchmark
│ ├── preprocess_data.py # Data preprocessing & column normalization
│ └── evaluate_paddle_ocr.py # Evaluation & metrics generation
│
├── results/ # Benchmark outputs (organized by dataset)
│ ├── raw/ # Raw OCR engine outputs
│ │ ├── getomni-ai_ocr-benchmark/
│ │ ├── HuggingFaceM4_ChartQA/
│ │ ├── merve_doclaynet-small/
│ │ ├── MosRat2333_ZhEn-latex/
│ │ ├── mychen76_invoices-and-receipts_ocr_v1/
│ │ ├── naver-clova-ix_cord-v2/
│ │ └── Teklia_IAM-line/
│ ├── normalized/ # Standardized metrics
│ └── final_metrics_clean/ # Comprehensive benchmark results (35+ CSV files)
│
├── utils/ # Utility modules
│ ├── notebook_utils.py # OCR evaluation helpers (WER, CER, plotting)
│ └── merge_data.py # Data merging utilities
│
├── figures/ # Generated visualizations
│
├── old/ # Legacy scripts (archived)
│
├── evaluate_ocr.ipynb # Main evaluation notebook
├── requirements.txt # Python dependencies
└── README.md # This file
Each OCR engine has a dedicated runner script in the scripts/ directory. All scripts follow a consistent pattern:
cd scripts
python run_<engine>.py
Edit the script's configuration section to customize:
# Example from run_paddle.py
DATASET_NAME = "mychen76/invoices-and-receipts_ocr_v1" # Choose dataset
MAX_SAMPLES = None # Set to integer for testing (e.g., 10)
OUTPUT_CSV = "invoice_benchmark_invoices.csv" # Output filename
python run_paddle.py
Index, Ground Truth, PaddleOCR Prediction, Time (s)python run_docling.py
python run_olmocr.py
python run_rolmocr.py
python run_mmore.py
python run_dots.py
python run_deepseek.py
scripts/deepseek_results/Use evaluate_paddle_ocr.py (adaptable to other engines) to generate comprehensive metrics:
cd scripts
python evaluate_paddle_ocr.py
Computed Metrics:
Generated Outputs:
figures/ directoryevaluate_ocr.ipynb)Comprehensive Jupyter notebook for analyzing benchmark results:
Features:
utils/notebook_utils.py for standardized metrics calculationTo run:
jupyter notebook evaluate_ocr.ipynb
All benchmark results follow a standardized CSV format:
Index,Ground Truth,Prediction,Time (s)
0,"Sample text",Sample text (conf: 0.95),0.123
1,"Another example",Another exmple (conf: 0.87),0.145
Columns:
Index: Sample numberGround Truth: Reference text from datasetPrediction: OCR engine output (may include confidence scores)Time (s): Processing time in secondsscripts/preprocess_data.py)Automated data preprocessing script for standardizing diverse CSV formats:
python preprocess_data.py
Features:
Supported column names:
utils/notebook_utils.py)Comprehensive utility module for OCR evaluation notebooks:
utils/merge_data.py)Utilities for combining results from multiple engines or datasets into unified comparison files.
Step-by-step guide to run a full benchmark:
Setup & Installation
python -m venv my_env
source my_env/bin/activate # Windows: my_env\Scripts\activate
pip install -r requirements.txt
Test with small sample (5-10 images)
cd scripts
# Edit run_paddle.py: set MAX_SAMPLES = 10
python run_paddle.py
Run full benchmark for all engines
# Run each engine (can be parallelized)
python run_paddle.py
python run_docling.py
python run_mmore.py
python run_olmocr.py
python run_rolmocr.py
python run_dots.py
python run_folio.py
python run_deepseek.py
Preprocess results (optional, for column normalization)
python preprocess_data.py
Generate metrics & plots
python evaluate_paddle_ocr.py
Analyze in notebook
jupyter notebook ../evaluate_ocr.ipynb
MAX_SAMPLES = 10 before full runsnvidia-smi to track usage during VLM inferenceHF_HOME environment variable to avoid re-downloadsFor optimal performance, GPU acceleration is recommended:
Check CUDA availability:
import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"CUDA version: {torch.version.cuda}")
Install PyTorch with CUDA:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
To avoid disk quota issues and speed up loading:
# Set cache directory
export HF_HOME="./hf_cache" # Linux/Mac
set HF_HOME=.\hf_cache # Windows
This is automatically configured in most runner scripts.
For systems with limited resources:
# In runner scripts, adjust:
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
# For VLM models, use quantization:
model = Qwen2VLForConditionalGeneration.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16, # or torch.float16
device_map="auto",
load_in_8bit=True # Requires bitsandbytes
)
All benchmark results are organized in results/ with two main sections:
results/raw/)Original OCR engine outputs by dataset:
getomni-ai_ocr-benchmark/ - General OCR benchmarkingHuggingFaceM4_ChartQA/ - Chart and graph understandingmerve_doclaynet-small/ - Document layout analysisMosRat2333_ZhEn-latex/ - Scientific documents with LaTeX/formulasmychen76_invoices-and-receipts_ocr_v1/ - Financial documentsnaver-clova-ix_cord-v2/ - Receipts (Korean/English)Teklia_IAM-line/ - Handwritten textresults/normalized/)Standardized metrics across all datasets
results/final_metrics_clean/)Comprehensive benchmark comparison with 35+ CSV files containing:
Dataset Coverage:
Metric Columns:
Model: OCR engine nameDataset: Benchmark datasetWER (Word Error Rate): % word-level errorsCER (Character Error Rate): % character-level errorsAccuracy_Score: Exact match percentageInference_Time_s: Processing time per samplePre-computed results are available in results/final_metrics_clean/:
# View sample results
head -5 results/final_metrics_clean/ChartQA_Docling.csv
head -5 results/final_metrics_clean/IAM_Handwriting_PaddleOCR.csv
head -5 results/final_metrics_clean/Invoices_\&_Receipts_RolmOCR.csv
Quick comparison example:
# Compare all engines on ChartQA dataset
ls results/final_metrics_clean/ChartQA_*.csv
# Compare all datasets for one engine
ls results/final_metrics_clean/*_PaddleOCR.csv
The evaluation scripts generate various plots automatically:
Figures are saved to figures/ organized by engine and dataset.
model.deviceHF_HOMEThis project uses several third-party libraries and models:
Important: Each OCR engine and dataset has its own license. Review and comply with their terms, especially for commercial use.
MAX_SAMPLES=10 before full runshtop (CPU) and nvidia-smi (GPU) to track usageresults/final_metrics_clean/ for pre-computed benchmarks1 commits
Jupyter Notebook
97.0%
Python
3.0%
Copy of ocr-benchmarking repo for ML4Science project
0
stars
1
commits
Jupyter Notebook
primary language
Jan 20, 2026
updated
A comprehensive OCR benchmarking framework for comparing multiple state-of-the-art OCR engines and document processors on standardized HuggingFace datasets. This project enables systematic evaluation of OCR performance across various document types including invoices, receipts, handwritten text, scientific papers, and charts.
This benchmarking suite provides a unified pipeline to:
| Engine | Type | Script | Status |
|---|---|---|---|
| PaddleOCR | Traditional OCR | run_paddle.py | Active |
| Docling | Document AI | run_docling.py | Active |
| MMoRe | Multimodal Reasoning | run_mmore.py | Active |
| OlmOCR | Vision-Language Model | run_olmocr.py | Active |
| RolmOCR | Vision-Language Model | run_rolmocr.py | Active |
| DotsOCR | LLM-based OCR | run_dots.py | Active |
| FolioForge | Document Parser | run_folio.py | Active |
| DeepSeek | Vision-Language Model | run_deepseek.py | Active |
Datasets are sourced from HuggingFace Hub and cover diverse document types:
| Dataset | Type | Samples | Focus Area |
|---|---|---|---|
mychen76/invoices-and-receipts_ocr_v1 | Invoices & Receipts | Variable | Structured documents, financial data |
Teklia/IAM-line | Handwriting | ~13k lines | Handwritten text recognition |
naver-clova-ix/cord-v2 | Receipts | 800+ | Korean/English receipts |
MosRat2333/ZhEn-latex | Scientific | Variable | Mathematical formulas, Chinese/English |
HuggingFaceM4/ChartQA | Charts | 9k+ | Chart and graph understanding |
merve/doclaynet-small | Documents | Variable | Document layout analysis |
getomni-ai/ocr-benchmark | General | Variable | General OCR benchmark |
git clone <repository-url>
cd project-2-ocr-benchmarking
python -m venv my_env
source my_env/bin/activate # On Windows: my_env\Scripts\activate
pip install -r requirements.txt
Note: The
requirements.txtcontains merge conflict markers. Resolve them before installation:
- Option A (GPU support): Keep the DeepSeek/PyTorch dependencies for GPU acceleration
- Option B (Lightweight): Keep only pandas, jiwer, matplotlib, and core utilities
- For CUDA 12.1 with GPU, use:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
cd scripts
python run_paddle.py # Run PaddleOCR on default dataset
Results will be saved as CSV files in the results/ directory.
project-2-ocr-benchmarking/
├── scripts/ # OCR engine runners & utilities
│ ├── run_paddle.py # PaddleOCR benchmark
│ ├── run_docling.py # Docling benchmark
│ ├── run_mmore.py # MMoRe benchmark
│ ├── run_olmocr.py # OlmOCR benchmark
│ ├── run_rolmocr.py # RolmOCR benchmark
│ ├── run_dots.py # DotsOCR benchmark
│ ├── run_folio.py # FolioForge benchmark
│ ├── run_deepseek.py # DeepSeek benchmark
│ ├── preprocess_data.py # Data preprocessing & column normalization
│ └── evaluate_paddle_ocr.py # Evaluation & metrics generation
│
├── results/ # Benchmark outputs (organized by dataset)
│ ├── raw/ # Raw OCR engine outputs
│ │ ├── getomni-ai_ocr-benchmark/
│ │ ├── HuggingFaceM4_ChartQA/
│ │ ├── merve_doclaynet-small/
│ │ ├── MosRat2333_ZhEn-latex/
│ │ ├── mychen76_invoices-and-receipts_ocr_v1/
│ │ ├── naver-clova-ix_cord-v2/
│ │ └── Teklia_IAM-line/
│ ├── normalized/ # Standardized metrics
│ └── final_metrics_clean/ # Comprehensive benchmark results (35+ CSV files)
│
├── utils/ # Utility modules
│ ├── notebook_utils.py # OCR evaluation helpers (WER, CER, plotting)
│ └── merge_data.py # Data merging utilities
│
├── figures/ # Generated visualizations
│
├── old/ # Legacy scripts (archived)
│
├── evaluate_ocr.ipynb # Main evaluation notebook
├── requirements.txt # Python dependencies
└── README.md # This file
Each OCR engine has a dedicated runner script in the scripts/ directory. All scripts follow a consistent pattern:
cd scripts
python run_<engine>.py
Edit the script's configuration section to customize:
# Example from run_paddle.py
DATASET_NAME = "mychen76/invoices-and-receipts_ocr_v1" # Choose dataset
MAX_SAMPLES = None # Set to integer for testing (e.g., 10)
OUTPUT_CSV = "invoice_benchmark_invoices.csv" # Output filename
python run_paddle.py
Index, Ground Truth, PaddleOCR Prediction, Time (s)python run_docling.py
python run_olmocr.py
python run_rolmocr.py
python run_mmore.py
python run_dots.py
python run_deepseek.py
scripts/deepseek_results/Use evaluate_paddle_ocr.py (adaptable to other engines) to generate comprehensive metrics:
cd scripts
python evaluate_paddle_ocr.py
Computed Metrics:
Generated Outputs:
figures/ directoryevaluate_ocr.ipynb)Comprehensive Jupyter notebook for analyzing benchmark results:
Features:
utils/notebook_utils.py for standardized metrics calculationTo run:
jupyter notebook evaluate_ocr.ipynb
All benchmark results follow a standardized CSV format:
Index,Ground Truth,Prediction,Time (s)
0,"Sample text",Sample text (conf: 0.95),0.123
1,"Another example",Another exmple (conf: 0.87),0.145
Columns:
Index: Sample numberGround Truth: Reference text from datasetPrediction: OCR engine output (may include confidence scores)Time (s): Processing time in secondsscripts/preprocess_data.py)Automated data preprocessing script for standardizing diverse CSV formats:
python preprocess_data.py
Features:
Supported column names:
utils/notebook_utils.py)Comprehensive utility module for OCR evaluation notebooks:
utils/merge_data.py)Utilities for combining results from multiple engines or datasets into unified comparison files.
Step-by-step guide to run a full benchmark:
Setup & Installation
python -m venv my_env
source my_env/bin/activate # Windows: my_env\Scripts\activate
pip install -r requirements.txt
Test with small sample (5-10 images)
cd scripts
# Edit run_paddle.py: set MAX_SAMPLES = 10
python run_paddle.py
Run full benchmark for all engines
# Run each engine (can be parallelized)
python run_paddle.py
python run_docling.py
python run_mmore.py
python run_olmocr.py
python run_rolmocr.py
python run_dots.py
python run_folio.py
python run_deepseek.py
Preprocess results (optional, for column normalization)
python preprocess_data.py
Generate metrics & plots
python evaluate_paddle_ocr.py
Analyze in notebook
jupyter notebook ../evaluate_ocr.ipynb
MAX_SAMPLES = 10 before full runsnvidia-smi to track usage during VLM inferenceHF_HOME environment variable to avoid re-downloadsFor optimal performance, GPU acceleration is recommended:
Check CUDA availability:
import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"CUDA version: {torch.version.cuda}")
Install PyTorch with CUDA:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
To avoid disk quota issues and speed up loading:
# Set cache directory
export HF_HOME="./hf_cache" # Linux/Mac
set HF_HOME=.\hf_cache # Windows
This is automatically configured in most runner scripts.
For systems with limited resources:
# In runner scripts, adjust:
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
# For VLM models, use quantization:
model = Qwen2VLForConditionalGeneration.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16, # or torch.float16
device_map="auto",
load_in_8bit=True # Requires bitsandbytes
)
All benchmark results are organized in results/ with two main sections:
results/raw/)Original OCR engine outputs by dataset:
getomni-ai_ocr-benchmark/ - General OCR benchmarkingHuggingFaceM4_ChartQA/ - Chart and graph understandingmerve_doclaynet-small/ - Document layout analysisMosRat2333_ZhEn-latex/ - Scientific documents with LaTeX/formulasmychen76_invoices-and-receipts_ocr_v1/ - Financial documentsnaver-clova-ix_cord-v2/ - Receipts (Korean/English)Teklia_IAM-line/ - Handwritten textresults/normalized/)Standardized metrics across all datasets
results/final_metrics_clean/)Comprehensive benchmark comparison with 35+ CSV files containing:
Dataset Coverage:
Metric Columns:
Model: OCR engine nameDataset: Benchmark datasetWER (Word Error Rate): % word-level errorsCER (Character Error Rate): % character-level errorsAccuracy_Score: Exact match percentageInference_Time_s: Processing time per samplePre-computed results are available in results/final_metrics_clean/:
# View sample results
head -5 results/final_metrics_clean/ChartQA_Docling.csv
head -5 results/final_metrics_clean/IAM_Handwriting_PaddleOCR.csv
head -5 results/final_metrics_clean/Invoices_\&_Receipts_RolmOCR.csv
Quick comparison example:
# Compare all engines on ChartQA dataset
ls results/final_metrics_clean/ChartQA_*.csv
# Compare all datasets for one engine
ls results/final_metrics_clean/*_PaddleOCR.csv
The evaluation scripts generate various plots automatically:
Figures are saved to figures/ organized by engine and dataset.
model.deviceHF_HOMEThis project uses several third-party libraries and models:
Important: Each OCR engine and dataset has its own license. Review and comply with their terms, especially for commercial use.
MAX_SAMPLES=10 before full runshtop (CPU) and nvidia-smi (GPU) to track usageresults/final_metrics_clean/ for pre-computed benchmarks1 commits
Jupyter Notebook
97.0%
Python
3.0%