A practical tool for converting PDF to Markdown
Project description
KittyDoc – 高速文档解析产线
基于 Mineru 二次开发,移除 VLM,专注于 Pipeline 产线下的高效文档解析,在 CPU 上也能保持不错的解析速度。
😺 项目介绍
KittyDoc 是一个轻量级、专注于文档解析的开源框架,支持 OCR、版面分析、公式识别、表格识别和阅读顺序恢复 等多种功能。
与原框架相比,本项目使用 PP-StructureV3 系列模型,并完全 去除对 Paddle 的依赖,所有模型均已转换为 ONNX,可直接通过 ONNX Runtime 或 OpenVINO(部分模型)进行高效推理。
✨如果该项目对您有帮助,您的star是我不断优化的动力!!!
👏 项目特点
-
OCR 识别
- 使用 RapidOCR 支持多种推理引擎
- CPU 下默认使用 OpenVINO,GPU 下默认使用 torch
-
版面识别
- 模型使用
PP-DocLayout系列 ONNX 模型(plus-L、L、M、S)- PP-DocLayout_plus-L:效果最好,速度稍慢
- PP-DocLayout-L:速度快,效果也不错,默认使用
- PP-DocLayout-S:速度极快,可能存在部分漏检
- 模型使用
-
公式识别
- 使用
PP-FormulaNet_plus系列 ONNX 模型(L、M、S)- PP-FormulaNet_plus-L:速度慢
- PP-FormulaNet_plus-S:速度最快,默认使用
- 支持配置只识别行间公式
- cuda环境默认不使用gpu,公式模型onnx gpu推理会报错,暂时无人解决 PaddleOCR/issues/15125, PaddleX/issues/4238, Paddle2ONNX/issues/1593
- 使用
-
表格识别
- 基于 rapid_table_self 增强,在原有基础上增强为多模型串联方案:
- 表格分类(区分有线/无线表格)
- SLANeXt 系列 表结构识别 + 单元格检测
- 有线表格识别UNET + SLANET_plus/UNITABLE(作为无线表格识别)
- 基于 rapid_table_self 增强,在原有基础上增强为多模型串联方案:
-
阅读顺序恢复
- 使用 PP-StructureV3 阅读顺序
xycut++算法简化 - 速度快且阅读顺序恢复效果不错
- 使用 PP-StructureV3 阅读顺序
-
推理方式
- 所有模型通过 ONNXRuntime 推理,OCR可配置其他推理引擎
- 除了 OCR 和 PP-DocLayout-M/S 模型,OpenVINO推理会报错,暂时难以解决。PaddleOCR/issues/16277
🛠️ 安装KittyDoc
使用pip安装KittyDoc
pip install kitty-doc -i https://mirrors.aliyun.com/pypi/simple
通过源码安装KittyDoc
# 克隆仓库
git clone https://github.com/hzkitty/KittyDoc.git
cd KittyDoc
# 安装依赖
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
使用gpu推理
# 在安装完kitty_doc之后,卸载cpu版的onnxruntime
pip uninstall onnxruntime
# 这里一定要确定onnxruntime-gpu与GPU对应
# 可参见https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements
pip install onnxruntime-gpu
# 在 Python 中指定 GPU(必须在导入 kitty_doc 之前设置)
import os
# 使用默认 GPU(cuda:0)
os.environ['MINERU_DEVICE_MODE'] = "cuda"
# 或指定 GPU 编号,例如使用第二块 GPU(cuda:1)
os.environ['MINERU_DEVICE_MODE'] = "cuda:1"
📋 使用示例
模型下载
不指定模型路径,初次运行时,会自动下载
📌 TODO
- 表格非OCR文本提取
- 跨页表格合并
- 复选框识别,使用opencv(默认关闭、opencv识别存在误检)
- 复选框识别,使用模型
- 四方向分类旋转表格解析 rapid_orientation
- 表格内公式提取
- 表格内图片提取
- 公式识别支持gpu
- 版面、表格、公式支持openvino
- KittyDoc4j(Java版本)
🙏 致谢
⚖️ 开源许可
基于 MinerU 改造而来,已移除原项目中的 YOLO 模型,并替换为 PP-StructureV3 系列 ONNX 模型。
由于已移除 AGPL 授权的 YOLO 模型部分,本项目整体不再受 AGPL 约束。
该项目采用 Apache 2.0 license 开源许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kitty_doc-0.1.0.tar.gz.
File metadata
- Download URL: kitty_doc-0.1.0.tar.gz
- Upload date:
- Size: 972.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76d529645fb9c2abc6b352748a1563bccdd1ecf101d674f2d0372b1de3c32129
|
|
| MD5 |
3270e1336de869e5202a1a1b0ab77dcd
|
|
| BLAKE2b-256 |
8a795e2241de7018c0b799b9c582edf41df1922a3470cffe2eb5e1531d295265
|
File details
Details for the file kitty_doc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kitty_doc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
120ee4c28d17f6b307b0ca802ace59f2893e6e4bef6ed020df6f90863b192478
|
|
| MD5 |
ffe6c105ea54b81b543277d5b3144564
|
|
| BLAKE2b-256 |
d669430ddb4b9fef3492e1fa540d1422e883ea384180da41707caceacc602b0a
|