|
|
@@ -7,32 +7,33 @@ from magic_pdf.model.sub_modules.language_detection.yolov11.YOLOv11 import YOLOv
|
|
|
from magic_pdf.model.sub_modules.layout.doclayout_yolo.DocLayoutYOLO import DocLayoutYOLOModel
|
|
|
from magic_pdf.model.sub_modules.mfd.yolov8.YOLOv8 import YOLOv8MFDModel
|
|
|
from magic_pdf.model.sub_modules.mfr.unimernet.Unimernet import UnimernetModel
|
|
|
-
|
|
|
-try:
|
|
|
- from magic_pdf_ascend_plugin.libs.license_verifier import (
|
|
|
- LicenseExpiredError, LicenseFormatError, LicenseSignatureError,
|
|
|
- load_license)
|
|
|
- from magic_pdf_ascend_plugin.model_plugin.ocr.paddleocr.ppocr_273_npu import ModifiedPaddleOCR
|
|
|
- from magic_pdf_ascend_plugin.model_plugin.table.rapidtable.rapid_table_npu import RapidTableModel
|
|
|
- license_key = load_license()
|
|
|
- logger.info(f'Using Ascend Plugin Success, License id is {license_key["payload"]["id"]},'
|
|
|
- f' License expired at {license_key["payload"]["date"]["end_date"]}')
|
|
|
-except Exception as e:
|
|
|
- if isinstance(e, ImportError):
|
|
|
- pass
|
|
|
- elif isinstance(e, LicenseFormatError):
|
|
|
- logger.error('Ascend Plugin: Invalid license format. Please check the license file.')
|
|
|
- elif isinstance(e, LicenseSignatureError):
|
|
|
- logger.error('Ascend Plugin: Invalid signature. The license may be tampered with.')
|
|
|
- elif isinstance(e, LicenseExpiredError):
|
|
|
- logger.error('Ascend Plugin: License has expired. Please renew your license.')
|
|
|
- elif isinstance(e, FileNotFoundError):
|
|
|
- logger.error('Ascend Plugin: Not found License file.')
|
|
|
- else:
|
|
|
- logger.error(f'Ascend Plugin: {e}')
|
|
|
- from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_273_mod import ModifiedPaddleOCR
|
|
|
- # from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_291_mod import ModifiedPaddleOCR
|
|
|
- from magic_pdf.model.sub_modules.table.rapidtable.rapid_table import RapidTableModel
|
|
|
+from magic_pdf.model.sub_modules.ocr.paddleocr2pytorch.pytorch_paddle import PytorchPaddleOCR
|
|
|
+from magic_pdf.model.sub_modules.table.rapidtable.rapid_table import RapidTableModel
|
|
|
+# try:
|
|
|
+# from magic_pdf_ascend_plugin.libs.license_verifier import (
|
|
|
+# LicenseExpiredError, LicenseFormatError, LicenseSignatureError,
|
|
|
+# load_license)
|
|
|
+# from magic_pdf_ascend_plugin.model_plugin.ocr.paddleocr.ppocr_273_npu import ModifiedPaddleOCR
|
|
|
+# from magic_pdf_ascend_plugin.model_plugin.table.rapidtable.rapid_table_npu import RapidTableModel
|
|
|
+# license_key = load_license()
|
|
|
+# logger.info(f'Using Ascend Plugin Success, License id is {license_key["payload"]["id"]},'
|
|
|
+# f' License expired at {license_key["payload"]["date"]["end_date"]}')
|
|
|
+# except Exception as e:
|
|
|
+# if isinstance(e, ImportError):
|
|
|
+# pass
|
|
|
+# elif isinstance(e, LicenseFormatError):
|
|
|
+# logger.error('Ascend Plugin: Invalid license format. Please check the license file.')
|
|
|
+# elif isinstance(e, LicenseSignatureError):
|
|
|
+# logger.error('Ascend Plugin: Invalid signature. The license may be tampered with.')
|
|
|
+# elif isinstance(e, LicenseExpiredError):
|
|
|
+# logger.error('Ascend Plugin: License has expired. Please renew your license.')
|
|
|
+# elif isinstance(e, FileNotFoundError):
|
|
|
+# logger.error('Ascend Plugin: Not found License file.')
|
|
|
+# else:
|
|
|
+# logger.error(f'Ascend Plugin: {e}')
|
|
|
+# from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_273_mod import ModifiedPaddleOCR
|
|
|
+# # from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_291_mod import ModifiedPaddleOCR
|
|
|
+# from magic_pdf.model.sub_modules.table.rapidtable.rapid_table import RapidTableModel
|
|
|
|
|
|
|
|
|
def table_model_init(table_model_type, model_path, max_time, _device_='cpu', ocr_engine=None, table_sub_model_name=None):
|
|
|
@@ -94,7 +95,8 @@ def ocr_model_init(show_log: bool = False,
|
|
|
det_db_unclip_ratio=1.8,
|
|
|
):
|
|
|
if lang is not None and lang != '':
|
|
|
- model = ModifiedPaddleOCR(
|
|
|
+ # model = ModifiedPaddleOCR(
|
|
|
+ model = PytorchPaddleOCR(
|
|
|
show_log=show_log,
|
|
|
det_db_box_thresh=det_db_box_thresh,
|
|
|
lang=lang,
|
|
|
@@ -102,7 +104,8 @@ def ocr_model_init(show_log: bool = False,
|
|
|
det_db_unclip_ratio=det_db_unclip_ratio,
|
|
|
)
|
|
|
else:
|
|
|
- model = ModifiedPaddleOCR(
|
|
|
+ # model = ModifiedPaddleOCR(
|
|
|
+ model = PytorchPaddleOCR(
|
|
|
show_log=show_log,
|
|
|
det_db_box_thresh=det_db_box_thresh,
|
|
|
use_dilation=use_dilation,
|