From: @zhouneng2 Reviewed-by: @linqingke,@liangchenghui Signed-off-by: @linqingketags/v1.2.0-rc1
| @@ -261,7 +261,7 @@ bash scripts/run_eval_ascend.sh $TRAINED_CKPT | |||||
| ### 训练性能 | ### 训练性能 | ||||
| | 参数 | Faster R-CNN | | |||||
| | 参数 | CNNCTC | | |||||
| | -------------------------- | ----------------------------------------------------------- | | | -------------------------- | ----------------------------------------------------------- | | ||||
| | 模型版本 | V1 | | | 模型版本 | V1 | | ||||
| | 资源 | Ascend 910;CPU 2.60GHz,192核;内存:755G | | | 资源 | Ascend 910;CPU 2.60GHz,192核;内存:755G | | ||||
| @@ -278,7 +278,7 @@ bash scripts/run_eval_ascend.sh $TRAINED_CKPT | |||||
| ### 评估性能 | ### 评估性能 | ||||
| | 参数 | Faster R-CNN | | |||||
| | 参数 | CNNCTC | | |||||
| | ------------------- | --------------------------- | | | ------------------- | --------------------------- | | ||||
| | 模型版本 | V1 | | | 模型版本 | V1 | | ||||
| | 资源 | Ascend 910 | | | 资源 | Ascend 910 | | ||||
| @@ -15,13 +15,13 @@ | |||||
| # ============================================================================ | # ============================================================================ | ||||
| echo "==============================================================================================================" | echo "==============================================================================================================" | ||||
| echo "Please run the scipt as: " | |||||
| echo "Please run the script as: " | |||||
| echo "sh scripts/run_distribute_eval.sh DEVICE_NUM RANK_TABLE_FILE DATASET CKPT_PATH" | echo "sh scripts/run_distribute_eval.sh DEVICE_NUM RANK_TABLE_FILE DATASET CKPT_PATH" | ||||
| echo "for example: sh scripts/run_distribute_train.sh 8 /data/hccl.json /path/to/dataset /path/to/ckpt" | echo "for example: sh scripts/run_distribute_train.sh 8 /data/hccl.json /path/to/dataset /path/to/ckpt" | ||||
| echo "It is better to use absolute path." | echo "It is better to use absolute path." | ||||
| echo "=================================================================================================================" | echo "=================================================================================================================" | ||||
| echo "After running the scipt, the network runs in the background. The log will be generated in eval_x/log.txt" | |||||
| echo "After running the script, the network runs in the background. The log will be generated in eval_x/log.txt" | |||||
| export RANK_SIZE=$1 | export RANK_SIZE=$1 | ||||
| export RANK_TABLE_FILE=$2 | export RANK_TABLE_FILE=$2 | ||||
| @@ -37,7 +37,7 @@ do | |||||
| cp -r ./src ./eval_$i | cp -r ./src ./eval_$i | ||||
| cd ./eval_$i || exit | cd ./eval_$i || exit | ||||
| export RANK_ID=$i | export RANK_ID=$i | ||||
| echo "start infering for rank $i, device $DEVICE_ID" | |||||
| echo "start inferring for rank $i, device $DEVICE_ID" | |||||
| env > env.log | env > env.log | ||||
| python eval.py \ | python eval.py \ | ||||
| --data_dir=$DATASET \ | --data_dir=$DATASET \ | ||||
| @@ -15,13 +15,13 @@ | |||||
| # ============================================================================ | # ============================================================================ | ||||
| echo "==============================================================================================================" | echo "==============================================================================================================" | ||||
| echo "Please run the scipt as: " | |||||
| echo "Please run the script as: " | |||||
| echo "sh scripts/run_distribute_train.sh DEVICE_NUM RANK_TABLE_FILE DATASET CKPT_FILE" | echo "sh scripts/run_distribute_train.sh DEVICE_NUM RANK_TABLE_FILE DATASET CKPT_FILE" | ||||
| echo "for example: sh scripts/run_distribute_train.sh 8 /data/hccl.json /path/to/dataset ckpt_file" | echo "for example: sh scripts/run_distribute_train.sh 8 /data/hccl.json /path/to/dataset ckpt_file" | ||||
| echo "It is better to use absolute path." | echo "It is better to use absolute path." | ||||
| echo "=================================================================================================================" | echo "=================================================================================================================" | ||||
| echo "After running the scipt, the network runs in the background. The log will be generated in train_x/log.txt" | |||||
| echo "After running the script, the network runs in the background. The log will be generated in train_x/log.txt" | |||||
| export RANK_SIZE=$1 | export RANK_SIZE=$1 | ||||
| export RANK_TABLE_FILE=$2 | export RANK_TABLE_FILE=$2 | ||||
| @@ -121,7 +121,7 @@ class _DenseBlock(nn.Cell): | |||||
| class _Transition(nn.Cell): | class _Transition(nn.Cell): | ||||
| """ | """ | ||||
| the transiton layer | |||||
| the transition layer | |||||
| """ | """ | ||||
| def __init__(self, num_input_features, num_output_features): | def __init__(self, num_input_features, num_output_features): | ||||
| super(_Transition, self).__init__() | super(_Transition, self).__init__() | ||||
| @@ -203,7 +203,7 @@ def _densenet201(**kwargs): | |||||
| class DenseNet121(nn.Cell): | class DenseNet121(nn.Cell): | ||||
| """ | """ | ||||
| the densenet121 architectur | |||||
| the densenet121 architecture | |||||
| """ | """ | ||||
| def __init__(self, num_classes, include_top=True): | def __init__(self, num_classes, include_top=True): | ||||
| super(DenseNet121, self).__init__() | super(DenseNet121, self).__init__() | ||||
| @@ -139,7 +139,7 @@ sh scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR | |||||
| ### Result | ### Result | ||||
| Training result will be stored in the example path. Checkpoints will be stored at `ckpt_path` by default, and training log will be redirected to `./log.txt` like followings. | |||||
| Training result will be stored in the example path. Checkpoints will be stored at `ckpt_path` by default, and training log will be redirected to `./log.txt` like following. | |||||
| ```python | ```python | ||||
| epoch: 1 step: 1251, loss is 5.4833196 | epoch: 1 step: 1251, loss is 5.4833196 | ||||
| @@ -175,7 +175,7 @@ You can start training using python or shell scripts. The usage of shell scripts | |||||
| ### Result | ### Result | ||||
| Evaluation result will be stored in the example path, you can find result like the followings in `eval.log`. | |||||
| Evaluation result will be stored in the example path, you can find result like the following in `eval.log`. | |||||
| ```python | ```python | ||||
| metric: {'Loss': 0.9849, 'Top1-Acc':0.7985, 'Top5-Acc':0.9460} | metric: {'Loss': 0.9849, 'Top1-Acc':0.7985, 'Top5-Acc':0.9460} | ||||
| @@ -115,7 +115,7 @@ class DetectionEngine: | |||||
| def _nms(self, predicts, threshold): | def _nms(self, predicts, threshold): | ||||
| """Calculate NMS.""" | """Calculate NMS.""" | ||||
| # conver xywh -> xmin ymin xmax ymax | |||||
| # convert xywh -> xmin ymin xmax ymax | |||||
| x1 = predicts[:, 0] | x1 = predicts[:, 0] | ||||
| y1 = predicts[:, 1] | y1 = predicts[:, 1] | ||||
| x2 = x1 + predicts[:, 2] | x2 = x1 + predicts[:, 2] | ||||
| @@ -139,13 +139,13 @@ class DetectionEngine: | |||||
| intersect_area = intersect_w * intersect_h | intersect_area = intersect_w * intersect_h | ||||
| ovr = intersect_area / (areas[i] + areas[order[1:]] - intersect_area) | 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 | return reserved_boxes | ||||
| def _diou_nms(self, dets, thresh=0.5): | def _diou_nms(self, dets, thresh=0.5): | ||||
| """ | """ | ||||
| conver xywh -> xmin ymin xmax ymax | |||||
| convert xywh -> xmin ymin xmax ymax | |||||
| """ | """ | ||||
| x1 = dets[:, 0] | x1 = dets[:, 0] | ||||
| y1 = dets[:, 1] | y1 = dets[:, 1] | ||||
| @@ -248,7 +248,7 @@ class DetectionEngine: | |||||
| x_top_left = x - w / 2. | x_top_left = x - w / 2. | ||||
| y_top_left = y - h / 2. | y_top_left = y - h / 2. | ||||
| # creat all False | |||||
| # create all False | |||||
| flag = np.random.random(cls_emb.shape) > sys.maxsize | flag = np.random.random(cls_emb.shape) > sys.maxsize | ||||
| for i in range(flag.shape[0]): | for i in range(flag.shape[0]): | ||||
| c = cls_argmax[i] | c = cls_argmax[i] | ||||
| @@ -58,7 +58,7 @@ cp ../*.py ./eval | |||||
| cp -r ../src ./eval | cp -r ../src ./eval | ||||
| cd ./eval || exit | cd ./eval || exit | ||||
| env > env.log | env > env.log | ||||
| echo "start infering for device $DEVICE_ID" | |||||
| echo "start inferring for device $DEVICE_ID" | |||||
| python eval.py \ | python eval.py \ | ||||
| --data_dir=$DATASET_PATH \ | --data_dir=$DATASET_PATH \ | ||||
| --pretrained=$CHECKPOINT_PATH \ | --pretrained=$CHECKPOINT_PATH \ | ||||
| @@ -58,7 +58,7 @@ cp ../*.py ./test | |||||
| cp -r ../src ./test | cp -r ../src ./test | ||||
| cd ./test || exit | cd ./test || exit | ||||
| env > env.log | env > env.log | ||||
| echo "start infering for device $DEVICE_ID" | |||||
| echo "start inferring for device $DEVICE_ID" | |||||
| python test.py \ | python test.py \ | ||||
| --data_dir=$DATASET_PATH \ | --data_dir=$DATASET_PATH \ | ||||
| --pretrained=$CHECKPOINT_PATH \ | --pretrained=$CHECKPOINT_PATH \ | ||||
| @@ -59,7 +59,7 @@ class YoloBlock(nn.Cell): | |||||
| Args: | Args: | ||||
| in_channels: Integer. Input channel. | in_channels: Integer. Input channel. | ||||
| out_chls: Interger. Middle channel. | |||||
| out_chls: Integer. Middle channel. | |||||
| out_channels: Integer. Output channel. | out_channels: Integer. Output channel. | ||||
| Returns: | Returns: | ||||
| @@ -111,7 +111,7 @@ class YOLOv4(nn.Cell): | |||||
| feature_shape: List. Input image shape, [N,C,H,W]. | feature_shape: List. Input image shape, [N,C,H,W]. | ||||
| backbone_shape: List. Darknet output channels shape. | backbone_shape: List. Darknet output channels shape. | ||||
| backbone: Cell. Backbone Network. | backbone: Cell. Backbone Network. | ||||
| out_channel: Interger. Output channel. | |||||
| out_channel: Integer. Output channel. | |||||
| Returns: | Returns: | ||||
| Tensor, output tensor. | Tensor, output tensor. | ||||
| @@ -45,7 +45,7 @@ def has_valid_annotation(anno): | |||||
| # if all boxes have close to zero area, there is no annotation | # if all boxes have close to zero area, there is no annotation | ||||
| if _has_only_empty_bbox(anno): | if _has_only_empty_bbox(anno): | ||||
| return False | 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 an annotation is valid | ||||
| if "keypoints" not in anno[0]: | if "keypoints" not in anno[0]: | ||||
| return True | return True | ||||
| @@ -107,7 +107,7 @@ class DetectionEngine(): | |||||
| def _nms(self, dets, thresh): | def _nms(self, dets, thresh): | ||||
| """nms function""" | """nms function""" | ||||
| # conver xywh -> xmin ymin xmax ymax | |||||
| # convert xywh -> xmin ymin xmax ymax | |||||
| x1 = dets[:, 0] | x1 = dets[:, 0] | ||||
| y1 = dets[:, 1] | y1 = dets[:, 1] | ||||
| x2 = x1 + dets[:, 2] | x2 = x1 + dets[:, 2] | ||||
| @@ -137,7 +137,7 @@ class DetectionEngine(): | |||||
| def _diou_nms(self, dets, thresh=0.5): | def _diou_nms(self, dets, thresh=0.5): | ||||
| """conver xywh -> xmin ymin xmax ymax""" | |||||
| """convert xywh -> xmin ymin xmax ymax""" | |||||
| x1 = dets[:, 0] | x1 = dets[:, 0] | ||||
| y1 = dets[:, 1] | y1 = dets[:, 1] | ||||
| x2 = x1 + dets[:, 2] | x2 = x1 + dets[:, 2] | ||||
| @@ -223,7 +223,7 @@ class DetectionEngine(): | |||||
| x_top_left = x - w / 2. | x_top_left = x - w / 2. | ||||
| y_top_left = y - h / 2. | y_top_left = y - h / 2. | ||||
| # creat all False | |||||
| # create all False | |||||
| flag = np.random.random(cls_emb.shape) > sys.maxsize | flag = np.random.random(cls_emb.shape) > sys.maxsize | ||||
| for i in range(flag.shape[0]): | for i in range(flag.shape[0]): | ||||
| c = cls_argmax[i] | c = cls_argmax[i] | ||||
| @@ -70,8 +70,8 @@ def nms(boxes, threshold=0.5): | |||||
| intersect_area = intersect_w * intersect_h | intersect_area = intersect_w * intersect_h | ||||
| ovr = intersect_area / (areas[i] + areas[order[1:]] - intersect_area) | 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 | return reserved_boxes | ||||
| @@ -40,7 +40,7 @@ def prepare_file_paths(): | |||||
| image_names = [] | image_names = [] | ||||
| for dataset_root in dataset_root_list: | for dataset_root in dataset_root_list: | ||||
| if not os.path.isdir(dataset_root): | if not os.path.isdir(dataset_root): | ||||
| raise ValueError("dataset root is unvalid!") | |||||
| raise ValueError("dataset root is invalid!") | |||||
| anno_dir = os.path.join(dataset_root, "Annotations") | anno_dir = os.path.join(dataset_root, "Annotations") | ||||
| image_dir = os.path.join(dataset_root, "JPEGImages") | image_dir = os.path.join(dataset_root, "JPEGImages") | ||||
| if is_train: | if is_train: | ||||
| @@ -38,7 +38,7 @@ def prepare_file_paths(): | |||||
| anno_files = [] | anno_files = [] | ||||
| for dataset_root in dataset_root_list: | for dataset_root in dataset_root_list: | ||||
| if not os.path.isdir(dataset_root): | if not os.path.isdir(dataset_root): | ||||
| raise ValueError("dataset root is unvalid!") | |||||
| raise ValueError("dataset root is invalid!") | |||||
| anno_dir = os.path.join(dataset_root, "Annotations") | anno_dir = os.path.join(dataset_root, "Annotations") | ||||
| image_dir = os.path.join(dataset_root, "JPEGImages") | image_dir = os.path.join(dataset_root, "JPEGImages") | ||||
| if is_train: | if is_train: | ||||
| @@ -39,7 +39,7 @@ def prepare_file_paths(): | |||||
| anno_files = [] | anno_files = [] | ||||
| for dataset_root in dataset_root_list: | for dataset_root in dataset_root_list: | ||||
| if not os.path.isdir(dataset_root): | if not os.path.isdir(dataset_root): | ||||
| raise ValueError("dataset root is unvalid!") | |||||
| raise ValueError("dataset root is invalid!") | |||||
| anno_dir = os.path.join(dataset_root, "Annotations") | anno_dir = os.path.join(dataset_root, "Annotations") | ||||
| image_dir = os.path.join(dataset_root, "JPEGImages") | image_dir = os.path.join(dataset_root, "JPEGImages") | ||||
| if is_train: | if is_train: | ||||
| @@ -139,7 +139,7 @@ def get_model(args): | |||||
| load_param_into_net(net, param_dict_new) | load_param_into_net(net, param_dict_new) | ||||
| args.logger.info('INFO, ------------- load model success--------------') | args.logger.info('INFO, ------------- load model success--------------') | ||||
| else: | else: | ||||
| args.logger.info('ERROR, not supprot file:{}, please check weight in config.py'.format(args.weight)) | |||||
| args.logger.info('ERROR, not support file:{}, please check weight in config.py'.format(args.weight)) | |||||
| return 0 | return 0 | ||||
| net.set_train(False) | net.set_train(False) | ||||
| return net | return net | ||||