|
|
@@ -5,12 +5,14 @@
|
|
|
## ✨ 核心功能
|
|
|
|
|
|
### 🎯 多工具 OCR 支持
|
|
|
+
|
|
|
- **Dots OCR**:专业 VLM OCR 引擎
|
|
|
- **PaddleOCR PPStructV3**:结构化文档识别
|
|
|
- **Table Recognition V2**:专业表格识别
|
|
|
- **MinerU VLM-2.5.3**:多模态文档理解
|
|
|
|
|
|
### 🔄 智能交叉验证
|
|
|
+
|
|
|
- **多数据源对比**:支持不同 OCR 工具结果的交叉验证
|
|
|
- **细粒度差异检测**:精确到单元格级别的差异分析
|
|
|
- **智能表格对比**:
|
|
|
@@ -24,6 +26,7 @@
|
|
|
- 段落差异
|
|
|
|
|
|
### 📊 可视化校验工具
|
|
|
+
|
|
|
- **交互式图像标注**:点击文本高亮对应图像位置
|
|
|
- **精确坐标定位**:基于 bbox 的精确位置标示
|
|
|
- **旋转角度处理**:
|
|
|
@@ -37,6 +40,7 @@
|
|
|
- 原始文本
|
|
|
|
|
|
### 📈 表格数据分析
|
|
|
+
|
|
|
- **智能表格解析**:自动识别并转换 HTML 表格
|
|
|
- **交互式操作**:
|
|
|
- 过滤(按列值、关键词)
|
|
|
@@ -47,6 +51,7 @@
|
|
|
- **统计分析**:自动生成数值列统计信息
|
|
|
|
|
|
### 🔧 数字标准化
|
|
|
+
|
|
|
- 全角/半角字符转换
|
|
|
- 千分位分隔符标准化
|
|
|
- 小数点格式统一
|
|
|
@@ -106,18 +111,21 @@ python run_streamlit_validator.py
|
|
|
**功能模块:**
|
|
|
|
|
|
#### 📄 内容人工检查
|
|
|
+
|
|
|
- 选择数据源和页码
|
|
|
- 点击文本内容查看图像位置
|
|
|
- 旋转图像调整角度
|
|
|
- 显示所有文本框或仅显示选中框
|
|
|
|
|
|
#### 🔍 交叉验证结果
|
|
|
+
|
|
|
- 选择两个不同的 OCR 数据源
|
|
|
- 点击「交叉验证」按钮运行批量验证
|
|
|
- 查看详细的差异对比结果
|
|
|
- 下载验证报告(Excel、JSON)
|
|
|
|
|
|
#### 📊 表格分析
|
|
|
+
|
|
|
- 解析 HTML 表格为 DataFrame
|
|
|
- 过滤、排序、搜索表格数据
|
|
|
- 导出表格为 CSV 或 Excel
|
|
|
@@ -125,7 +133,7 @@ python run_streamlit_validator.py
|
|
|
|
|
|
### 2️⃣ 命令行对比工具
|
|
|
|
|
|
-使用 [`compare_ocr_results.py`](compare_ocr_results.py) 进行命令行对比:
|
|
|
+使用 [comparator/compare_ocr_results.py](compare_ocr_results.py) 进行命令行对比:
|
|
|
|
|
|
```bash
|
|
|
# 基本对比
|
|
|
@@ -144,6 +152,7 @@ python compare_ocr_results.py file1.md file2.md \
|
|
|
```
|
|
|
|
|
|
**参数说明:**
|
|
|
+
|
|
|
- `-o, --output`:输出文件名(不含扩展名)
|
|
|
- `-f, --format`:输出格式(`json`、`markdown`、`both`)
|
|
|
- `--table-mode`:表格比对模式(`standard`、`flow_list`)
|
|
|
@@ -196,20 +205,21 @@ ocr_verify/
|
|
|
### 交叉验证流程
|
|
|
|
|
|
1. **数据源选择**
|
|
|
+
|
|
|
- 选择 OCR 数据源(如 PPStructV3)
|
|
|
- 选择验证数据源(如 MinerU)
|
|
|
-
|
|
|
2. **批量验证**
|
|
|
+
|
|
|
- 自动匹配相同页码的文件
|
|
|
- 逐页进行差异检测
|
|
|
- 生成详细验证报告
|
|
|
-
|
|
|
3. **差异分析**
|
|
|
+
|
|
|
- 表格差异:逐单元格对比
|
|
|
- 段落差异:智能段落匹配
|
|
|
- 结构差异:表头位置、行缺失等
|
|
|
-
|
|
|
4. **结果展示**
|
|
|
+
|
|
|
- 差异列表(按类型、严重程度分类)
|
|
|
- 统计图表(饼图、柱状图)
|
|
|
- 详细对比视图(左右对照)
|
|
|
@@ -217,11 +227,13 @@ ocr_verify/
|
|
|
### 表格对比算法
|
|
|
|
|
|
#### 标准模式 (`standard`)
|
|
|
+
|
|
|
- 适用于结构固定的表格
|
|
|
- 逐行逐列对比
|
|
|
- 适合财务报表、数据统计表
|
|
|
|
|
|
#### 流水表格模式 (`flow_list`)
|
|
|
+
|
|
|
- 智能检测表头位置
|
|
|
- 支持表头前内容对比
|
|
|
- 自动列类型检测(数字、日期、文本)
|
|
|
@@ -247,6 +259,7 @@ rotated_image, rotated_bboxes = rotate_image_and_coordinates(
|
|
|
### 交叉验证报告
|
|
|
|
|
|
#### JSON 格式
|
|
|
+
|
|
|
```json
|
|
|
{
|
|
|
"differences": [
|
|
|
@@ -276,6 +289,7 @@ rotated_image, rotated_bboxes = rotate_image_and_coordinates(
|
|
|
```
|
|
|
|
|
|
#### Markdown 格式
|
|
|
+
|
|
|
```markdown
|
|
|
# OCR结果对比报告
|
|
|
|
|
|
@@ -307,7 +321,7 @@ ocr:
|
|
|
json_structure: "object"
|
|
|
rotation:
|
|
|
coordinates_are_pre_rotated: true
|
|
|
-
|
|
|
+
|
|
|
mineru:
|
|
|
name: "MinerU"
|
|
|
json_structure: "array"
|
|
|
@@ -315,45 +329,9 @@ ocr:
|
|
|
coordinates_are_pre_rotated: false
|
|
|
```
|
|
|
|
|
|
-### 合并 MinerU 和 Paddle OCR 结果
|
|
|
-```bash
|
|
|
-echo "A用户_单元格扫描流水"
|
|
|
-python merge_mineru_paddle_ocr.py \
|
|
|
- --mineru-dir "/Users/zhch158/workspace/data/流水分析/A用户_单元格扫描流水/mineru-vlm-2.5.3_Results" \
|
|
|
- --paddle-dir "/Users/zhch158/workspace/data/流水分析/A用户_单元格扫描流水/data_PPStructureV3_Results" \
|
|
|
- --output-dir "/Users/zhch158/workspace/data/流水分析/A用户_单元格扫描流水/merged_results" \
|
|
|
- --format "both"
|
|
|
-
|
|
|
-echo "B用户_扫描流水"
|
|
|
-python merge_mineru_paddle_ocr.py \
|
|
|
- --mineru-dir "/Users/zhch158/workspace/data/流水分析/B用户_扫描流水/mineru-vlm-2.5.3_Results" \
|
|
|
- --paddle-dir "/Users/zhch158/workspace/data/流水分析/B用户_扫描流水/data_PPStructureV3_Results" \
|
|
|
- --output-dir "/Users/zhch158/workspace/data/流水分析/B用户_扫描流水/merged_results" \
|
|
|
- --format "both"
|
|
|
-
|
|
|
-echo "德_内蒙古银行照"
|
|
|
-python merge_mineru_paddle_ocr.py \
|
|
|
- --mineru-dir "/Users/zhch158/workspace/data/流水分析/德_内蒙古银行照/mineru-vlm-2.5.3_Results" \
|
|
|
- --paddle-dir "/Users/zhch158/workspace/data/流水分析/德_内蒙古银行照/data_PPStructureV3_Results" \
|
|
|
- --output-dir "/Users/zhch158/workspace/data/流水分析/德_内蒙古银行照/merged_results" \
|
|
|
- --format "both"
|
|
|
-
|
|
|
-echo "对公_招商银行图"
|
|
|
-python merge_mineru_paddle_ocr.py \
|
|
|
- --mineru-dir "/Users/zhch158/workspace/data/流水分析/对公_招商银行图/mineru-vlm-2.5.3_Results" \
|
|
|
- --paddle-dir "/Users/zhch158/workspace/data/流水分析/对公_招商银行图/data_PPStructureV3_Results" \
|
|
|
- --output-dir "/Users/zhch158/workspace/data/流水分析/对公_招商银行图/merged_results" \
|
|
|
- --format "both"
|
|
|
-
|
|
|
-echo "至远彩色印刷工业有限公司"
|
|
|
-python merge_mineru_paddle_ocr.py \
|
|
|
- --mineru-dir "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/mineru-vlm-2.5.3_Results" \
|
|
|
- --paddle-dir "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/data_PPStructureV3_Results" \
|
|
|
- --output-dir "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/merged_results" \
|
|
|
- --format "both"
|
|
|
-
|
|
|
+### MinerU, PaddleOCR-VL表格单元格坐标使用 Paddle OCR全局OCR文本块坐标
|
|
|
|
|
|
-```
|
|
|
+详见[merger-说明.md](merger/merger-说明.md)
|
|
|
|
|
|
### Streamlit 配置
|
|
|
|
|
|
@@ -373,17 +351,21 @@ enableXsrfProtection = true
|
|
|
## 🐛 常见问题
|
|
|
|
|
|
### Q1: 图像显示位置不正确?
|
|
|
+
|
|
|
**A:** 检查 OCR 工具的坐标是否已预旋转,在 `config.yaml` 中调整 `coordinates_are_pre_rotated` 设置。
|
|
|
|
|
|
### Q2: 交叉验证结果为空?
|
|
|
+
|
|
|
**A:** 确保两个数据源包含相同页码的文件,且文件名格式为 `*_page_XXX.json`。
|
|
|
|
|
|
### Q3: 表格对比差异过多?
|
|
|
+
|
|
|
**A:** 尝试切换到 `flow_list` 模式,或调整相似度算法参数。
|
|
|
|
|
|
## 📝 开发说明
|
|
|
|
|
|
### 扩展开发
|
|
|
+
|
|
|
- 新增 OCR 工具:在 `ocr_validator_utils.py` 中添加解析函数
|
|
|
- 自定义对比算法:继承 `OCRResultComparator` 类
|
|
|
- 新增渲染模式:在 `ocr_validator_layout.py` 中扩展
|
|
|
@@ -412,4 +394,4 @@ enableXsrfProtection = true
|
|
|
|
|
|
---
|
|
|
|
|
|
-**最后更新**: 2025年10月10日
|
|
|
+**最后更新**: 2025年10月10日
|