| 24 | |
| 25 | |
| 26 | def parse_args(): |
| 27 | parser = argparse.ArgumentParser(description='Model prediction') |
| 28 | |
| 29 | # Common params |
| 30 | parser.add_argument("--config", help="The path of config file.", type=str) |
| 31 | parser.add_argument( |
| 32 | '--model_path', |
| 33 | help='The path of trained weights for prediction.', |
| 34 | type=str) |
| 35 | parser.add_argument( |
| 36 | '--image_path', |
| 37 | help='The image to predict, which can be a path of image, or a file list containing image paths, or a directory including images', |
| 38 | type=str) |
| 39 | parser.add_argument( |
| 40 | '--save_dir', |
| 41 | help='The directory for saving the predicted results.', |
| 42 | type=str, |
| 43 | default='./output/result') |
| 44 | parser.add_argument( |
| 45 | '--device', |
| 46 | help='Set the device place for predicting model.', |
| 47 | default='gpu', |
| 48 | choices=['cpu', 'gpu', 'xpu', 'npu', 'mlu'], |
| 49 | type=str) |
| 50 | parser.add_argument( |
| 51 | '--device_id', |
| 52 | help='Set the device id for predicting model.', |
| 53 | default=0, |
| 54 | type=int) |
| 55 | |
| 56 | # Data augment params |
| 57 | parser.add_argument( |
| 58 | '--aug_pred', |
| 59 | help='Whether to use mulit-scales and flip augment for prediction', |
| 60 | action='store_true') |
| 61 | parser.add_argument( |
| 62 | '--scales', |
| 63 | nargs='+', |
| 64 | help='Scales for augment, e.g., `--scales 0.75 1.0 1.25`.', |
| 65 | type=float, |
| 66 | default=1.0) |
| 67 | parser.add_argument( |
| 68 | '--flip_horizontal', |
| 69 | help='Whether to use flip horizontally augment', |
| 70 | action='store_true') |
| 71 | parser.add_argument( |
| 72 | '--flip_vertical', |
| 73 | help='Whether to use flip vertically augment', |
| 74 | action='store_true') |
| 75 | |
| 76 | # Sliding window evaluation params |
| 77 | parser.add_argument( |
| 78 | '--is_slide', |
| 79 | help='Whether to predict images in sliding window method', |
| 80 | action='store_true') |
| 81 | parser.add_argument( |
| 82 | '--crop_size', |
| 83 | nargs=2, |