Files
dsProject/dsLightRag/Util/GGB/GGB_5_FULL.py
2025-08-14 15:45:08 +08:00

37 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import logging
from Util.GGB.GGB_1_CUT import yoloCut
from Util.GGB.GGB_2_OCR import pix2text_ocr
from Util.GGB.GGB_3_GLM import batch_glm
from Util.GGB.GGB_4_LLM import generate_ggb
# 更详细地控制日志输出
logger = logging.getLogger('GGB')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.addHandler(handler)
if __name__ == '__main__':
# 图片路径
image_path = '../../Test/img10.jpg'
# 步骤1调用yoloCut函数
output_dir, processed_image_path, img_list = yoloCut(image_path)
# 步骤2调用pix2text_ocr函数
ocr_result = pix2text_ocr(output_dir, processed_image_path)
logger.info(f"成功生成文字+公式OCR文件: {ocr_result}")
# 步骤3调用QVQ解析图片
qvq_result = batch_glm(output_dir, img_list)
logger.info(f"成功生成图形解析文件: {qvq_result}")
# 步骤4生成GGB指令
ggb = generate_ggb(ocr_result, qvq_result, output_dir)
logger.info(f"成功生成GGB文件: {ggb}")
# 步骤5输出GGB指令集
with open(ggb, 'r', encoding='utf-8') as f:
print(f.read())