diff --git a/model_zoo/official/cv/retinaface_resnet50/README.md b/model_zoo/official/cv/retinaface_resnet50/README.md index 48716d59314..b0a3f3ae8f7 100644 --- a/model_zoo/official/cv/retinaface_resnet50/README.md +++ b/model_zoo/official/cv/retinaface_resnet50/README.md @@ -218,9 +218,9 @@ Parameters for both training and evaluation can be set in config.py ``` # grep "Val AP" eval.log - Easy Val AP : 0.9437 - Medium Val AP : 0.9334 - Hard Val AP : 0.8904 + Easy Val AP : 0.9413 + Medium Val AP : 0.9325 + Hard Val AP : 0.8900 ``` OR, @@ -233,9 +233,9 @@ Parameters for both training and evaluation can be set in config.py ``` # grep "Val AP" eval.log - Easy Val AP : 0.9437 - Medium Val AP : 0.9334 - Hard Val AP : 0.8904 + Easy Val AP : 0.9413 + Medium Val AP : 0.9325 + Hard Val AP : 0.8900 ``` @@ -258,8 +258,8 @@ Parameters for both training and evaluation can be set in config.py | Loss Function | MultiBoxLoss + Softmax Cross Entropy | | outputs | bounding box + confidence + landmark | | Loss | 1.200 | -| Speed | 3pcs: 550 ms/step | -| Total time | 3pcs: 8.2 hours | +| Speed | 3pcs: 566 ms/step | +| Total time | 3pcs: 8.43 hours | | Parameters (M) | 27.29M | | Checkpoint for Fine tuning | 336.3M (.ckpt file) | | Scripts | [retinaface script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/retinaface) | diff --git a/model_zoo/official/cv/retinaface_resnet50/eval.py b/model_zoo/official/cv/retinaface_resnet50/eval.py index d07e4aedb88..57769677379 100644 --- a/model_zoo/official/cv/retinaface_resnet50/eval.py +++ b/model_zoo/official/cv/retinaface_resnet50/eval.py @@ -179,7 +179,7 @@ class DetectionEngine: for event in self.results: for name in self.results[event].keys(): bbox = np.array(self.results[event][name]['bboxes']).astype(np.float) - if not bool(bbox): + if bbox.shape[0] <= 0: continue max_score = max(max_score, np.max(bbox[:, -1])) min_score = min(min_score, np.min(bbox[:, -1])) @@ -188,7 +188,7 @@ class DetectionEngine: for event in self.results: for name in self.results[event].keys(): bbox = np.array(self.results[event][name]['bboxes']).astype(np.float) - if not bool(bbox): + if bbox.shape[0] <= 0: continue bbox[:, -1] -= min_score bbox[:, -1] /= length @@ -227,7 +227,7 @@ class DetectionEngine: for section in range(section_num): _thresh = 1 - (section + 1)/section_num over_score_index = np.where(predict[:, 4] >= _thresh)[0] - if not bool(over_score_index): + if over_score_index.shape[0] <= 0: image_pr[section, 0] = 0 image_pr[section, 1] = 0 else: @@ -264,10 +264,10 @@ class DetectionEngine: keep_index = event_gt_index_list[j][0] count_gt += len(keep_index) - if not bool(gt_boxes) or not bool(predict): + if gt_boxes.shape[0] <= 0 or predict.shape[0] <= 0: continue keep = np.zeros(gt_boxes.shape[0]) - if bool(keep_index): + if keep_index.shape[0] > 0: keep[keep_index-1] = 1 image_pr = self._image_eval(predict, gt_boxes, keep, diff --git a/model_zoo/official/cv/retinaface_resnet50/src/augmemtation.py b/model_zoo/official/cv/retinaface_resnet50/src/augmemtation.py index a82d594c48c..775c5f094d7 100644 --- a/model_zoo/official/cv/retinaface_resnet50/src/augmemtation.py +++ b/model_zoo/official/cv/retinaface_resnet50/src/augmemtation.py @@ -55,7 +55,7 @@ def _choose_candidate(max_trial, image_w, image_h, boxes): dx = int(_rand(0, image_w - nw)) dy = int(_rand(0, image_h - nh)) - if bool(boxes): + if boxes.shape[0] > 0: crop_box = np.array((dx, dy, dx + nw, dy + nh)) if not _is_iof_satisfied_constraint(boxes, crop_box[np.newaxis]): continue diff --git a/model_zoo/official/cv/retinaface_resnet50/src/dataset.py b/model_zoo/official/cv/retinaface_resnet50/src/dataset.py index 6592e906fc0..716a8217aec 100644 --- a/model_zoo/official/cv/retinaface_resnet50/src/dataset.py +++ b/model_zoo/official/cv/retinaface_resnet50/src/dataset.py @@ -71,7 +71,7 @@ def read_dataset(img_path, annotation): labels = annotation anns = np.zeros((0, 15)) - if not bool(labels): + if labels.shape[0] <= 0: return anns for _, label in enumerate(labels): ann = np.zeros((1, 15))