Views
No views yet
| Model | mAP(0.5) (%) |
|---|---|
| PicoDet-L_layout_3cls | 88.2 |
1# for CUDA11.8
2python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
3
4# for CUDA12.6
5python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
6
7# for CPU
8python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/python -m pip install paddleocr1paddleocr layout_detection \
2 --model_name PicoDet-L_layout_3cls \
3 -i https://cdn-uploads.huggingface.co/production/uploads/63d7b8ee07cd1aa3c49a2026/N5C68HPVAI-xQAWTxpbA6.jpeg1from paddleocr import LayoutDetection
2
3model = LayoutDetection(model_name="PicoDet-L_layout_3cls")
4output = model.predict("N5C68HPVAI-xQAWTxpbA6.jpeg", batch_size=1, layout_nms=True)
5for res in output:
6 res.print()
7 res.save_to_img(save_path="./output/")
8 res.save_to_json(save_path="./output/res.json"){'res': {'input_path': '/root/.paddlex/predict_input/N5C68HPVAI-xQAWTxpbA6.jpeg', 'page_index': None, 'boxes': [{'cls_id': 1, 'label': 'table', 'score': 0.9604419469833374, 'coordinate': [75.01548, 105.75383, 322.04535, 299.34668]}, {'cls_id': 1, 'label': 'table', 'score': 0.9599140286445618, 'coordinate': [437.74323, 106.181526, 663.59216, 313.78995]}]}}
1paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数 --qianfan_api_key your_api_key --layout_detection_model_name PicoDet-L_layout_3cls
2save_path.1from paddleocr import PPChatOCRv4Doc
2
3chat_bot_config = {
4 "module_name": "chat_bot",
5 "model_name": "ernie-3.5-8k",
6 "base_url": "https://qianfan.baidubce.com/v2",
7 "api_type": "openai",
8 "api_key": "api_key", # your api_key
9}
10
11retriever_config = {
12 "module_name": "retriever",
13 "model_name": "embedding-v1",
14 "base_url": "https://qianfan.baidubce.com/v2",
15 "api_type": "qianfan",
16 "api_key": "api_key", # your api_key
17}
18
19mllm_chat_bot_config = {
20 "module_name": "chat_bot",
21 "model_name": "PP-DocBee2",
22 "base_url": "http://127.0.0.1:8080/", # your local mllm service url
23 "api_type": "openai",
24 "api_key": "api_key", # your api_key
25}
26
27pipeline = PPChatOCRv4Doc(
28 layout_detection_model_name="PicoDet-L_layout_3cls",
29)
30
31visual_predict_res = pipeline.visual_predict(
32 input="vehicle_certificate-1.png",
33 use_doc_orientation_classify=False,
34 use_doc_unwarping=False,
35 use_common_ocr=True,
36 use_seal_recognition=True,
37 use_table_recognition=True,
38)
39
40visual_info_list = []
41for res in visual_predict_res:
42 visual_info_list.append(res["visual_info"])
43 layout_parsing_result = res["layout_parsing_result"]
44
45vector_info = pipeline.build_vector(
46 visual_info_list, flag_save_bytes_vector=True, retriever_config=retriever_config
47)
48mllm_predict_res = pipeline.mllm_pred(
49 input="vehicle_certificate-1.png",
50 key_list=["驾驶室准乘人数"],
51 mllm_chat_bot_config=mllm_chat_bot_config,
52)
53mllm_predict_info = mllm_predict_res["mllm_res"]
54chat_result = pipeline.chat(
55 key_list=["驾驶室准乘人数"],
56 visual_info=visual_info_list,
57 vector_info=vector_info,
58 mllm_predict_info=mllm_predict_info,
59 chat_bot_config=chat_bot_config,
60 retriever_config=retriever_config,
61)
62print(chat_result)RT-DETR-H_layout_3cls, so it is needed that specifing to PicoDet-L_layout_3cls by argument layout_detection_model_name. And you can also use the local model file by argument layout_detection_model_dir. For details about usage command and descriptions of parameters, please refer to the Document.