Metadata-Version: 2.4
Name: multi-ocr-py
Version: 0.2.2
Summary: 多引擎 OCR 工具包：将 PDF 和图片转换为 Markdown，支持 CLI 全局安装和 SDK 依赖两种使用方式
Project-URL: Repository, https://github.com/BlackBoxRecorder/multi-ocr
Author-email: Yinnan <im.yinnan@outlook.com>
License-Expression: MIT
License-File: LICENSE
Keywords: cli,markdown,ocr,pdf,vision-language-model
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.11
Requires-Dist: liteparse
Requires-Dist: ollama
Requires-Dist: openai>=2.45.0
Requires-Dist: pymupdf>=1.28.0
Requires-Dist: tqdm>=4.67.0
Description-Content-Type: text/markdown

# multi-ocr

多引擎 OCR 工具包，将 PDF 和图片转换为 Markdown 文档。

- **CLI 工具**：全局安装后一行命令完成 OCR
- **SDK 依赖**：作为 Python 库集成到你的项目中

## 支持的引擎

| 引擎 | 说明 | 类型 | 场景 | 费用 |
|---|---|---|---|---|
| SiliconFlow + DeepSeek-OCR | 云端 OCR，精度高 | API | 图片+PDF | 免费 |
| SiliconFlow + PaddleOCR-VL-1.5 | 云端 OCR，轻量快速 | API | 图片+PDF  | 免费 |
| LiteParse | 本地 PDF 解析，无需联网 | 本地 | PDF  | 免费 |
| Ollama + DeepSeek-OCR | 本地部署 OCR | 本地 | 图片+PDF  | 免费 |


> 本地运行 ollama 参考：https://ollama.com/library/deepseek-ocr

## 安装

### CLI 全局安装

```bash
uv tool install multi-ocr-py
# 或
pip install multi-ocr-py
```

### SDK 依赖安装

```bash
pip install multi-ocr-py
# 或
uv add multi-ocr-py
```

## CLI 使用

```bash
# 单文件 OCR
multi-ocr document.pdf

# 指定引擎和页码范围
multi-ocr document.pdf --model liteparse --pages 1-5

# 批量处理目录，4个并发
multi-ocr ./scans/ --model silicon-deepseek-ocr -j 4

# 查看帮助
multi-ocr -h
```

### 环境变量

| 引擎 | 环境变量 |
|---|---|
| SiliconFlow | `SILICONFLOW_API_KEY` |
| Ollama | `OLLAMA_BASE_URL`（可选，默认 http://127.0.0.1:11434）|


## SDK 使用

```python
from pathlib import Path
from multi_ocr import get_engine, ocr_file, OCREngine

# 创建引擎
engine = get_engine(
    provider="siliconflow",
    model="deepseek-ai/DeepSeek-OCR",
    api_key="your-api-key",
)

# 识别图片
text = engine.parse_image(Path("scan.jpg"))

# 识别 PDF
result = ocr_file(Path("document.pdf"), engine, pages="1-3")

# 批量处理目录
from multi_ocr import ocr_directory
ocr_directory(Path("./scans/"), engine, concurrency=4)
```

### 自定义引擎

```python
from multi_ocr import OCREngine

class MyEngine(OCREngine):
    def parse_image(self, image_path: Path) -> str:
        # 你的 OCR 逻辑
        return "recognized text"
```

## 要求

- Python >= 3.11

## 协议

MIT License
