| 26 | |
| 27 | |
| 28 | def build_option(args): |
| 29 | option = fd.RuntimeOption() |
| 30 | |
| 31 | if args.device.lower() == "gpu": |
| 32 | option.use_gpu() |
| 33 | |
| 34 | if args.use_trt: |
| 35 | option.use_paddle_infer_backend() |
| 36 | # If use original Tensorrt, not Paddle-TensorRT, |
| 37 | # please try `option.use_trt_backend()` |
| 38 | option.paddle_infer_option.enable_trt = True |
| 39 | option.paddle_infer_option.collect_trt_shape = True |
| 40 | option.trt_option.set_shape("image", [1, 3, 640, 640], [1, 3, 640, 640], |
| 41 | [1, 3, 640, 640]) |
| 42 | option.trt_option.set_shape("scale_factor", [1, 2], [1, 2], [1, 2]) |
| 43 | return option |
| 44 | |
| 45 | |
| 46 | args = parse_arguments() |