2 Commits abf5932769 ... db2f73aa2e

Autor SHA1 Mensaje Fecha
  zhch158_admin db2f73aa2e feat(batch_process_pdf): 添加场景参数处理逻辑,支持默认场景参数名和必填校验 hace 1 semana
  zhch158_admin a2ddb4c408 fix(cell_fusion): 移除过滤条件中的 'unet_only' 标记,并添加极薄/极窄噪声框过滤 hace 1 semana

+ 12 - 0
ocr_tools/ocr_batch/batch_process_pdf.py

@@ -829,6 +829,10 @@ def main():
     if args.extra_args and args.processor:
         processor_config.extra_args = args.extra_args.split()
     
+    # 若处理器未配置scene_arg但用户提供了scene,使用默认场景参数名
+    if args.scene and not processor_config.scene_arg:
+        processor_config.scene_arg = args.scene_arg
+
     # 覆盖虚拟环境
     if args.venv:
         processor_config.venv = args.venv
@@ -870,6 +874,14 @@ def main():
             print(f"  - {t.path}{scene_suffix}")
         if len(invalid_files) > 5:
             print(f"  ... 还有 {len(invalid_files) - 5} 个")
+
+    # scene 必填校验(当处理器需要scene时)
+    if processor_config.scene_arg and not args.scene:
+        missing_scene = [t for t in valid_files if not t.scene]
+        if missing_scene:
+            print("\n❌ 当前处理器需要场景参数,但文件列表未提供scene且未指定--scene")
+            print("   解决方法: \n1) 在列表中使用 '文件名\t场景' \n2) 或使用命令行 --scene bank_statement|financial_report")
+            return 1
     
     # 确认执行
     if not args.dry_run and valid_files:

+ 8 - 1
ocr_tools/universal_doc_parser/models/adapters/wired_table/cell_fusion.py

@@ -721,7 +721,6 @@ class CellFusionEngine:
         过滤边界噪声单元格
         
         过滤条件:
-        1. 单元格标记为 'unet_only'(只在 UNet 中检测到,RT-DETR 未匹配)
         2. 单元格位于表格边界(左边界或右边界)
         3. 单元格内没有任何 OCR 文本框(说明是空白区域)
         
@@ -748,6 +747,14 @@ class CellFusionEngine:
             #     continue
             
             x1, y1, x2, y2 = cell
+
+            # 过滤极薄/极窄的噪声框(无论是否在边界)
+            if tol > 0.0 and (abs(x2 - x1) < tol or abs(y2 - y1) < tol):
+                logger.debug(
+                    f"🗑️ 过滤异常细线框: [{x1:.1f}, {y1:.1f}, {x2:.1f}, {y2:.1f}] (tol={tol})"
+                )
+                filtered_count += 1
+                continue
             
             # 检查是否在边界(加入容忍范围,避免贴边被误判)
             is_left_boundary = x1 <= (rtdetr_bbox[0] - tol)