feat(fields): 字段抽取支持按行锁定与多项匹配开关,修复进度日志被吞
字段抽取 src/ocr_server/fields.py - 新增 row:只从第 N 行取值,行号由 bbox 纵向重叠的坐标分组得出,-1 表示不限定; 用于排除正文/页眉里同名标签造成的误取 - 新增 separator_optional(标签后无冒号也抽,默认关闭) 与 label_linebreak(标签内部跨行,如 姓 + 名:,默认关闭) - 新增 occurrence(first/last,正副本、页眉页脚重复打印时取最后一个) 与全局 extract_include_empty(未命中的字段返回空串,便于固定 schema) - 修复:跨行命中的标签文本包含换行,归一化时未去换行导致匹配不到字段规则、 取到的值被丢弃 - build_specs 在服务启动时校验:字段名重复、同一标签被多个字段共用、 正则语法、max_length / occurrence / row 取值合法性 日志 src/ocr_server/logging_setup.py - handler 改挂到 ocr_server logger 并关闭向 root 传播:Paddle 初始化会把 root 级别改成 WARNING,依赖 root 会导致其后所有 INFO 日志(含 10/20/50/80/100 进度行)被静默过滤,看起来像任务卡死 引擎配置 - enable_mkldnn 由写死的 False 改为可配置;cpu_threads 支持 max(吃满逻辑核心) - pyproject 固定 paddlepaddle>=3.2,<3.3:3.3.x 的 PIR + oneDNN 组合会直接推理失败 打包 - 移除多余的 scripts 目录打包;新增 -DistPath 便于 dist 被占用时改址构建; 构建结束输出 exe SHA256(避免再拿到旧产物) - Ubuntu 脚本同步更新,并输出二进制 SHA256 文档 - README / config.yaml 注释按实测修订:行结构、模型档位对比、oneDNN 与版本差异、 汉字字符类的范围与缺口、防止取错的机制与建议 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,8 @@ if __name__ == "__main__":
|
||||
text_det_unclip_ratio=settings.text_det_unclip_ratio,
|
||||
text_rec_score_thresh=settings.text_rec_score_thresh,
|
||||
text_recognition_batch_size=settings.text_recognition_batch_size,
|
||||
cpu_threads=settings.cpu_threads,
|
||||
cpu_threads=settings.cpu_threads_resolved,
|
||||
enable_mkldnn=settings.enable_mkldnn,
|
||||
)
|
||||
service.prepare()
|
||||
|
||||
@@ -36,7 +37,8 @@ if __name__ == "__main__":
|
||||
lines = service.recognize(image_path, on_progress=on_progress)
|
||||
elapsed_ms = (perf_counter() - started) * 1000
|
||||
print(f"image={image_path}")
|
||||
print(f"cpu_threads={settings.cpu_threads}")
|
||||
print(f"cpu_threads={settings.cpu_threads_resolved} (config={settings.cpu_threads})")
|
||||
print(f"enable_mkldnn={settings.enable_mkldnn}")
|
||||
print(f"det={settings.det_model_name} rec={settings.rec_model_name}")
|
||||
print(f"elapsed_ms={elapsed_ms:.2f}")
|
||||
print(f"segments={len(lines)}")
|
||||
|
||||
Reference in New Issue
Block a user