|
|
1 tuần trước cách đây | |
|---|---|---|
| .. | ||
| config | 1 tuần trước cách đây | |
| README.md | 1 tuần trước cách đây | |
| __init__.py | 1 tuần trước cách đây | |
| config_manager.py | 1 tuần trước cách đây | |
| ocr_validator_file_utils.py | 1 tuần trước cách đây | |
| ocr_validator_layout.py | 1 tuần trước cách đây | |
| ocr_validator_utils.py | 1 tuần trước cách đây | |
| run_streamlit_validator.py | 1 tuần trước cách đây | |
| streamlit_ocr_validator.py | 1 tuần trước cách đây | |
| streamlit_validator_core.py | 1 tuần trước cách đây | |
| streamlit_validator_cross.py | 1 tuần trước cách đây | |
| streamlit_validator_result.py | 1 tuần trước cách đây | |
| streamlit_validator_table.py | 1 tuần trước cách đây | |
| streamlit_validator_ui.py | 1 tuần trước cách đây | |
| styles.css | 1 tuần trước cách đây | |
一个功能强大的 OCR 识别与验证系统,集成了多种 OCR 工具支持、智能交叉验证、可视化校验和表格数据分析功能,专为财务报表、数据表格等复杂文档设计。
ocr_validator/
├── __init__.py # 包初始化文件
├── streamlit_ocr_validator.py # 主应用入口
├── streamlit_validator_core.py # 核心验证器类
├── streamlit_validator_ui.py # UI 组件
├── streamlit_validator_table.py # 表格处理
├── streamlit_validator_cross.py # 交叉验证
├── streamlit_validator_result.py # 结果展示
├── ocr_validator_layout.py # 布局管理
├── ocr_validator_utils.py # OCR 验证工具函数
├── ocr_validator_file_utils.py # 文件处理工具(Streamlit 特定)
├── config_manager.py # 配置管理器
├── run_streamlit_validator.py # 启动脚本
├── styles.css # 样式文件
├── config/ # 配置文件目录
│ ├── global.yaml
│ └── ... (其他配置文件)
└── README.md # 本文档
standard)flow_list)- 支持表头位置智能检测table_amount)- 严重度:hightable_datetime)- 严重度:mediumtable_text)- 严重度:low/medium(根据相似度)ocr_utils.image_utils.rotate_image_and_coordinates)ocr_utils.html_utils.process_html_images)ocr_utils.html_utils.process_markdown_images)ocr_utils.html_utils.parse_html_tables)ocr_utils.html_utils.convert_html_table_to_markdown)ocr_utils.number_utils)# 创建 conda 环境
conda create -n py312 python=3.12 -y
conda activate py312
# 进入 ocr_platform 目录
cd /path/to/ocr_platform
# 安装依赖
pip install streamlit plotly pandas pillow numpy opencv-python openpyxl \
beautifulsoup4 pyyaml fuzzywuzzy python-Levenshtein
编辑配置文件(详见 config/README.md):
config/global.yaml)data_sources:
- 德_内蒙古银行照.yaml
- 对公_招商银行图.yaml
- A用户_单元格扫描流水.yaml
- B用户_扫描流水.yaml
- 至远彩色_2023年报.yaml
config/B用户_扫描流水.yaml)name: "B用户_扫描流水"
description: "扫描流水数据验证"
data_path: "/path/to/data"
ocr:
tools:
dots_ocr:
name: "Dots OCR"
json_structure: "array"
text_field: "text"
bbox_field: "bbox"
category_field: "category"
confidence_field: "confidence"
# 方式 1: 使用启动脚本
cd /path/to/ocr_platform/ocr_validator
python run_streamlit_validator.py
# 方式 2: 直接使用 Streamlit
streamlit run streamlit_ocr_validator.py
ocr_utils:通用工具模块
ocr_utils.html_utils:HTML/Markdown 处理ocr_utils.image_utils:图像处理和旋转ocr_utils.visualization_utils:可视化工具ocr_utils.number_utils:数字标准化在 config/global.yaml 中配置数据源列表,每个数据源对应一个 YAML 配置文件。
系统会自动扫描配置的数据路径,查找 OCR 结果文件(JSON 格式)。
选择两个不同的 OCR 数据源进行对比,系统会自动检测差异并生成报告。
streamlit_ocr_validator.py:主入口,负责页面布局和路由streamlit_validator_core.py:核心验证器类,管理 OCR 数据和状态streamlit_validator_ui.py:UI 组件和页面配置streamlit_validator_table.py:表格处理和分析streamlit_validator_cross.py:交叉验证功能streamlit_validator_result.py:结果展示ocr_validator_layout.py:布局管理和图像处理ocr_validator_utils.py:OCR 验证专用工具函数ocr_validator_file_utils.py:Streamlit 特定的文件处理函数通用工具已提取到 ocr_utils 模块:
ocr_utils.html_utilsocr_utils.image_utils.rotate_image_and_coordinatesocr_utils.visualization_utils.VisualizationUtils.draw_bbox_on_imageconfig/ 目录下创建工具配置文件ocr_validator_utils.py 中添加数据解析函数config/global.yaml 添加数据源[根据项目许可证填写]
欢迎提交 Issue 和 Pull Request!