From 965331ebb61c17780feeca6ac98487df8e662171 Mon Sep 17 00:00:00 2001 From: William Jin Date: Thu, 26 Sep 2024 15:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=20conda=20=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chyoso_toolkit_ui.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/chyoso_toolkit_ui.py b/chyoso_toolkit_ui.py index d1e5b40..f064f79 100644 --- a/chyoso_toolkit_ui.py +++ b/chyoso_toolkit_ui.py @@ -172,21 +172,14 @@ def run_ocr(image): image_path = os.path.expanduser("/home/tmfc/apps/got-ocr/img.png") image.save(image_path) - # 激活 Conda 环境 - activate_env_command = "conda activate got" - # 调用 OCR 命令 - ocr_command = [ - "python3", "/home/tmfc/apps/got-ocr/GOT/demo/run_ocr_2.0_crop.py", + command = [ + "/home/tmfc/miniconda3/envs/got/bin/python3", "/home/tmfc/apps/got-ocr/GOT/demo/run_ocr_2.0_crop.py", "--model-name", "/home/tmfc/apps/got-ocr/models/", "--image-file", image_path ] - # 构建完整的命令 - full_command = f"{activate_env_command} && {' '.join(ocr_command)}" - - # 使用 shell 执行命令 - result = subprocess.run(full_command, shell=True, capture_output=True, text=True) + result = subprocess.run(command, capture_output=True, text=True) # 获取 OCR 识别的输出 ocr_output = result.stdout