Jelajahi Sumber

feat: 更新表格识别适配器,优化条件判断以支持无线表格单元格转换

zhch158_admin 1 bulan lalu
induk
melakukan
9304cd7f18
2 mengubah file dengan 17 tambahan dan 1 penghapusan
  1. 14 0
      zhch/adapters/__init__.py
  2. 3 1
      zhch/adapters/table_recognition_adapter.py

+ 14 - 0
zhch/adapters/__init__.py

@@ -0,0 +1,14 @@
+"""
+适配器包初始化 - 支持自动激活
+"""
+from .table_recognition_adapter import (
+    apply_table_recognition_adapter,
+    restore_original_function,
+    enhanced_predict_single_table_recognition_res
+)
+
+__all__ = [
+    'apply_table_recognition_adapter',
+    'restore_original_function',
+    'enhanced_predict_single_table_recognition_res'
+]

+ 3 - 1
zhch/adapters/table_recognition_adapter.py

@@ -386,7 +386,7 @@ def enhanced_predict_single_table_recognition_res(
     table_ocr_pred = get_sub_regions_ocr_res(overall_ocr_res, table_box_array)
     
     # 🎯 Step 4: **关键改进** - OCR引导的单元格补全
-    if use_wired_table_cells_trans_to_html and use_ocr_results_with_table_cells:
+    if (use_wired_table_cells_trans_to_html or use_wireless_table_cells_trans_to_html) and use_ocr_results_with_table_cells:
         # ✅ 对每个单元格做OCR(使用裁剪前的坐标)
         cells_texts_list = self.gen_ocr_with_table_cells(image_array, table_cells_result)
         # ✅ 补全缺失的单元格
@@ -419,6 +419,8 @@ def enhanced_predict_single_table_recognition_res(
         return res
     else:
         # 回退到原始实现
+        print(f"Fallback to original implementation: {table_cls_result}: use_wired_table_cells_trans_to_html={use_wired_table_cells_trans_to_html}, use_wireless_table_cells_trans_to_html={use_wireless_table_cells_trans_to_html}, use_ocr_results_with_table_cells={use_ocr_results_with_table_cells}")
+
         return _original_predict_single(
             self, image_array, overall_ocr_res, table_box,
             use_e2e_wired_table_rec_model, use_e2e_wireless_table_rec_model,