chore: Clean up and refactor codebase for improved maintainability
- Removed obsolete command-line test parameters from `run_cli.py` to streamline functionality. - Introduced a new `ocr_preprocess.py` module for unified OCR image preprocessing, enhancing recognition stability. - Updated various components to utilize the new preprocessing function, improving code organization and readability. - Adjusted configuration values in `config.json` for better performance and consistency. - Added comprehensive technical documentation for the Douyin project, detailing code modification standards and operational guidelines. - Cleaned up excessive blank lines across multiple files to enhance overall readability.
This commit is contained in:
1 parent
efe6e2252f
commit
223c127e11
70 files changed
+17121
-1752
No files matched your search
@@ -270,19 +270,8 @@ class underlying_operations:
|
||||
), contextlib.redirect_stderr(devnull):
|
||||
from paddleocr import PaddleOCR
|
||||
|
||||
# PaddleOCR的GPU支持需要paddlepaddle-gpu版本
|
||||
# 使用 PaddleOCR(强制 CPU 模式)
|
||||
use_gpu = False
|
||||
try:
|
||||
import paddle
|
||||
|
||||
if (
|
||||
paddle.device.is_compiled_with_cuda()
|
||||
and paddle.device.get_device()
|
||||
):
|
||||
use_gpu = False
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.ocr = PaddleOCR(
|
||||
lang="ch",
|
||||
ocr_version="PP-OCRv4",
|
||||
@@ -293,8 +282,7 @@ class underlying_operations:
|
||||
use_textline_orientation=False,
|
||||
)
|
||||
self.ocr_type = "paddleocr"
|
||||
gpu_status = "GPU加速" if use_gpu else "CPU模式"
|
||||
print(f"[OCR] EasyOCR不可用,使用 PaddleOCR({gpu_status})")
|
||||
print(f"[OCR] EasyOCR不可用,使用 PaddleOCR(CPU模式)")
|
||||
print(
|
||||
f"[OCR] 提示:安装EasyOCR可提升速度,运行: pip install easyocr"
|
||||
)
|
||||
@@ -373,19 +361,8 @@ class underlying_operations:
|
||||
):
|
||||
from paddleocr import PaddleOCR
|
||||
|
||||
# PaddleOCR的GPU支持需要paddlepaddle-gpu版本
|
||||
# 使用 PaddleOCR(强制 CPU 模式)
|
||||
use_gpu = False
|
||||
try:
|
||||
import paddle
|
||||
|
||||
if (
|
||||
paddle.device.is_compiled_with_cuda()
|
||||
and paddle.device.get_device()
|
||||
):
|
||||
use_gpu = False
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.ocr = PaddleOCR(
|
||||
lang="ch",
|
||||
ocr_version="PP-OCRv4",
|
||||
@@ -396,8 +373,7 @@ class underlying_operations:
|
||||
use_textline_orientation=False,
|
||||
)
|
||||
self.ocr_type = "paddleocr"
|
||||
gpu_status = "GPU加速" if use_gpu else "CPU模式"
|
||||
print(f"[OCR] 延迟初始化:使用 PaddleOCR({gpu_status})")
|
||||
print(f"[OCR] 延迟初始化:使用 PaddleOCR(CPU模式)")
|
||||
except Exception:
|
||||
self.ocr = None
|
||||
self.ocr_type = None
|
||||
|
||||
Reference in new issue
Block a user