MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / process_batch

Function process_batch

tools/infer_doc.py:796–817  ·  view source on GitHub ↗
(process_batch_list: list, gpuId: int, output_path: str,
                  is_save_vis_img: bool, is_save_json: bool,
                  is_save_markdown: bool, pretty: bool)

Source from the content-addressed store, hash-verified

794
795
796def 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
820if __name__ == '__main__':

Callers 1

infer_doc.pyFile · 0.85

Calls 4

predictMethod · 0.95
OpenDocClass · 0.85
save_to_jsonMethod · 0.45
save_to_markdownMethod · 0.45

Tested by

no test coverage detected