Skip to content

Commit

Permalink
避免在server.py中加载PaddleOCR
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Sep 30, 2023
1 parent 0536b70 commit f803943
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 2 additions & 0 deletions arknights_mower/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from arknights_mower.utils.simulator import restart_simulator
from arknights_mower.utils.email import task_template
from arknights_mower.utils.plan import Plan, PlanConfig, Room
import arknights_mower.utils.paddleocr

conf = {}
plan = {}
Expand Down Expand Up @@ -41,6 +42,7 @@ def main(c, p, o={}, child_conn=None):
Pipe.conn = child_conn
logger.info('开始运行Mower')
logger.debug(agent_base_config)
arknights_mower.utils.paddleocr.initialize_ocr()
simulate()

#newbing说用这个来定义休息时间省事
Expand Down
33 changes: 20 additions & 13 deletions arknights_mower/utils/paddleocr.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import os
from paddleocr import PaddleOCR


det_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "det", "ch")
rec_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "rec", "ch")
cls_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "cls")
ocr = None

ocr = PaddleOCR(
enable_mkldnn=False,
use_angle_cls=False,
cls=False,
show_log=False,
det_model_dir=det_model_dir,
rec_model_dir=rec_model_dir,
cls_model_dir=cls_model_dir,
)

def initialize_ocr():
det_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "det", "ch")
rec_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "rec", "ch")
cls_model_dir = os.path.join(os.getcwd(), "tmp", "paddle", "cls")

global ocr
if not ocr:
from paddleocr import PaddleOCR

ocr = PaddleOCR(
enable_mkldnn=False,
use_angle_cls=False,
cls=False,
show_log=False,
det_model_dir=det_model_dir,
rec_model_dir=rec_model_dir,
cls_model_dir=cls_model_dir,
)

0 comments on commit f803943

Please sign in to comment.