diff --git a/paddle2onnx/command.py b/paddle2onnx/command.py index 4562a9a6f..fe6fb7026 100755 --- a/paddle2onnx/command.py +++ b/paddle2onnx/command.py @@ -71,12 +71,6 @@ def arg_parser(): default="None", help="define input shapes, e.g --input_shape_dict=\"{'image':[1, 3, 608, 608]}\" or" \ "--input_shape_dict=\"{'image':[1, 3, 608, 608], 'im_shape': [1, 2], 'scale_factor': [1, 2]}\"") - parser.add_argument( - "--enable_dev_version", - type=ast.literal_eval, - default=True, - help="whether to use new version of Paddle2ONNX which is under developing, default True" - ) parser.add_argument( "--deploy_backend", "-d", @@ -165,26 +159,6 @@ def c_paddle_to_onnx(model_file, return onnx_model_str -def program2onnx(model_dir, - save_file, - model_filename=None, - params_filename=None, - opset_version=9, - enable_onnx_checker=False, - operator_export_type="ONNX", - input_shape_dict=None, - output_names=None, - auto_update_opset=True): - logging.warning( - "[Deprecated] `paddle2onnx.command.program2onnx` will be deprecated in the future version, the recommended usage is `paddle2onnx.export`" - ) - from paddle2onnx.legacy.command import program2onnx - return program2onnx(model_dir, save_file, model_filename, params_filename, - opset_version, enable_onnx_checker, - operator_export_type, input_shape_dict, output_names, - auto_update_opset) - - def main(): if len(sys.argv) < 2: logging.info("Use \"paddle2onnx -h\" to print the help information") @@ -207,13 +181,6 @@ def main(): input_shape_dict = eval(args.input_shape_dict) - operator_export_type = "ONNX" - if args.enable_paddle_fallback: - logging.warning( - "[Deprecated] The flag `--enable_paddle_fallback` will be deprecated, and only works while `--enable_dev_version False` now." - ) - operator_export_type = "PaddleFallback" - if args.output_names is not None and args.enable_dev_version: logging.warning( "[Deprecated] The flag `--output_names` is deprecated, if you need to modify the output name, please refer to this tool https://github.com/jiangjiajun/PaddleUtils/tree/main/onnx " @@ -228,54 +195,38 @@ def main(): "[Deprecated] The flag `--input_shape_dict` is deprecated, if you need to modify the input shape of PaddlePaddle model, please refer to this tool https://github.com/jiangjiajun/PaddleUtils/tree/main/paddle " ) - if args.enable_dev_version: - model_file = os.path.join(args.model_dir, args.model_filename) - if args.params_filename is None: - params_file = "" - else: - params_file = os.path.join(args.model_dir, args.params_filename) - - if args.external_filename is None: - args.external_filename = "external_data" + model_file = os.path.join(args.model_dir, args.model_filename) + if args.params_filename is None: + params_file = "" + else: + params_file = os.path.join(args.model_dir, args.params_filename) - base_path = os.path.dirname(args.save_file) - if base_path and not os.path.exists(base_path): - os.mkdir(base_path) - external_file = os.path.join(base_path, args.external_filename) + if args.external_filename is None: + args.external_filename = "external_data" - custom_ops_dict = eval(args.custom_ops) + base_path = os.path.dirname(args.save_file) + if base_path and not os.path.exists(base_path): + os.mkdir(base_path) + external_file = os.path.join(base_path, args.external_filename) - calibration_file = args.save_calibration_file - c_paddle_to_onnx( - model_file=model_file, - params_file=params_file, - save_file=args.save_file, - opset_version=args.opset_version, - auto_upgrade_opset=args.enable_auto_update_opset, - verbose=True, - enable_onnx_checker=args.enable_onnx_checker, - enable_experimental_op=True, - enable_optimize=True, - deploy_backend=args.deploy_backend, - calibration_file=calibration_file, - external_file=external_file, - export_fp16_model=args.export_fp16_model, - custom_ops=custom_ops_dict) - logging.info("===============Make PaddlePaddle Better!================") - logging.info("A little survey: https://iwenjuan.baidu.com/?code=r8hu2s") - return + custom_ops_dict = eval(args.custom_ops) - program2onnx( - args.model_dir, - args.save_file, - args.model_filename, - args.params_filename, + calibration_file = args.save_calibration_file + c_paddle_to_onnx( + model_file=model_file, + params_file=params_file, + save_file=args.save_file, opset_version=args.opset_version, + auto_upgrade_opset=args.enable_auto_update_opset, + verbose=True, enable_onnx_checker=args.enable_onnx_checker, - operator_export_type=operator_export_type, - input_shape_dict=input_shape_dict, - output_names=args.output_names, - auto_update_opset=args.enable_auto_update_opset) + enable_experimental_op=True, + enable_optimize=True, + deploy_backend=args.deploy_backend, + calibration_file=calibration_file, + external_file=external_file, + export_fp16_model=args.export_fp16_model, + custom_ops=custom_ops_dict) logging.info("===============Make PaddlePaddle Better!================") logging.info("A little survey: https://iwenjuan.baidu.com/?code=r8hu2s")