Parses and validates the values of the default command line arguments.
(parser)
| 740 | |
| 741 | |
| 742 | def parse_validate_default_args(parser): |
| 743 | """ |
| 744 | Parses and validates the values of the default command line arguments. |
| 745 | """ |
| 746 | args = parser.parse_args() |
| 747 | |
| 748 | if hasattr(args, "input_path"): |
| 749 | if not os.path.isdir(args.input_path) and not os.path.isfile(args.input_path): |
| 750 | raise ValueError( |
| 751 | "input_path is neither a valid file not a directory: %s" |
| 752 | % args.input_path |
| 753 | ) |
| 754 | |
| 755 | if hasattr(args, "output_dir"): |
| 756 | if not os.path.isdir(args.output_dir): |
| 757 | raise ValueError( |
| 758 | "output_dir is not a valid directory: %s" % args.output_dir |
| 759 | ) |
| 760 | |
| 761 | if hasattr(args, "batch_size"): |
| 762 | if args.batch_size <= 0: |
| 763 | raise ValueError("batch_size must be a value >=1.") |
| 764 | |
| 765 | if hasattr(args, "device_id"): |
| 766 | if torch.cuda.device_count(): |
| 767 | if args.device_id < 0 or args.device_id >= torch.cuda.device_count(): |
| 768 | raise ValueError( |
| 769 | "device_id must be a valid value from 0 to %d." |
| 770 | % (torch.cuda.device_count() - 1) |
| 771 | ) |
| 772 | |
| 773 | if hasattr(args, "target_img_height"): |
| 774 | if args.target_img_height < 10: |
| 775 | raise ValueError("target_img_height must be a value >=10.") |
| 776 | |
| 777 | if hasattr(args, "target_img_width"): |
| 778 | if args.target_img_width < 10: |
| 779 | raise ValueError("target_img_width must be a value >=10.") |
| 780 | |
| 781 | return args |
| 782 | |
| 783 | |
| 784 | def summarize_runs( |