MCPcopy
hub / github.com/PaddlePaddle/PaddleOCR / save_structure_res

Function save_structure_res

ppstructure/predict_system.py:274–301  ·  view source on GitHub ↗
(res, save_folder, img_name, img_idx=0)

Source from the content-addressed store, hash-verified

272
273
274def save_structure_res(res, save_folder, img_name, img_idx=0):
275 excel_save_folder = os.path.join(save_folder, img_name)
276 os.makedirs(excel_save_folder, exist_ok=True)
277 res_cp = deepcopy(res)
278 # save res
279 with open(
280 os.path.join(excel_save_folder, "res_{}.txt".format(img_idx)),
281 "w",
282 encoding="utf8",
283 ) as f:
284 for region in res_cp:
285 roi_img = region.pop("img")
286 f.write("{}\n".format(json.dumps(region)))
287
288 if (
289 region["type"].lower() == "table"
290 and len(region["res"]) > 0
291 and "html" in region["res"]
292 ):
293 excel_path = os.path.join(
294 excel_save_folder, "{}_{}.xlsx".format(region["bbox"], img_idx)
295 )
296 to_excel(region["res"]["html"], excel_path)
297 elif region["type"].lower() == "figure":
298 img_path = os.path.join(
299 excel_save_folder, "{}_{}.jpg".format(region["bbox"], img_idx)
300 )
301 cv2.imwrite(img_path, roi_img)
302
303
304def main(args):

Callers 2

ppocrPrecitorMethod · 0.90
mainFunction · 0.70

Calls 3

to_excelFunction · 0.90
formatMethod · 0.80
popMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…