Skip to main content

OCRmyPDF-AIH

批量 PDF OCR 处理管线,支持 Tesseract / Calamari 双后端

Python 3.11+ License: MPL-2.0


项目定位

OCRmyPDF-AIH 是 AIH-Infra(人文学科人工智能基础设施) 的 OCR 处理组件,基于 OCRmyPDF v17.2.0 构建。

┌─────────────────────────────────────────────────┐
│  应用层                                          │
│  朴素 RAG → Graph RAG → Agent RAG               │
├─────────────────────────────────────────────────┤
│  0.5 层:經緯·Contexture                         │
│  页码锚点 · 边注识别 · 行内注 · 模板 · 配置共享   │
├─────────────────────────────────────────────────┤
│  OCR 层:OCRmyPDF-AIH  ← 本项目                 │
│  Tesseract · Calamari · 批量处理 · Web UI        │
├─────────────────────────────────────────────────┤
│  基础层:PDF 解析                                │
│  Ghostscript · pdftext · pypdfium2              │
└─────────────────────────────────────────────────┘

OCRmyPDF-AIH 为扫描版 PDF 添加可搜索的 OCR 文字层,输出标准 PDF/A 文件。这些文件随后可被 經緯·Contexture 进一步处理为带页码锚点的结构化 Markdown,进入学术 RAG 检索流程。

相比上游 OCRmyPDF 的增强

特性 OCRmyPDF OCRmyPDF-AIH
OCR 后端 Tesseract Tesseract + Calamari GPU
使用方式 CLI CLI + Streamlit Web UI
批量处理 逐文件命令行 Web UI 多文件批量 + ZIP 打包下载
进度显示 文件级 页面级实时进度
语言选择 手动指定 自动检测已安装语言包
参数调优 CLI 参数 可视化面板(OCR 模式、预处理、输出格式)

快速开始

环境要求

  • Python 3.11 / 3.12 / 3.13
  • Windows 10/11、macOS 或 Linux
  • Ghostscript、Tesseract OCR

一键安装

Windows: 双击 install.bat

macOS:

chmod +x install.command start.command install.sh start.sh
# 然后双击 install.command

Linux:

chmod +x install.sh start.sh
./install.sh

安装脚本会自动创建虚拟环境、安装依赖,并尝试自动安装 Tesseract(失败时提示手动安装)。

pip 安装

pip install ocrmypdf-aih-infra

启动 Web UI

Windows: 双击 start.bat

macOS / Linux: ./start.sh

浏览器访问 http://localhost:6106

Calamari GPU 后端

OCRmyPDF-AIH 支持通过远程 API 调用 Calamari OCR GPU 服务,适用于需要高精度历史文献识别的场景。

在 Web UI 侧边栏选择 Calamari 后端,填入服务地址即可使用。

上游功能

OCRmyPDF-AIH 完整保留了 OCRmyPDF 的所有功能:

  • 生成可搜索的 PDF/A 文件
  • 支持 100+ 语言(Tesseract 语言包)
  • 页面旋转校正、倾斜校正、图像清理
  • 多核并行处理
  • 无损 OCR 层注入
  • PDF 图像优化
  • 插件系统

CLI 用法与上游完全兼容:

ocrmypdf -l chi_sim+eng --deskew input.pdf output.pdf

详细文档参见 OCRmyPDF 官方文档。

关于 AIH-Infra

AIH-Infra(人文学科人工智能基础设施) 致力于为人文学科研究者提供可追溯、可验证、可传承的 AI 工具链。

  • 材料线:經緯·Contexture(文献数字化与结构化)
  • OCR 层:OCRmyPDF-AIH(本项目,PDF OCR 处理)
  • 系统线:学术 RAG 知识库与检索系统

核心原则:每一条 AI 生成的回答,都必须能够返回原书的那一页。

许可证

本项目基于 Mozilla Public License 2.0 (MPL-2.0) 发布,与上游 OCRmyPDF 保持一致。

致谢

作者

Güriedrich & Baireinhold — AIH-Infra

Metadata

Release files for ocrmypdf-aih-infra 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocrmypdf-aih-infra 0.1.0
File Size Uploaded Provenance
ocrmypdf_aih_infra-0.1.0.tar.gz 10.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ocrmypdf-aih-infra 0.1.0
File Interpreter ABI Platform
ocrmypdf_aih_infra-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 MB

Release files / ocrmypdf_aih_infra-0.1.0.tar.gz

Download URL ocrmypdf_aih_infra-0.1.0.tar.gz
Size 10.1 MB
Tags Source
SHA-256 checksum
How to use checksums
4d66d2788ad56a1e89de2d4b76d682bd8065eb423bfff58fa7605e763a03449c
BLAKE2b-256 checksum
How to use checksums
bf8e42f07825e48bdb3bae2b598737e41a955c26ef84742d3b0bd7d59898907c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ocrmypdf_aih_infra-0.1.0-py3-none-any.whl

Download URL ocrmypdf_aih_infra-0.1.0-py3-none-any.whl
Size 490.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dfc0cc7544bb7aa702e50f1886ec973cc3dcb6c4c028d91fa3f3b17e9a28fe4
BLAKE2b-256 checksum
How to use checksums
af05bcab2bb05403714cc3f04fb9b0a7cb486e13b051de971d5b33c95e8ca8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for ocrmypdf-aih-infra 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page