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("# 大模型工具集")