u
This commit is contained in:
1 parent
3b70d0da3b
commit
d81386c22b
12 files changed
-5951
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 558 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 547 KiB |
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 348 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 309 KiB |
File diff suppressed because it is too large.
Load diff
@@ -1,74 +0,0 @@
|
||||
from paddleocr import PPChatOCRv4Doc
|
||||
import paddle
|
||||
# 检查 PaddlePaddle 是否安装成功
|
||||
# 打印是否支持 GPU
|
||||
print("是否支持 GPU:", paddle.is_compiled_with_cuda())
|
||||
|
||||
# 如果支持,再看看当前是否在使用 GPU
|
||||
if paddle.is_compiled_with_cuda():
|
||||
print("当前是否使用 GPU:", paddle.device.get_device())
|
||||
|
||||
chat_bot_config = {
|
||||
"module_name": "chat_bot",
|
||||
"model_name": "ernie-3.5-8k",
|
||||
"base_url": "https://qianfan.baidubce.com/v2",
|
||||
"api_type": "openai",
|
||||
"api_key": "bce-v3/ALTAK-5bKjjmEZxz7bnIjpWxxZT/723849a3548dc0d9f639b0ffaed5255a1ccf3f30", # your api_key
|
||||
}
|
||||
|
||||
retriever_config = {
|
||||
"module_name": "retriever",
|
||||
"model_name": "embedding-v1",
|
||||
"base_url": "https://qianfan.baidubce.com/v2",
|
||||
"api_type": "qianfan",
|
||||
"api_key": "bce-v3/ALTAK-5bKjjmEZxz7bnIjpWxxZT/723849a3548dc0d9f639b0ffaed5255a1ccf3f30", # your api_key
|
||||
}
|
||||
|
||||
pipeline = PPChatOCRv4Doc(
|
||||
use_doc_orientation_classify=False,
|
||||
use_doc_unwarping=False
|
||||
)
|
||||
|
||||
visual_predict_res = pipeline.visual_predict(
|
||||
input="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/vehicle_certificate-1.png",
|
||||
use_common_ocr=True,
|
||||
use_seal_recognition=True,
|
||||
use_table_recognition=True,
|
||||
)
|
||||
|
||||
mllm_predict_info = None
|
||||
use_mllm = False
|
||||
# 如果使用多模态大模型,需要启动本地 mllm 服务,可以参考文档:https://github.com/PaddlePaddle/PaddleX/blob/release/3.0/docs/pipeline_usage/tutorials/vlm_pipelines/doc_understanding.md 进行部署,并更新 mllm_chat_bot_config 配置。
|
||||
if use_mllm:
|
||||
mllm_chat_bot_config = {
|
||||
"module_name": "chat_bot",
|
||||
"model_name": "PP-DocBee",
|
||||
"base_url": "http://127.0.0.1:8080/", # your local mllm service url
|
||||
"api_type": "openai",
|
||||
"api_key": "api_key", # your api_key
|
||||
}
|
||||
|
||||
mllm_predict_res = pipeline.mllm_pred(
|
||||
input="test1.png",
|
||||
key_list=["Shipper"],
|
||||
mllm_chat_bot_config=mllm_chat_bot_config,
|
||||
)
|
||||
mllm_predict_info = mllm_predict_res["mllm_res"]
|
||||
|
||||
visual_info_list = []
|
||||
for res in visual_predict_res:
|
||||
visual_info_list.append(res["visual_info"])
|
||||
layout_parsing_result = res["layout_parsing_result"]
|
||||
|
||||
vector_info = pipeline.build_vector(
|
||||
visual_info_list, flag_save_bytes_vector=True, retriever_config=retriever_config
|
||||
)
|
||||
chat_result = pipeline.chat(
|
||||
key_list=["Shipper"],
|
||||
visual_info=visual_info_list,
|
||||
vector_info=vector_info,
|
||||
mllm_predict_info=mllm_predict_info,
|
||||
chat_bot_config=chat_bot_config,
|
||||
retriever_config=retriever_config,
|
||||
)
|
||||
print(chat_result)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 81 KiB |
Reference in new issue
Block a user