| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- from paddlex import create_pipeline
- pipeline = create_pipeline(pipeline="PP-ChatOCRv3-doc")
- # img_path = "./test_demo_imgs/vehicle_certificate-1.png"
- # key_list = ['驾驶室准乘人数']
- # img_path = "./test_demo_imgs/test_layout_parsing.jpg"
- # key_list = ['3.2的标题']
- img_path = "./test_demo_imgs/seal_text_det.png"
- key_list = ["印章上公司"]
- # visual_predict_res = pipeline.visual_predict(img_path,
- # use_doc_orientation_classify=True,
- # use_doc_unwarping=True,
- # use_common_ocr=True,
- # use_seal_recognition=True,
- # use_table_recognition=True)
- # ####[TODO] 增加类别信息
- # visual_info_list = []
- # for res in visual_predict_res:
- # visual_info_list.append(res["visual_info"])
- # pipeline.save_visual_info_list(visual_info_list, "./res_visual_info/visual_info3.json")
- visual_info_list = pipeline.load_visual_info_list("./res_visual_info/visual_info3.json")
- vector_info = pipeline.build_vector(visual_info_list)
- print(vector_info)
- final_results = pipeline.chat(visual_info_list, key_list, vector_info)
- print(final_results)
|