MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / get_default_arg_parser

Function get_default_arg_parser

bench/python/perf_utils.py:608–739  ·  view source on GitHub ↗

Prepares and returns an argparse command line argument parser for the scripts that supports auto-benchmarking. This parser guarantees that all the scripts which can be benchmarked supports a basic set of command line arguments which allows us to run them in a uniform and consistent

(
    message,
    supports_video=True,
    input_path=None,
    output_dir="/tmp",
    target_img_height=224,
    target_img_width=224,
    batch_size=4,
    device_id=0,
    supported_backends=["tensorrt", "pytorch"],
    backend="tensorrt",
    log_level="info",
    parser_type="vision",
)

Source from the content-addressed store, hash-verified

606
607
608def get_default_arg_parser(
609 message,
610 supports_video=True,
611 input_path=None,
612 output_dir="/tmp",
613 target_img_height=224,
614 target_img_width=224,
615 batch_size=4,
616 device_id=0,
617 supported_backends=["tensorrt", "pytorch"],
618 backend="tensorrt",
619 log_level="info",
620 parser_type="vision",
621):
622 """
623 Prepares and returns an argparse command line argument parser for the scripts
624 that supports auto-benchmarking. This parser guarantees that all the scripts which can be
625 benchmarked supports a basic set of command line arguments which allows us to run
626 them in a uniform and consistent fashion.
627 """
628
629 # Check what kind of parser the user needs.
630 # 1. A vision parser:
631 # Adds all of the most commonly used command-line arguments for a typical
632 # computer vision pipeline.
633 # 2. A minimal parser:
634 # Only adds the arguments needed for performance benchmarking.
635 #
636 if parser_type not in ["vision", "minimal"]:
637 raise ValueError("parser_type must either be 'vision' or 'minimal.")
638
639 assets_dir = os.path.join(
640 os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
641 "assets",
642 )
643
644 if not input_path:
645 input_path = os.path.join(assets_dir, "images", "Weimaraner.jpg")
646
647 parser = argparse.ArgumentParser(
648 message,
649 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
650 )
651
652 if parser_type == "vision":
653 if not supports_video:
654 parser.add_argument(
655 "-i",
656 "--input_path",
657 default=input_path,
658 type=str,
659 help="The path to a JPEG image or a directory containing JPG images "
660 "to use as input. When pointing to a directory, only *.jpg images will be read.",
661 )
662 else:
663 parser.add_argument(
664 "-i",
665 "--input_path",

Callers 1

mainFunction · 0.90

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected