forked from huawei/mindspore2022
fasterrcnn add export.py in r1.0
This commit is contained in:
parent
9fe624527b
commit
81c6acadc1
|
|
@ -33,7 +33,9 @@ FasterRcnn is a two-stage target detection network,This network uses a region pr
|
|||
|
||||
# Dataset
|
||||
|
||||
Dataset used: [COCO2017](<http://images.cocodataset.org/>)
|
||||
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.
|
||||
|
||||
Dataset used: [COCO2017](<https://cocodataset.org/>)
|
||||
|
||||
- Dataset size:19G
|
||||
- Train:18G,118000 images
|
||||
|
|
@ -148,7 +150,7 @@ sh run_standalone_train_ascend.sh [PRETRAINED_MODEL]
|
|||
sh run_distribute_train_ascend.sh [RANK_TABLE_FILE] [PRETRAINED_MODEL]
|
||||
```
|
||||
|
||||
> Rank_table.json which is specified by RANK_TABLE_FILE is needed when you are running a distribute task. You can generate it by using the [hccl_tools](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools).
|
||||
> Rank_table.json which is specified by RANK_TABLE_FILE is needed when you are running a distribute task. You can generate it by using the [hccl_tools](https://gitee.com/mindspore/mindspore/tree/r1.0/model_zoo/utils/hccl_tools).
|
||||
> As for PRETRAINED_MODEL,it should be a ResNet50 checkpoint that trained over ImageNet2012. Ready-made pretrained_models are not available now. Stay tuned.
|
||||
> The original dataset path needs to be in the config.py,you can select "coco_root" or "image_dir".
|
||||
|
||||
|
|
@ -207,9 +209,9 @@ Eval result will be stored in the example path, whose folder name is "eval". Und
|
|||
| Parameters | FasterRcnn |
|
||||
| -------------------------- | ----------------------------------------------------------- |
|
||||
| Model Version | V1 |
|
||||
| Resource | Ascend 910 ;CPU 2.60GHz,56cores;Memory,314G |
|
||||
| Resource | Ascend 910 ;CPU 2.60GHz,192cores;Memory,755G |
|
||||
| uploaded Date | 08/31/2020 (month/day/year) |
|
||||
| MindSpore Version | 0.7.0-beta |
|
||||
| MindSpore Version | 1.0.0 |
|
||||
| Dataset | COCO2017 |
|
||||
| Training Parameters | epoch=12, batch_size=2 |
|
||||
| Optimizer | SGD |
|
||||
|
|
@ -217,7 +219,7 @@ Eval result will be stored in the example path, whose folder name is "eval". Und
|
|||
| Speed | 1pc: 190 ms/step; 8pcs: 200 ms/step |
|
||||
| Total time | 1pc: 37.17 hours; 8pcs: 4.89 hours |
|
||||
| Parameters (M) | 250 |
|
||||
| Scripts | https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/faster_rcnn |
|
||||
| Scripts | [fasterrcnn script](https://gitee.com/mindspore/mindspore/tree/r1.0/model_zoo/official/cv/faster_rcnn) |
|
||||
|
||||
|
||||
### Evaluation Performance
|
||||
|
|
@ -227,7 +229,7 @@ Eval result will be stored in the example path, whose folder name is "eval". Und
|
|||
| Model Version | V1 |
|
||||
| Resource | Ascend 910 |
|
||||
| Uploaded Date | 08/31/2020 (month/day/year) |
|
||||
| MindSpore Version | 0.7.0-beta |
|
||||
| MindSpore Version | 1.0.0 |
|
||||
| Dataset | COCO2017 |
|
||||
| batch_size | 2 |
|
||||
| outputs | mAP |
|
||||
|
|
@ -235,4 +237,5 @@ Eval result will be stored in the example path, whose folder name is "eval". Und
|
|||
| Model for inference | 250M (.ckpt file) |
|
||||
|
||||
# [ModelZoo Homepage](#contents)
|
||||
Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).
|
||||
Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/r1.0/model_zoo).
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""export checkpoint file into air models"""
|
||||
import argparse
|
||||
import numpy as np
|
||||
|
||||
import mindspore as ms
|
||||
from mindspore import Tensor, load_checkpoint, load_param_into_net, export
|
||||
|
||||
from src.FasterRcnn.faster_rcnn_r50 import Faster_Rcnn_Resnet50
|
||||
from src.config import config
|
||||
|
||||
parser = argparse.ArgumentParser(description='fasterrcnn_export')
|
||||
parser.add_argument('--ckpt_file', type=str, default='', help='fasterrcnn ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='', help='fasterrcnn output air name.')
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
if __name__ == '__main__':
|
||||
net = Faster_Rcnn_Resnet50(config=config)
|
||||
|
||||
param_dict = load_checkpoint(args.ckpt_file)
|
||||
load_param_into_net(net, param_dict)
|
||||
|
||||
img = Tensor(np.zeros([config.test_batch_size, 3, config.img_height, config.img_width]), ms.float16)
|
||||
img_metas = Tensor(np.random.uniform(0.0, 1.0, size=[config.test_batch_size, 4]), ms.float16)
|
||||
gt_bboxes = Tensor(np.random.uniform(0.0, 1.0, size=[config.test_batch_size, config.num_gts]), ms.float16)
|
||||
gt_label = Tensor(np.random.uniform(0.0, 1.0, size=[config.test_batch_size, config.num_gts]), ms.int32)
|
||||
gt_num = Tensor(np.random.uniform(0.0, 1.0, size=[config.test_batch_size, config.num_gts]), ms.bool_)
|
||||
|
||||
export(net, img, img_metas, gt_bboxes, gt_label, gt_num, file_name=args.output_file, file_format=args.file_format)
|
||||
Loading…
Reference in New Issue