(process_batch_list: list, gpuId: int, output_path: str,
is_save_vis_img: bool, is_save_json: bool,
is_save_markdown: bool, pretty: bool)
| 794 | |
| 795 | |
| 796 | def process_batch(process_batch_list: list, gpuId: int, output_path: str, |
| 797 | is_save_vis_img: bool, is_save_json: bool, |
| 798 | is_save_markdown: bool, pretty: bool): |
| 799 | |
| 800 | opendoc_pipeline = OpenDoc(gpuId=gpuId) |
| 801 | for img_path in process_batch_list: |
| 802 | img_name = os.path.basename(img_path)[:-4] |
| 803 | output = opendoc_pipeline.predict(img_path, |
| 804 | use_doc_orientation_classify=False, |
| 805 | use_doc_unwarping=False) |
| 806 | for res in output: |
| 807 | if is_save_vis_img: |
| 808 | res.save_to_img(output_path) |
| 809 | if is_save_json: |
| 810 | res.save_to_json(save_path=output_path) ## 保存当前图像的结构化json结果 |
| 811 | if is_save_markdown: |
| 812 | res.save_to_markdown(save_path=output_path, |
| 813 | pretty=pretty) ## 保存当前图像的markdown格式的结果 |
| 814 | if gpuId >= 0: |
| 815 | logger.info(f'GPU {gpuId} processing {img_name} done!') |
| 816 | else: |
| 817 | logger.info(f'CPU processing {img_name} done!') |
| 818 | |
| 819 | |
| 820 | if __name__ == '__main__': |
no test coverage detected