| 283 | |
| 284 | |
| 285 | def parse_args(): |
| 286 | parser = argparse.ArgumentParser(description='Convert MMSeg to ONNX') |
| 287 | parser.add_argument('config', help='test config file path') |
| 288 | parser.add_argument('--checkpoint', help='checkpoint file', default=None) |
| 289 | parser.add_argument( |
| 290 | '--input-img', type=str, help='Images for input', default=None) |
| 291 | parser.add_argument( |
| 292 | '--show', |
| 293 | action='store_true', |
| 294 | help='show onnx graph and segmentation results') |
| 295 | parser.add_argument( |
| 296 | '--verify', action='store_true', help='verify the onnx model') |
| 297 | parser.add_argument('--output-file', type=str, default='tmp.onnx') |
| 298 | parser.add_argument('--opset-version', type=int, default=11) |
| 299 | parser.add_argument( |
| 300 | '--shape', |
| 301 | type=int, |
| 302 | nargs='+', |
| 303 | default=None, |
| 304 | help='input image height and width.') |
| 305 | parser.add_argument( |
| 306 | '--rescale_shape', |
| 307 | type=int, |
| 308 | nargs='+', |
| 309 | default=None, |
| 310 | help='output image rescale height and width, work for slide mode.') |
| 311 | parser.add_argument( |
| 312 | '--cfg-options', |
| 313 | nargs='+', |
| 314 | action=DictAction, |
| 315 | help='Override some settings in the used config, the key-value pair ' |
| 316 | 'in xxx=yyy format will be merged into config file. If the value to ' |
| 317 | 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' |
| 318 | 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' |
| 319 | 'Note that the quotation marks are necessary and that no white space ' |
| 320 | 'is allowed.') |
| 321 | parser.add_argument( |
| 322 | '--dynamic-export', |
| 323 | action='store_true', |
| 324 | help='Whether to export onnx with dynamic axis.') |
| 325 | args = parser.parse_args() |
| 326 | return args |
| 327 | |
| 328 | |
| 329 | if __name__ == '__main__': |