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

Function main

tools/infer_e2e.py:405–467  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

403
404
405def main():
406 parser = argparse.ArgumentParser(description='OpenOCR system')
407 parser.add_argument(
408 '--img_path',
409 type=str,
410 help='Path to the directory containing images or the image filename.')
411 parser.add_argument(
412 '--mode',
413 type=str,
414 default='mobile',
415 help="Mode of the OCR system, e.g., 'mobile' or 'server'.")
416 parser.add_argument(
417 '--backend',
418 type=str,
419 default='torch',
420 help="Backend of the OCR system, e.g., 'torch' or 'onnx'.")
421 parser.add_argument('--onnx_det_model_path',
422 type=str,
423 default=None,
424 help='Path to the ONNX model for text detection.')
425 parser.add_argument('--onnx_rec_model_path',
426 type=str,
427 default=None,
428 help='Path to the ONNX model for text recognition.')
429 parser.add_argument(
430 '--save_dir',
431 type=str,
432 default='e2e_results/',
433 help='Directory to save prediction and visualization results. \
434 Defaults to ./e2e_results/.')
435 parser.add_argument('--is_vis',
436 action='store_true',
437 default=False,
438 help='Visualize the results.')
439 parser.add_argument('--drop_score',
440 type=float,
441 default=0.5,
442 help='Score threshold for text recognition.')
443 parser.add_argument('--use_gpu',
444 type=str,
445 default='auto',
446 choices=['auto', 'true', 'false'],
447 help='GPU usage strategy: auto (detect automatically), true (force GPU), false (force CPU)')
448 args = parser.parse_args()
449
450 img_path = args.img_path
451 mode = args.mode
452 backend = args.backend
453 onnx_det_model_path = args.onnx_det_model_path
454 onnx_rec_model_path = args.onnx_rec_model_path
455 save_dir = args.save_dir
456 is_visualize = args.is_vis
457 drop_score = args.drop_score
458 use_gpu = args.use_gpu
459
460 text_sys = OpenOCRE2E(mode=mode,
461 backend=backend,
462 onnx_det_model_path=onnx_det_model_path,

Callers 1

infer_e2e.pyFile · 0.70

Calls 2

OpenOCRE2EClass · 0.85
parse_argsMethod · 0.45

Tested by

no test coverage detected