From a10dca74c70a778acfb2e2308b319548b4692fb3 Mon Sep 17 00:00:00 2001 From: WongGawa Date: Thu, 26 Sep 2024 15:36:31 +0800 Subject: [PATCH] fix yolov7's MaxPool2d's bug --- configs/yolov7/yolov7-tiny.yaml | 1 + test.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/configs/yolov7/yolov7-tiny.yaml b/configs/yolov7/yolov7-tiny.yaml index dfb8e9f5..52e62399 100644 --- a/configs/yolov7/yolov7-tiny.yaml +++ b/configs/yolov7/yolov7-tiny.yaml @@ -6,6 +6,7 @@ __BASE__: [ per_batch_size: 16 # 16 * 8 = 128 img_size: 640 # image sizes sync_bn: True +precision_mode: 'allow_fp32_to_fp16' network: model_name: yolov7 diff --git a/test.py b/test.py index 3a6f0860..8c47d55f 100644 --- a/test.py +++ b/test.py @@ -33,6 +33,9 @@ def get_parser_test(parents=None): parser.add_argument( "--ms_enable_graph_kernel", type=ast.literal_eval, default=False, help="use enable_graph_kernel or not" ) + parser.add_argument( + "--precision_mode", type=str, default=None, help="set accuracy mode of network model" + ) parser.add_argument("--weight", type=str, default="yolov7_300.ckpt", help="model.ckpt path(s)") parser.add_argument("--per_batch_size", type=int, default=32, help="size of each image batch") parser.add_argument("--img_size", type=int, default=640, help="inference size (pixels)") @@ -71,6 +74,8 @@ def get_parser_test(parents=None): def set_default_test(args): # Set Context ms.set_context(mode=args.ms_mode, device_target=args.device_target, max_call_depth=2000) + if args.precision_mode is not None: + ms.set_context(ascend_config={"precision_mode":args.precision_mode}) if args.ms_mode == 0: ms.set_context(jit_config={"jit_level": "O2"}) if args.device_target == "Ascend":