From e031e60a6e80696c7e9bffa714fa1ceaf72dc972 Mon Sep 17 00:00:00 2001 From: wsq3 <877518222@qq.com> Date: Fri, 29 Jan 2021 15:54:11 +0800 Subject: [PATCH] some words misspelled,it has modified --- .../official/cv/yolov3_darknet53/eval.py | 8 +++--- .../cv/yolov3_darknet53/scripts/run_eval.sh | 2 +- .../yolov3_darknet53/scripts/run_eval_gpu.sh | 2 +- .../cv/yolov3_darknet53/src/convert_weight.py | 2 +- .../official/cv/yolov3_darknet53/src/yolo.py | 4 +-- .../cv/yolov3_darknet53/src/yolo_dataset.py | 2 +- .../official/cv/yolov3_darknet53/train.py | 27 ++++++++++--------- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/model_zoo/official/cv/yolov3_darknet53/eval.py b/model_zoo/official/cv/yolov3_darknet53/eval.py index b270a39a26b..cdb119b3a3e 100644 --- a/model_zoo/official/cv/yolov3_darknet53/eval.py +++ b/model_zoo/official/cv/yolov3_darknet53/eval.py @@ -87,7 +87,7 @@ class DetectionEngine: def _nms(self, predicts, threshold): """Calculate NMS.""" - # conver xywh -> xmin ymin xmax ymax + # convert xywh -> xmin ymin xmax ymax x1 = predicts[:, 0] y1 = predicts[:, 1] x2 = x1 + predicts[:, 2] @@ -111,8 +111,8 @@ class DetectionEngine: intersect_area = intersect_w * intersect_h ovr = intersect_area / (areas[i] + areas[order[1:]] - intersect_area) - indexs = np.where(ovr <= threshold)[0] - order = order[indexs + 1] + indexes = np.where(ovr <= threshold)[0] + order = order[indexes + 1] return reserved_boxes def write_result(self): @@ -179,7 +179,7 @@ class DetectionEngine: x_top_left = x - w / 2. y_top_left = y - h / 2. - # creat all False + # create all False flag = np.random.random(cls_emb.shape) > sys.maxsize for i in range(flag.shape[0]): c = cls_argmax[i] diff --git a/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval.sh b/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval.sh index ff6b79e516d..0ac33dc60be 100644 --- a/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval.sh +++ b/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval.sh @@ -58,7 +58,7 @@ cp ../*.py ./eval cp -r ../src ./eval cd ./eval || exit env > env.log -echo "start infering for device $DEVICE_ID" +echo "start inferring for device $DEVICE_ID" python eval.py \ --data_dir=$DATASET_PATH \ --pretrained=$CHECKPOINT_PATH \ diff --git a/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval_gpu.sh b/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval_gpu.sh index ccf94a93022..5729e24cf67 100644 --- a/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval_gpu.sh +++ b/model_zoo/official/cv/yolov3_darknet53/scripts/run_eval_gpu.sh @@ -58,7 +58,7 @@ cp ../*.py ./eval cp -r ../src ./eval cd ./eval || exit env > env.log -echo "start infering for device $DEVICE_ID" +echo "start inferring for device $DEVICE_ID" python eval.py \ --device_target="GPU" \ --data_dir=$DATASET_PATH \ diff --git a/model_zoo/official/cv/yolov3_darknet53/src/convert_weight.py b/model_zoo/official/cv/yolov3_darknet53/src/convert_weight.py index e63a5bc32e3..b01d5f6e862 100644 --- a/model_zoo/official/cv/yolov3_darknet53/src/convert_weight.py +++ b/model_zoo/official/cv/yolov3_darknet53/src/convert_weight.py @@ -39,7 +39,7 @@ def build_network(): def convert(weights_file, output_file): - """Conver weight to mindspore ckpt.""" + """Convert weight to mindspore ckpt.""" params = build_network() weights = load_weight(weights_file) index = 0 diff --git a/model_zoo/official/cv/yolov3_darknet53/src/yolo.py b/model_zoo/official/cv/yolov3_darknet53/src/yolo.py index 6d6e37d9091..98be509a62d 100644 --- a/model_zoo/official/cv/yolov3_darknet53/src/yolo.py +++ b/model_zoo/official/cv/yolov3_darknet53/src/yolo.py @@ -59,7 +59,7 @@ class YoloBlock(nn.Cell): Args: in_channels: Integer. Input channel. - out_chls: Interger. Middle channel. + out_chls: Integer. Middle channel. out_channels: Integer. Output channel. Returns: @@ -108,7 +108,7 @@ class YOLOv3(nn.Cell): Args: backbone_shape: List. Darknet output channels shape. backbone: Cell. Backbone Network. - out_channel: Interger. Output channel. + out_channel: Integer. Output channel. Returns: Tensor, output tensor. diff --git a/model_zoo/official/cv/yolov3_darknet53/src/yolo_dataset.py b/model_zoo/official/cv/yolov3_darknet53/src/yolo_dataset.py index 53793e09a0a..c4e4466f8d6 100644 --- a/model_zoo/official/cv/yolov3_darknet53/src/yolo_dataset.py +++ b/model_zoo/official/cv/yolov3_darknet53/src/yolo_dataset.py @@ -45,7 +45,7 @@ def has_valid_annotation(anno): # if all boxes have close to zero area, there is no annotation if _has_only_empty_bbox(anno): return False - # keypoints task have a slight different critera for considering + # keypoints task have a slight different criteria for considering # if an annotation is valid if "keypoints" not in anno[0]: return True diff --git a/model_zoo/official/cv/yolov3_darknet53/train.py b/model_zoo/official/cv/yolov3_darknet53/train.py index 682e0eeffc9..eef9f8192e2 100644 --- a/model_zoo/official/cv/yolov3_darknet53/train.py +++ b/model_zoo/official/cv/yolov3_darknet53/train.py @@ -131,9 +131,7 @@ def conver_training_shape(args): return training_shape -def train(): - """Train function.""" - args = parse_args() +def network_init(args): devid = int(os.getenv('DEVICE_ID', '0')) context.set_context(mode=context.GRAPH_MODE, enable_auto_mixed_precision=True, device_target=args.device_target, save_graphs=True, device_id=devid) @@ -145,26 +143,21 @@ def train(): init("nccl") args.rank = get_rank() args.group_size = get_group_size() - # select for master rank save ckpt or all rank save, compatiable for model parallel + # select for master rank save ckpt or all rank save, compatible for model parallel args.rank_save_ckpt_flag = 0 if args.is_save_on_master: if args.rank == 0: args.rank_save_ckpt_flag = 1 else: args.rank_save_ckpt_flag = 1 - # logger args.outputs_dir = os.path.join(args.ckpt_path, datetime.datetime.now().strftime('%Y-%m-%d_time_%H_%M_%S')) args.logger = get_logger(args.outputs_dir, args.rank) args.logger.save_args(args) - if args.need_profiler: - from mindspore.profiler.profiling import Profiler - profiler = Profiler(output_path=args.outputs_dir, is_detail=True, is_show_op_path=True) - - loss_meter = AverageMeter('loss') +def parallel_init(args): context.reset_auto_parallel_context() parallel_mode = ParallelMode.STAND_ALONE degree = 1 @@ -173,6 +166,17 @@ def train(): degree = get_group_size() context.set_auto_parallel_context(parallel_mode=parallel_mode, gradients_mean=True, device_num=degree) +def train(): + """Train function.""" + args = parse_args() + network_init(args) + if args.need_profiler: + from mindspore.profiler.profiling import Profiler + profiler = Profiler(output_path=args.outputs_dir, is_detail=True, is_show_op_path=True) + + loss_meter = AverageMeter('loss') + parallel_init(args) + network = YOLOV3DarkNet53(is_training=True) # default is kaiming-normal default_recurisive_init(network) @@ -182,7 +186,6 @@ def train(): args.logger.info('finish get network') config = ConfigYOLOV3DarkNet53() - config.label_smooth = args.label_smooth config.label_smooth_factor = args.label_smooth_factor @@ -202,7 +205,6 @@ def train(): args.ckpt_interval = args.steps_per_epoch lr = get_lr(args) - opt = Momentum(params=get_param_groups(network), learning_rate=Tensor(lr), momentum=args.momentum, @@ -281,7 +283,6 @@ def train(): if i == 10: profiler.analyse() break - args.logger.info('==========end training===============')