From c46c4dffe4279114fc0124d29cc13f4a224314f7 Mon Sep 17 00:00:00 2001 From: bai-yangfan Date: Wed, 2 Dec 2020 11:02:30 +0800 Subject: [PATCH] mindir_suffix --- model_zoo/official/cv/cnnctc/export.py | 2 +- model_zoo/official/cv/deeplabv3/export.py | 2 +- model_zoo/official/cv/googlenet/src/config.py | 8 ++++---- model_zoo/official/cv/inceptionv3/export.py | 2 +- model_zoo/official/cv/lenet/src/config.py | 2 +- model_zoo/official/cv/lenet_quant/export.py | 2 +- model_zoo/official/cv/mobilenetv2/src/config.py | 6 +++--- model_zoo/official/cv/mobilenetv2_quant/export.py | 2 +- model_zoo/official/cv/mobilenetv3/src/config.py | 2 +- model_zoo/official/cv/nasnet/src/config.py | 4 ++-- model_zoo/official/cv/resnet_thor/export.py | 2 +- model_zoo/official/cv/resnext50/src/config.py | 2 +- model_zoo/official/cv/squeezenet/export.py | 4 ++-- model_zoo/official/cv/ssd/export.py | 2 +- model_zoo/official/cv/unet/export.py | 2 +- model_zoo/official/cv/vgg16/export.py | 2 +- model_zoo/official/cv/yolov3_darknet53/export.py | 2 +- model_zoo/official/cv/yolov3_darknet53_quant/export.py | 2 +- model_zoo/official/cv/yolov3_resnet18/export.py | 2 +- model_zoo/official/cv/yolov4/export.py | 2 +- model_zoo/official/nlp/bert/export.py | 2 +- model_zoo/official/nlp/tinybert/export.py | 2 +- model_zoo/official/recommend/wide_and_deep/export.py | 4 ++-- serving/example/export_model/add_model.py | 2 +- tests/st/quantization/lenet_quant/test_lenet_quant.py | 2 +- tests/ut/python/utils/test_serialize.py | 2 +- 26 files changed, 34 insertions(+), 34 deletions(-) diff --git a/model_zoo/official/cv/cnnctc/export.py b/model_zoo/official/cv/cnnctc/export.py index dae4557524a..a8f7a4f781b 100644 --- a/model_zoo/official/cv/cnnctc/export.py +++ b/model_zoo/official/cv/cnnctc/export.py @@ -26,7 +26,7 @@ context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") parser = argparse.ArgumentParser(description='CNNCTC_export') parser.add_argument('--ckpt_file', type=str, default='./ckpts/cnn_ctc.ckpt', help='CNN&CTC ckpt file.') -parser.add_argument('--output_file', type=str, default='cnn_ctc.air', help='CNN&CTC output air name.') +parser.add_argument('--output_file', type=str, default='cnn_ctc', help='CNN&CTC output air name.') args_opt = parser.parse_args() if __name__ == '__main__': diff --git a/model_zoo/official/cv/deeplabv3/export.py b/model_zoo/official/cv/deeplabv3/export.py index 964b71d2024..f9e05b64077 100644 --- a/model_zoo/official/cv/deeplabv3/export.py +++ b/model_zoo/official/cv/deeplabv3/export.py @@ -39,4 +39,4 @@ if __name__ == '__main__': # load the parameter into net load_param_into_net(network, param_dict) input_data = np.random.uniform(0.0, 1.0, size=[32, 3, 513, 513]).astype(np.float32) - export(network, Tensor(input_data), file_name=args.model+'-300_11.air', file_format='AIR') + export(network, Tensor(input_data), file_name=args.model+'-300_11', file_format='AIR') diff --git a/model_zoo/official/cv/googlenet/src/config.py b/model_zoo/official/cv/googlenet/src/config.py index a0809692998..13873d86c88 100644 --- a/model_zoo/official/cv/googlenet/src/config.py +++ b/model_zoo/official/cv/googlenet/src/config.py @@ -33,8 +33,8 @@ cifar_cfg = edict({ 'device_id': 0, 'keep_checkpoint_max': 10, 'checkpoint_path': './train_googlenet_cifar10-125_390.ckpt', - 'onnx_filename': 'googlenet.onnx', - 'air_filename': 'googlenet.air' + 'onnx_filename': 'googlenet', + 'air_filename': 'googlenet' }) imagenet_cfg = edict({ @@ -54,8 +54,8 @@ imagenet_cfg = edict({ 'device_id': 0, 'keep_checkpoint_max': 10, 'checkpoint_path': None, - 'onnx_filename': 'googlenet.onnx', - 'air_filename': 'googlenet.air', + 'onnx_filename': 'googlenet', + 'air_filename': 'googlenet', # optimizer and lr related 'lr_scheduler': 'exponential', diff --git a/model_zoo/official/cv/inceptionv3/export.py b/model_zoo/official/cv/inceptionv3/export.py index c7fa16cd56b..61daaaa9751 100644 --- a/model_zoo/official/cv/inceptionv3/export.py +++ b/model_zoo/official/cv/inceptionv3/export.py @@ -26,7 +26,7 @@ from src.inception_v3 import InceptionV3 parser = argparse.ArgumentParser(description='inceptionv3 export') parser.add_argument('--ckpt_file', type=str, required=True, help='inceptionv3 ckpt file.') -parser.add_argument('--output_file', type=str, default='inceptionv3.air', help='inceptionv3 output air name.') +parser.add_argument('--output_file', type=str, default='inceptionv3', help='inceptionv3 output air name.') parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') parser.add_argument('--width', type=int, default=299, help='input width') parser.add_argument('--height', type=int, default=299, help='input height') diff --git a/model_zoo/official/cv/lenet/src/config.py b/model_zoo/official/cv/lenet/src/config.py index f8227278fd5..e191906a073 100644 --- a/model_zoo/official/cv/lenet/src/config.py +++ b/model_zoo/official/cv/lenet/src/config.py @@ -29,5 +29,5 @@ mnist_cfg = edict({ 'image_width': 32, 'save_checkpoint_steps': 1875, 'keep_checkpoint_max': 10, - 'air_name': "lenet.air", + 'air_name': "lenet", }) diff --git a/model_zoo/official/cv/lenet_quant/export.py b/model_zoo/official/cv/lenet_quant/export.py index 3d5873e5bd3..a37c90f6c58 100644 --- a/model_zoo/official/cv/lenet_quant/export.py +++ b/model_zoo/official/cv/lenet_quant/export.py @@ -54,4 +54,4 @@ if __name__ == "__main__": # export network inputs = Tensor(np.ones([1, 1, cfg.image_height, cfg.image_width]), mindspore.float32) - export(network, inputs, file_name="lenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO') + export(network, inputs, file_name="lenet_quant", file_format='MINDIR', quant_mode='AUTO') diff --git a/model_zoo/official/cv/mobilenetv2/src/config.py b/model_zoo/official/cv/mobilenetv2/src/config.py index 9598ca3310a..414491838e3 100644 --- a/model_zoo/official/cv/mobilenetv2/src/config.py +++ b/model_zoo/official/cv/mobilenetv2/src/config.py @@ -42,7 +42,7 @@ def set_config(args): "platform": args.platform, "activation": "Softmax", "export_format": "MINDIR", - "export_file": "mobilenetv2.mindir" + "export_file": "mobilenetv2" }) config_gpu = ed({ "num_classes": 1000, @@ -66,7 +66,7 @@ def set_config(args): "run_distribute": args.run_distribute, "activation": "Softmax", "export_format": "MINDIR", - "export_file": "mobilenetv2.mindir" + "export_file": "mobilenetv2" }) config_ascend = ed({ "num_classes": 1000, @@ -93,7 +93,7 @@ def set_config(args): "run_distribute": int(os.getenv('RANK_SIZE', '1')) > 1., "activation": "Softmax", "export_format": "MINDIR", - "export_file": "mobilenetv2.mindir" + "export_file": "mobilenetv2" }) config = ed({"CPU": config_cpu, "GPU": config_gpu, diff --git a/model_zoo/official/cv/mobilenetv2_quant/export.py b/model_zoo/official/cv/mobilenetv2_quant/export.py index 5af9e473bfb..c951d64f20e 100644 --- a/model_zoo/official/cv/mobilenetv2_quant/export.py +++ b/model_zoo/official/cv/mobilenetv2_quant/export.py @@ -51,5 +51,5 @@ if __name__ == '__main__': # export network print("============== Starting export ==============") inputs = Tensor(np.ones([1, 3, cfg.image_height, cfg.image_width]), mindspore.float32) - export(network, inputs, file_name="mobilenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO') + export(network, inputs, file_name="mobilenet_quant", file_format='MINDIR', quant_mode='AUTO') print("============== End export ==============") diff --git a/model_zoo/official/cv/mobilenetv3/src/config.py b/model_zoo/official/cv/mobilenetv3/src/config.py index 317f3e0073e..ebc9e2e5490 100644 --- a/model_zoo/official/cv/mobilenetv3/src/config.py +++ b/model_zoo/official/cv/mobilenetv3/src/config.py @@ -34,5 +34,5 @@ config_gpu = ed({ "keep_checkpoint_max": 500, "save_checkpoint_path": "./checkpoint", "export_format": "MINDIR", - "export_file": "mobilenetv3.mindir" + "export_file": "mobilenetv3" }) diff --git a/model_zoo/official/cv/nasnet/src/config.py b/model_zoo/official/cv/nasnet/src/config.py index f8b236aa93f..88464433f8e 100755 --- a/model_zoo/official/cv/nasnet/src/config.py +++ b/model_zoo/official/cv/nasnet/src/config.py @@ -51,6 +51,6 @@ nasnet_a_mobile_config_gpu = edict({ "loss_scale": 1, ### onnx&air Config - 'onnx_filename': 'nasnet_a_mobile.onnx', - 'air_filename': 'nasnet_a_mobile.air' + 'onnx_filename': 'nasnet_a_mobile', + 'air_filename': 'nasnet_a_mobile' }) diff --git a/model_zoo/official/cv/resnet_thor/export.py b/model_zoo/official/cv/resnet_thor/export.py index 00b91fbe6f2..9b79d97aed3 100644 --- a/model_zoo/official/cv/resnet_thor/export.py +++ b/model_zoo/official/cv/resnet_thor/export.py @@ -41,4 +41,4 @@ if __name__ == '__main__': load_param_into_net(net, param_dict) inputs = np.random.uniform(0.0, 1.0, size=[1, 3, 224, 224]).astype(np.float32) - export(net, Tensor(inputs), file_name='resnet-42_5004.air', file_format='AIR') + export(net, Tensor(inputs), file_name='resnet-42_5004', file_format='AIR') diff --git a/model_zoo/official/cv/resnext50/src/config.py b/model_zoo/official/cv/resnext50/src/config.py index 75a39966f22..a1902335ad1 100644 --- a/model_zoo/official/cv/resnext50/src/config.py +++ b/model_zoo/official/cv/resnext50/src/config.py @@ -44,5 +44,5 @@ config = ed({ "rank": 0, "group_size": 1, "export_format": "MINDIR", - "export_file": "resnext50.mindir" + "export_file": "resnext50" }) diff --git a/model_zoo/official/cv/squeezenet/export.py b/model_zoo/official/cv/squeezenet/export.py index c198587d704..b3d83d7306c 100755 --- a/model_zoo/official/cv/squeezenet/export.py +++ b/model_zoo/official/cv/squeezenet/export.py @@ -39,8 +39,8 @@ if __name__ == '__main__': else: num_classes = 1000 - onnx_filename = args_opt.net + '_' + args_opt.dataset + '.onnx' - air_filename = args_opt.net + '_' + args_opt.dataset + '.air' + onnx_filename = args_opt.net + '_' + args_opt.dataset + air_filename = args_opt.net + '_' + args_opt.dataset net = squeezenet(num_classes=num_classes) diff --git a/model_zoo/official/cv/ssd/export.py b/model_zoo/official/cv/ssd/export.py index 0ef9531f47c..b9bb950703f 100644 --- a/model_zoo/official/cv/ssd/export.py +++ b/model_zoo/official/cv/ssd/export.py @@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='SSD export') parser.add_argument("--device_id", type=int, default=0, help="Device id") parser.add_argument("--batch_size", type=int, default=1, help="batch size") parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.") -parser.add_argument("--file_name", type=str, default="ssd.air", help="output file name.") +parser.add_argument("--file_name", type=str, default="ssd", help="output file name.") parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/cv/unet/export.py b/model_zoo/official/cv/unet/export.py index 6f0390e9455..dcdd082d246 100644 --- a/model_zoo/official/cv/unet/export.py +++ b/model_zoo/official/cv/unet/export.py @@ -23,7 +23,7 @@ from src.unet.unet_model import UNet parser = argparse.ArgumentParser(description='Export ckpt to air') parser.add_argument('--ckpt_file', type=str, default="ckpt_unet_medical_adam-1_600.ckpt", help='The path of input ckpt file') -parser.add_argument('--air_file', type=str, default="unet_medical_adam-1_600.air", help='The path of output air file') +parser.add_argument('--air_file', type=str, default="unet_medical_adam-1_600", help='The path of output air file') args = parser.parse_args() net = UNet(n_channels=1, n_classes=2) diff --git a/model_zoo/official/cv/vgg16/export.py b/model_zoo/official/cv/vgg16/export.py index 1cdc732823b..629e60d15ba 100644 --- a/model_zoo/official/cv/vgg16/export.py +++ b/model_zoo/official/cv/vgg16/export.py @@ -27,7 +27,7 @@ context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") parser = argparse.ArgumentParser(description='VGG16 export') parser.add_argument('--dataset', type=str, choices=["cifar10", "imagenet2012"], default="cifar10", help='ckpt file') parser.add_argument('--ckpt_file', type=str, required=True, help='vgg16 ckpt file.') -parser.add_argument('--output_file', type=str, default='vgg16.air', help='vgg16 output air name.') +parser.add_argument('--output_file', type=str, default='vgg16', help='vgg16 output air name.') parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/cv/yolov3_darknet53/export.py b/model_zoo/official/cv/yolov3_darknet53/export.py index bab2192c530..90a62509d41 100644 --- a/model_zoo/official/cv/yolov3_darknet53/export.py +++ b/model_zoo/official/cv/yolov3_darknet53/export.py @@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='yolov3_darknet53 export') parser.add_argument("--device_id", type=int, default=0, help="Device id") parser.add_argument("--batch_size", type=int, default=1, help="batch size") parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.") -parser.add_argument("--file_name", type=str, default="yolov3_darknet53.air", help="output file name.") +parser.add_argument("--file_name", type=str, default="yolov3_darknet53", help="output file name.") parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/cv/yolov3_darknet53_quant/export.py b/model_zoo/official/cv/yolov3_darknet53_quant/export.py index 9a82efc2ac1..440833afa43 100644 --- a/model_zoo/official/cv/yolov3_darknet53_quant/export.py +++ b/model_zoo/official/cv/yolov3_darknet53_quant/export.py @@ -27,7 +27,7 @@ parser = argparse.ArgumentParser(description='yolov3_darknet53_quant export') parser.add_argument("--device_id", type=int, default=0, help="Device id") parser.add_argument("--batch_size", type=int, default=1, help="batch size") parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.") -parser.add_argument("--file_name", type=str, default="yolov3_darknet53_quant.mindir", help="output file name.") +parser.add_argument("--file_name", type=str, default="yolov3_darknet53_quant", help="output file name.") parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='MINDIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/cv/yolov3_resnet18/export.py b/model_zoo/official/cv/yolov3_resnet18/export.py index 06c4baad2e3..225ca360024 100644 --- a/model_zoo/official/cv/yolov3_resnet18/export.py +++ b/model_zoo/official/cv/yolov3_resnet18/export.py @@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='yolov3_resnet18 export') parser.add_argument("--device_id", type=int, default=0, help="Device id") parser.add_argument("--batch_size", type=int, default=1, help="batch size") parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.") -parser.add_argument("--file_name", type=str, default="yolov3_resnet18.air", help="output file name.") +parser.add_argument("--file_name", type=str, default="yolov3_resnet18", help="output file name.") parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/cv/yolov4/export.py b/model_zoo/official/cv/yolov4/export.py index a4b20c50d52..6eeef669414 100644 --- a/model_zoo/official/cv/yolov4/export.py +++ b/model_zoo/official/cv/yolov4/export.py @@ -26,7 +26,7 @@ parser.add_argument("--device_id", type=int, default=0, help="Device id") parser.add_argument("--batch_size", type=int, default=1, help="batch size") parser.add_argument("--testing_shape", type=int, default=608, help="test shape") parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.") -parser.add_argument("--file_name", type=str, default="yolov4.air", help="output file name.") +parser.add_argument("--file_name", type=str, default="yolov4", help="output file name.") parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/nlp/bert/export.py b/model_zoo/official/nlp/bert/export.py index 30296e7ae83..6d74c97c691 100644 --- a/model_zoo/official/nlp/bert/export.py +++ b/model_zoo/official/nlp/bert/export.py @@ -34,7 +34,7 @@ parser.add_argument('--downstream_task', type=str, choices=["NER", "CLS", "SQUAD parser.add_argument('--num_class', type=int, default=41, help='The number of class, default is 41.') parser.add_argument('--label_file_path', type=str, default="", help='label file path, used in clue benchmark.') parser.add_argument('--ckpt_file', type=str, required=True, help='Bert ckpt file.') -parser.add_argument('--output_file', type=str, default='Bert.air', help='bert output air name.') +parser.add_argument('--output_file', type=str, default='Bert', help='bert output air name.') parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format') args = parser.parse_args() diff --git a/model_zoo/official/nlp/tinybert/export.py b/model_zoo/official/nlp/tinybert/export.py index 3502ea485af..e02c82dca41 100644 --- a/model_zoo/official/nlp/tinybert/export.py +++ b/model_zoo/official/nlp/tinybert/export.py @@ -26,7 +26,7 @@ from src.tinybert_model import BertModelCLS parser = argparse.ArgumentParser(description='tinybert task distill') parser.add_argument('--ckpt_file', type=str, required=True, help='tinybert ckpt file.') -parser.add_argument('--output_file', type=str, default='tinybert.air', help='tinybert output air name.') +parser.add_argument('--output_file', type=str, default='tinybert', help='tinybert output air name.') parser.add_argument('--task_name', type=str, default='SST-2', choices=['SST-2', 'QNLI', 'MNLI'], help='task name') args = parser.parse_args() diff --git a/model_zoo/official/recommend/wide_and_deep/export.py b/model_zoo/official/recommend/wide_and_deep/export.py index cffd0da4027..0d322602638 100644 --- a/model_zoo/official/recommend/wide_and_deep/export.py +++ b/model_zoo/official/recommend/wide_and_deep/export.py @@ -56,5 +56,5 @@ if __name__ == '__main__': ids = Tensor(np.ones([widedeep_config.eval_batch_size, widedeep_config.field_size]).astype(np.int32)) wts = Tensor(np.ones([widedeep_config.eval_batch_size, widedeep_config.field_size]).astype(np.float32)) input_tensor_list = [ids, wts] - export(net, *input_tensor_list, file_name='wide_and_deep.onnx', file_format="ONNX") - export(net, *input_tensor_list, file_name='wide_and_deep.air', file_format="AIR") + export(net, *input_tensor_list, file_name='wide_and_deep', file_format="ONNX") + export(net, *input_tensor_list, file_name='wide_and_deep', file_format="AIR") diff --git a/serving/example/export_model/add_model.py b/serving/example/export_model/add_model.py index 4e206ba01ef..6d37640f5b9 100644 --- a/serving/example/export_model/add_model.py +++ b/serving/example/export_model/add_model.py @@ -35,7 +35,7 @@ def export_net(): y = np.ones([2, 2]).astype(np.float32) add = Net() output = add(Tensor(x), Tensor(y)) - export(add, Tensor(x), Tensor(y), file_name='tensor_add.mindir', file_format='MINDIR') + export(add, Tensor(x), Tensor(y), file_name='tensor_add', file_format='MINDIR') print(x) print(y) print(output.asnumpy()) diff --git a/tests/st/quantization/lenet_quant/test_lenet_quant.py b/tests/st/quantization/lenet_quant/test_lenet_quant.py index 96bb068bb80..a2981ee21fd 100644 --- a/tests/st/quantization/lenet_quant/test_lenet_quant.py +++ b/tests/st/quantization/lenet_quant/test_lenet_quant.py @@ -147,7 +147,7 @@ def export_lenet(): # export network inputs = Tensor(np.ones([1, 1, cfg.image_height, cfg.image_width]), mstype.float32) - export(network, inputs, file_name="lenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO') + export(network, inputs, file_name="lenet_quant", file_format='MINDIR', quant_mode='AUTO') @pytest.mark.level0 diff --git a/tests/ut/python/utils/test_serialize.py b/tests/ut/python/utils/test_serialize.py index 214c2dcc3e1..e7c3d6b85bb 100644 --- a/tests/ut/python/utils/test_serialize.py +++ b/tests/ut/python/utils/test_serialize.py @@ -331,7 +331,7 @@ def test_export(): def test_mindir_export(): net = MYNET() input_data = Tensor(np.random.randint(0, 255, [1, 3, 224, 224]).astype(np.float32)) - export(net, input_data, file_name="./me_binary_export.mindir", file_format="MINDIR") + export(net, input_data, file_name="./me_binary_export", file_format="MINDIR") class PrintNet(nn.Cell):