소스 검색

Merge pull request #866 from myhloli/dev

fix(table): improve table image processing
Xiaomeng Zhao 1 년 전
부모
커밋
7ca195e717
2개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 0 1
      docs/README_Ubuntu_CUDA_Acceleration_zh_CN.md
  2. 3 1
      magic_pdf/model/ppTableModel.py

+ 0 - 1
docs/README_Ubuntu_CUDA_Acceleration_zh_CN.md

@@ -11,7 +11,6 @@ nvidia-smi
 注意:`CUDA Version` 显示的版本号应 >= 12.1,如显示的版本号小于12.1,请升级驱动
 
 ```plaintext
-```
 +---------------------------------------------------------------------------------------+
 | NVIDIA-SMI 537.34                 Driver Version: 537.34       CUDA Version: 12.2     |
 |-----------------------------------------+----------------------+----------------------+

+ 3 - 1
magic_pdf/model/ppTableModel.py

@@ -1,3 +1,4 @@
+import cv2
 from paddleocr.ppstructure.table.predict_table import TableSystem
 from paddleocr.ppstructure.utility import init_args
 from magic_pdf.libs.Constants import *
@@ -36,7 +37,8 @@ class ppTableModel(object):
         - HTML (str): A string representing the HTML structure with content of the table.
         """
         if isinstance(image, Image.Image):
-            image = np.array(image)
+            image = np.asarray(image)
+            image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
         pred_res, _ = self.table_sys(image)
         pred_html = pred_res["html"]
         # res = '<td><table  border="1">' + pred_html.replace("<html><body><table>", "").replace(