From c8268df1d1ac41a101c3ebafe6b8a6aa08c7c258 Mon Sep 17 00:00:00 2001 From: gengdongjie Date: Mon, 26 Oct 2020 10:54:37 +0800 Subject: [PATCH] opt maskrnn preprocessing pref --- model_zoo/official/cv/maskrcnn/README.md | 15 +++++++++------ model_zoo/official/cv/maskrcnn/src/dataset.py | 6 ++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/model_zoo/official/cv/maskrcnn/README.md b/model_zoo/official/cv/maskrcnn/README.md index 28feb1fa09..d876e9cdce 100644 --- a/model_zoo/official/cv/maskrcnn/README.md +++ b/model_zoo/official/cv/maskrcnn/README.md @@ -35,6 +35,9 @@ MaskRCNN is a two-stage target detection network. It extends FasterRCNN by addin [Paper](http://cn.arxiv.org/pdf/1703.06870v3): Kaiming He, Georgia Gkioxari, Piotr Dollar and Ross Girshick. "MaskRCNN" # [Dataset](#contents) + +Note that you can run the scripts based on the dataset mentioned in original paper or widely used in relevant domain/network architecture. In the following sections, we will introduce how to run the scripts using the related dataset below. + - [COCO2017](https://cocodataset.org/) is a popular dataset with bounding-box and pixel-level stuff annotations. These annotations can be used for scene understanding tasks like semantic segmentation, object detection and image captioning. There are 118K/5K images for train/val. - Dataset size: 19G @@ -398,12 +401,12 @@ Accumulating evaluation results... ### Evaluation Performance -| Parameters | MaskRCNN | +| Parameters | Ascend | | -------------------------- | ----------------------------------------------------------- | | Model Version | V1 | -| Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory, 755G | +| Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory, 755G | | uploaded Date | 08/01/2020 (month/day/year) | -| MindSpore Version | 0.6.0-alpha | +| MindSpore Version | 1.0.0 | | Dataset | COCO2017 | | Training Parameters | epoch=12, batch_size = 2 | | Optimizer | SGD | @@ -414,18 +417,18 @@ Accumulating evaluation results... | Total time | 1pc: 46 hours; 8pcs: 5.38 hours | | Parameters (M) | 84.8 | | Checkpoint for Fine tuning | 85M(.ckpt file) | -| Model for inference | 571M(.air file) | +| Model for inference | 571M(.air file) | | Scripts | [maskrcnn script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/maskrcnn) | ### Inference Performance -| Parameters | MaskRCNN | +| Parameters | Ascend | | ------------------- | --------------------------- | | Model Version | V1 | | Resource | Ascend 910 | | Uploaded Date | 08/01/2020 (month/day/year) | -| MindSpore Version | 0.6.0-alpha | +| MindSpore Version | 1.0.0 | | Dataset | COCO2017 | | batch_size | 2 | | outputs | mAP | diff --git a/model_zoo/official/cv/maskrcnn/src/dataset.py b/model_zoo/official/cv/maskrcnn/src/dataset.py index 53b9efb84d..bb055bde2c 100644 --- a/model_zoo/official/cv/maskrcnn/src/dataset.py +++ b/model_zoo/official/cv/maskrcnn/src/dataset.py @@ -301,10 +301,8 @@ def pad_to_max(img, img_shape, gt_bboxes, gt_label, gt_num, gt_mask, instance_co gt_label_new = np.pad(gt_label, ((0, pad_max_number - instance_count)), mode="constant", constant_values=-1) gt_iscrowd_new = np.pad(gt_num, ((0, pad_max_number - instance_count)), mode="constant", constant_values=1) gt_iscrowd_new_revert = ~(gt_iscrowd_new.astype(np.bool)) - gt_mask_new = np.pad(gt_mask, ((0, pad_max_number - instance_count), (0, 0), (0, 0)), mode="constant", - constant_values=0) - return img, img_shape, gt_box_new, gt_label_new, gt_iscrowd_new_revert, gt_mask_new + return img, img_shape, gt_box_new, gt_label_new, gt_iscrowd_new_revert, gt_mask def preprocess_fn(image, box, mask, mask_shape, is_training): """Preprocess function for dataset.""" @@ -518,7 +516,7 @@ def create_maskrcnn_dataset(mindrecord_file, batch_size=2, device_num=1, rank_id column_order=["image", "image_shape", "box", "label", "valid_num", "mask"], python_multiprocessing=False, num_parallel_workers=num_parallel_workers) - ds = ds.batch(batch_size, drop_remainder=True) + ds = ds.batch(batch_size, drop_remainder=True, pad_info={"mask": ([config.max_instance_count, None, None], 0)}) else: ds = ds.map(operations=compose_map_func,