From 6ca110f1f4c90799557086c974f564d4b2fbfb12 Mon Sep 17 00:00:00 2001 From: William Jin Date: Thu, 26 Sep 2024 16:06:06 +0800 Subject: [PATCH] fix bug --- chyoso_toolkit_ui.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/chyoso_toolkit_ui.py b/chyoso_toolkit_ui.py index fdf2960..c470678 100644 --- a/chyoso_toolkit_ui.py +++ b/chyoso_toolkit_ui.py @@ -176,16 +176,17 @@ def run_ocr(image): 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 + "--image-file", image_path, + "> /home/tmfc/apps/got-ocr/img.txt" ] - result = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - # 获取 OCR 识别的输出 - ocr_output = result.stdout - - return ocr_output - + try: + subprocess.run(command, check=True) + except subprocess.CalledProcessError as e: + return f"识别失败: {e}" + with open("/home/tmfc/apps/got-ocr/img.txt", 'r', encoding='utf-8') as f: + content = f.read() + return content with gr.Blocks() as iface: gr.Markdown("# 大模型工具集")