diff --git a/models b/models
new file mode 160000
index 0000000000000000000000000000000000000000..1329e3bb2a78bccd508a630eec0376c9ece1e104
--- /dev/null
+++ b/models
@@ -0,0 +1 @@
+Subproject commit 1329e3bb2a78bccd508a630eec0376c9ece1e104
diff --git a/research/cv/ssd_resnet50/Dockerfile b/research/cv/ssd_resnet50/Dockerfile
index fcb31f207f23664ca2d60bda9a15463af1042dd9..1b847a3ec546252b0d6c8531f89cb202a111c9da 100644
--- a/research/cv/ssd_resnet50/Dockerfile
+++ b/research/cv/ssd_resnet50/Dockerfile
@@ -1,6 +1,6 @@
-ARG FROM_IMAGE_NAME
-FROM ${FROM_IMAGE_NAME}
-
-RUN apt install libgl1-mesa-glx -y
-COPY requirements.txt .
-RUN pip3.7 install -r requirements.txt
+ARG FROM_IMAGE_NAME
+FROM ${FROM_IMAGE_NAME}
+
+RUN apt install libgl1-mesa-glx -y
+COPY requirements.txt .
+RUN pip3.7 install -r requirements.txt
diff --git a/research/cv/ssd_resnet50/README.md b/research/cv/ssd_resnet50/README.md
index 6a9c4bbd6c2b8b1f05b67437b210df30947f1c85..3cb5d376123e3ed1d2a398a088df42f6303eee0e 100644
--- a/research/cv/ssd_resnet50/README.md
+++ b/research/cv/ssd_resnet50/README.md
@@ -1,352 +1,352 @@
-# Contents
-
-- [Contents](#contents)
- - [SSD Description](#ssd-description)
- - [Model Architecture](#model-architecture)
- - [Dataset](#dataset)
- - [Environment Requirements](#environment-requirements)
- - [Quick Start](#quick-start)
- - [Prepare the model](#prepare-the-model)
- - [Run the scripts](#run-the-scripts)
- - [Script Description](#script-description)
- - [Script and Sample Code](#script-and-sample-code)
- - [Script Parameters](#script-parameters)
- - [Training Process](#training-process)
- - [Training on Ascend](#training-on-ascend)
- - [Evaluation Process](#evaluation-process)
- - [Evaluation on Ascend](#evaluation-on-ascend)
- - [Performance](#performance)
- - [Export Process](#Export-process)
- - [Export](#Export)
- - [Inference Process](#Inference-process)
- - [Inference](#Inference)
- - [Description of Random Situation](#description-of-random-situation)
- - [ModelZoo Homepage](#modelzoo-homepage)
-
-## [SSD Description](#contents)
-
-SSD discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location. At prediction time, the network generates scores for the presence of each object category in each default box and produces adjustments to the box to better match the object shape.Additionally, the network combines predictions from multiple feature maps with different resolutions to naturally handle objects of various sizes.
-
-[Paper](https://arxiv.org/abs/1512.02325): Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.European Conference on Computer Vision (ECCV), 2016 (In press).
-
-## [Model Architecture](#contents)
-
-The SSD approach is based on a feed-forward convolutional network that produces a fixed-size collection of bounding boxes and scores for the presence of object class instances in those boxes, followed by a non-maximum suppression step to produce the final detections. The early network layers are based on a standard architecture used for high quality image classification, which is called the base network. Then add auxiliary structure to the network to produce detections.
-
-## [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.
-
-Dataset used: [COCO2017]()
-
-- Dataset size:19G
- - Train:18G,118000 images
- - Val:1G,5000 images
- - Annotations:241M,instances,captions,person_keypoints etc
-- Data format:image and json files
- - Note:Data will be processed in dataset.py
-
-## [Environment Requirements](#contents)
-
-- Install [MindSpore](https://www.mindspore.cn/install/en).
-
-- Download the dataset COCO2017.
-
-- We use COCO2017 as training dataset in this example by default, and you can also use your own datasets.
- First, install Cython ,pycocotool and opencv to process data and to get evaluation result.
-
- ```shell
- pip install Cython
-
- pip install pycocotools
-
- pip install opencv-python
- ```
-
- 1. If coco dataset is used. **Select dataset to coco when run script.**
-
- Change the `coco_root` and other settings you need in `src/config.py`. The directory structure is as follows:
-
- ```shell
- .
- └─coco_dataset
- ├─annotations
- ├─instance_train2017.json
- └─instance_val2017.json
- ├─val2017
- └─train2017
- ```
-
- 2. If VOC dataset is used. **Select dataset to voc when run script.**
- Change `classes`, `num_classes`, `voc_json` and `voc_root` in `src/config.py`. `voc_json` is the path of json file with coco format for evaluation, `voc_root` is the path of VOC dataset, the directory structure is as follows:
-
- ```shell
- .
- └─voc_dataset
- └─train
- ├─0001.jpg
- └─0001.xml
- ...
- ├─xxxx.jpg
- └─xxxx.xml
- └─eval
- ├─0001.jpg
- └─0001.xml
- ...
- ├─xxxx.jpg
- └─xxxx.xml
- ```
-
- 3. If your own dataset is used. **Select dataset to other when run script.**
- Organize the dataset information into a TXT file, each row in the file is as follows:
-
- ```shell
- train2017/0000001.jpg 0,259,401,459,7 35,28,324,201,2 0,30,59,80,2
- ```
-
- Each row is an image annotation which split by space, the first column is a relative path of image, the others are box and class infomations of the format [xmin,ymin,xmax,ymax,class]. We read image from an image path joined by the `image_dir`(dataset directory) and the relative path in `anno_path`(the TXT file path), `image_dir` and `anno_path` are setting in `src/config.py`.
-
-## [Quick Start](#contents)
-
-### Run the scripts
-
-After installing MindSpore via the official website, you can start training and evaluation as follows:
-
-- running on Ascend
-
-```shell
-# distributed training on Ascend
-bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE]
-
-# training on single NPU
-bash run_standalone_train.sh
-
-# run eval on Ascend
-bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
-
-```
-
-- Run on docker
-
-Build docker images(Change version to the one you actually used)
-
-```shell
-# build docker
-docker build -t ssd:20.1.0 . --build-arg FROM_IMAGE_NAME=ascend-mindspore-arm:20.1.0
-```
-
-Create a container layer over the created image and start it
-
-```shell
-# start docker
-bash scripts/docker_start.sh ssd:20.1.0 [DATA_DIR] [MODEL_DIR]
-```
-
-Then you can run everything just like on ascend.
-
-## [Script Description](#contents)
-
-### [Script and Sample Code](#contents)
-
-```shell
-.
-└─ cv
- └─ ssd
- ├─ README.md # descriptions about SSD
- ├─ ascend310_infer # application for 310 inference
- ├─ scripts
- ├─ run_distribute_train.sh # shell script for distributed on ascend
- ├─ run_eval.sh # shell script for eval on ascend
- └─ run_infer_310.sh # shell script for 310 inference
- ├─ src
- ├─ __init__.py # init file
- ├─ box_utils.py # bbox utils
- ├─ eval_utils.py # metrics utils
- ├─ config.py # total config
- ├─ dataset.py # create dataset and process dataset
- ├─ init_params.py # parameters utils
- ├─ lr_schedule.py # learning ratio generator
- └─ ssd.py # ssd architecture
- ├─ eval.py # eval scripts
- ├─ train.py # train scripts
- ├─ export.py # export mindir script
- ├─ postprogress.py # post process for 310 inference
- └─ mindspore_hub_conf.py # mindspore hub interface
-```
-
-### [Script Parameters](#contents)
-
- ```shell
- Major parameters in train.py and config.py as follows:
-
- "device_num": 1 # Use device nums
- "lr": 0.05 # Learning rate init value
- "dataset": coco # Dataset name
- "epoch_size": 500 # Epoch size
- "batch_size": 32 # Batch size of input tensor
- "pre_trained": None # Pretrained checkpoint file path
- "pre_trained_epoch_size": 0 # Pretrained epoch size
- "save_checkpoint_epochs": 10 # The epoch interval between two checkpoints. By default, the checkpoint will be saved per 10 epochs
- "loss_scale": 1024 # Loss scale
- "filter_weight": False # Load parameters in head layer or not. If the class numbers of train dataset is different from the class numbers in pre_trained checkpoint, please set True.
- "freeze_layer": "none" # Freeze the backbone parameters or not, support none and backbone.
-
- "class_num": 81 # Dataset class number
- "image_shape": [300, 300] # Image height and width used as input to the model
- "mindrecord_dir": "/data/MindRecord_COCO" # MindRecord path
- "coco_root": "/data/coco2017" # COCO2017 dataset path
- "voc_root": "/data/voc_dataset" # VOC original dataset path
- "voc_json": "annotations/voc_instances_val.json" # is the path of json file with coco format for evaluation
- "image_dir": "" # Other dataset image path, if coco or voc used, it will be useless
- "anno_path": "" # Other dataset annotation path, if coco or voc used, it will be useless
-
- ```
-
-### [Training Process](#contents)
-
-To train the model, run `train.py`. If the `mindrecord_dir` is empty, it will generate [mindrecord](https://www.mindspore.cn/docs/programming_guide/en/master/convert_dataset.html) files by `coco_root`(coco dataset), `voc_root`(voc dataset) or `image_dir` and `anno_path`(own dataset). **Note if mindrecord_dir isn't empty, it will use mindrecord_dir instead of raw images.**
-
-#### Training on Ascend
-
-- Distribute mode
-
-```shell
- bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE] [PRE_TRAINED](optional) [PRE_TRAINED_EPOCH_SIZE](optional)
-```
-
-We need five or seven parameters for this scripts.
-
-- `DEVICE_NUM`: the device number for distributed train.
-- `EPOCH_NUM`: epoch num for distributed train.
-- `LR`: learning rate init value for distributed train.
-- `DATASET`:the dataset mode for distributed train.
-- `RANK_TABLE_FILE :` the path of [rank_table.json](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools), it is better to use absolute path.
-- `PRE_TRAINED :` the path of pretrained checkpoint file, it is better to use absolute path.
-- `PRE_TRAINED_EPOCH_SIZE :` the epoch num of pretrained.
-
-Training result will be stored in the current path, whose folder name begins with "LOG". Under this, you can find checkpoint file together with result like the followings in log
-
-```shell
-epoch: 1 step: 458, loss is 3.1681802
-epoch time: 228752.4654865265, per step time: 499.4595316299705
-epoch: 2 step: 458, loss is 2.8847265
-epoch time: 38912.93382644653, per step time: 84.96273761232868
-epoch: 3 step: 458, loss is 2.8398118
-epoch time: 38769.184827804565, per step time: 84.64887516987896
-...
-
-epoch: 498 step: 458, loss is 0.70908034
-epoch time: 38771.079778671265, per step time: 84.65301261718616
-epoch: 499 step: 458, loss is 0.7974688
-epoch time: 38787.413120269775, per step time: 84.68867493508685
-epoch: 500 step: 458, loss is 0.5548882
-epoch time: 39064.8467540741, per step time: 85.29442522723602
-```
-
-### [Evaluation Process](#contents)
-
-#### Evaluation on Ascend
-
-```shell
-bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
-```
-
-We need two parameters for this scripts.
-
-- `DATASET`:the dataset mode of evaluation dataset.
-- `CHECKPOINT_PATH`: the absolute path for checkpoint file.
-- `DEVICE_ID`: the device id for eval.
-
-> checkpoint can be produced in training process.
-
-Inference result will be stored in the example path, whose folder name begins with "eval". Under this, you can find result like the followings in log.
-
-```shell
-Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
-Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.474
-Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
-Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.120
-Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.350
-Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.315
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.489
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.511
-Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.208
-Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.557
-Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.689
-
-========================================
-
-mAP: 0.32719216721918915
-
-```
-
-## [Export Process](#contents)
-
-### [Export](#content)
-
-```shell
-python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_format[EXPORT_FORMAT]
-```
-
-`EXPORT_FORMAT` should be in ["AIR", "MINDIR"]
-
-## [Inference Process](#contents)
-
-### [Inference](#content)
-
-Before performing inference, we need to export model first. Air model can only be exported in Ascend 910 environment, mindir model can be exported in any environment.
-Current batch_ Size can only be set to 1.
-
-```shell
-# Ascend310 inference
-bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID]
-```
-
-Inference result will be stored in the example path, you can find result like the followings in acc.log.
-
-```shell
-Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
-Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.475
-Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
-Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.115
-Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.353
-Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.455
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.314
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.485
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.509
-Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.200
-Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.554
-Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.692
-
-mAP: 0.3266651054070853
-```
-
-### [Performance](#contents)
-
-| 参数 | Ascend |
-| ------------------- | --------------------- |
-| 模型版本 | SSD resnet50 |
-| 资源 | Ascend 910 |
-| 上传日期 | 2020-03-29 |
-| MindSpore版本 | 1.1.0 |
-| 数据集 | COCO2017 |
-| mAP | IoU=0.50: 32.7% |
-| 模型大小 | 281M(.ckpt文件) |
-
-## [Export MindIR](#contents)
-
-```shell
-python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --file_format [FILE_FORMAT]
-```
-
-The ckpt_file parameter is required,
-`EXPORT_FORMAT` should be in ["AIR", "MINDIR"]
-
-## [Description of Random Situation](#contents)
-
-In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
-
-## [ModelZoo Homepage](#contents)
-
- Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).
+# Contents
+
+- [Contents](#contents)
+ - [SSD Description](#ssd-description)
+ - [Model Architecture](#model-architecture)
+ - [Dataset](#dataset)
+ - [Environment Requirements](#environment-requirements)
+ - [Quick Start](#quick-start)
+ - [Prepare the model](#prepare-the-model)
+ - [Run the scripts](#run-the-scripts)
+ - [Script Description](#script-description)
+ - [Script and Sample Code](#script-and-sample-code)
+ - [Script Parameters](#script-parameters)
+ - [Training Process](#training-process)
+ - [Training on Ascend](#training-on-ascend)
+ - [Evaluation Process](#evaluation-process)
+ - [Evaluation on Ascend](#evaluation-on-ascend)
+ - [Performance](#performance)
+ - [Export Process](#Export-process)
+ - [Export](#Export)
+ - [Inference Process](#Inference-process)
+ - [Inference](#Inference)
+ - [Description of Random Situation](#description-of-random-situation)
+ - [ModelZoo Homepage](#modelzoo-homepage)
+
+## [SSD Description](#contents)
+
+SSD discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location. At prediction time, the network generates scores for the presence of each object category in each default box and produces adjustments to the box to better match the object shape.Additionally, the network combines predictions from multiple feature maps with different resolutions to naturally handle objects of various sizes.
+
+[Paper](https://arxiv.org/abs/1512.02325): Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.European Conference on Computer Vision (ECCV), 2016 (In press).
+
+## [Model Architecture](#contents)
+
+The SSD approach is based on a feed-forward convolutional network that produces a fixed-size collection of bounding boxes and scores for the presence of object class instances in those boxes, followed by a non-maximum suppression step to produce the final detections. The early network layers are based on a standard architecture used for high quality image classification, which is called the base network. Then add auxiliary structure to the network to produce detections.
+
+## [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.
+
+Dataset used: [COCO2017]()
+
+- Dataset size:19G
+ - Train:18G,118000 images
+ - Val:1G,5000 images
+ - Annotations:241M,instances,captions,person_keypoints etc
+- Data format:image and json files
+ - Note:Data will be processed in dataset.py
+
+## [Environment Requirements](#contents)
+
+- Install [MindSpore](https://www.mindspore.cn/install/en).
+
+- Download the dataset COCO2017.
+
+- We use COCO2017 as training dataset in this example by default, and you can also use your own datasets.
+ First, install Cython ,pycocotool and opencv to process data and to get evaluation result.
+
+ ```shell
+ pip install Cython
+
+ pip install pycocotools
+
+ pip install opencv-python
+ ```
+
+ 1. If coco dataset is used. **Select dataset to coco when run script.**
+
+ Change the `coco_root` and other settings you need in `src/config.py`. The directory structure is as follows:
+
+ ```shell
+ .
+ └─coco_dataset
+ ├─annotations
+ ├─instance_train2017.json
+ └─instance_val2017.json
+ ├─val2017
+ └─train2017
+ ```
+
+ 2. If VOC dataset is used. **Select dataset to voc when run script.**
+ Change `classes`, `num_classes`, `voc_json` and `voc_root` in `src/config.py`. `voc_json` is the path of json file with coco format for evaluation, `voc_root` is the path of VOC dataset, the directory structure is as follows:
+
+ ```shell
+ .
+ └─voc_dataset
+ └─train
+ ├─0001.jpg
+ └─0001.xml
+ ...
+ ├─xxxx.jpg
+ └─xxxx.xml
+ └─eval
+ ├─0001.jpg
+ └─0001.xml
+ ...
+ ├─xxxx.jpg
+ └─xxxx.xml
+ ```
+
+ 3. If your own dataset is used. **Select dataset to other when run script.**
+ Organize the dataset information into a TXT file, each row in the file is as follows:
+
+ ```shell
+ train2017/0000001.jpg 0,259,401,459,7 35,28,324,201,2 0,30,59,80,2
+ ```
+
+ Each row is an image annotation which split by space, the first column is a relative path of image, the others are box and class infomations of the format [xmin,ymin,xmax,ymax,class]. We read image from an image path joined by the `image_dir`(dataset directory) and the relative path in `anno_path`(the TXT file path), `image_dir` and `anno_path` are setting in `src/config.py`.
+
+## [Quick Start](#contents)
+
+### Run the scripts
+
+After installing MindSpore via the official website, you can start training and evaluation as follows:
+
+- running on Ascend
+
+```shell
+# distributed training on Ascend
+bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE]
+
+# training on single NPU
+bash run_standalone_train.sh
+
+# run eval on Ascend
+bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
+
+```
+
+- Run on docker
+
+Build docker images(Change version to the one you actually used)
+
+```shell
+# build docker
+docker build -t ssd:20.1.0 . --build-arg FROM_IMAGE_NAME=ascend-mindspore-arm:20.1.0
+```
+
+Create a container layer over the created image and start it
+
+```shell
+# start docker
+bash scripts/docker_start.sh ssd:20.1.0 [DATA_DIR] [MODEL_DIR]
+```
+
+Then you can run everything just like on ascend.
+
+## [Script Description](#contents)
+
+### [Script and Sample Code](#contents)
+
+```shell
+.
+└─ cv
+ └─ ssd
+ ├─ README.md # descriptions about SSD
+ ├─ ascend310_infer # application for 310 inference
+ ├─ scripts
+ ├─ run_distribute_train.sh # shell script for distributed on ascend
+ ├─ run_eval.sh # shell script for eval on ascend
+ └─ run_infer_310.sh # shell script for 310 inference
+ ├─ src
+ ├─ __init__.py # init file
+ ├─ box_utils.py # bbox utils
+ ├─ eval_utils.py # metrics utils
+ ├─ config.py # total config
+ ├─ dataset.py # create dataset and process dataset
+ ├─ init_params.py # parameters utils
+ ├─ lr_schedule.py # learning ratio generator
+ └─ ssd.py # ssd architecture
+ ├─ eval.py # eval scripts
+ ├─ train.py # train scripts
+ ├─ export.py # export mindir script
+ ├─ postprogress.py # post process for 310 inference
+ └─ mindspore_hub_conf.py # mindspore hub interface
+```
+
+### [Script Parameters](#contents)
+
+ ```shell
+ Major parameters in train.py and config.py as follows:
+
+ "device_num": 1 # Use device nums
+ "lr": 0.05 # Learning rate init value
+ "dataset": coco # Dataset name
+ "epoch_size": 500 # Epoch size
+ "batch_size": 32 # Batch size of input tensor
+ "pre_trained": None # Pretrained checkpoint file path
+ "pre_trained_epoch_size": 0 # Pretrained epoch size
+ "save_checkpoint_epochs": 10 # The epoch interval between two checkpoints. By default, the checkpoint will be saved per 10 epochs
+ "loss_scale": 1024 # Loss scale
+ "filter_weight": False # Load parameters in head layer or not. If the class numbers of train dataset is different from the class numbers in pre_trained checkpoint, please set True.
+ "freeze_layer": "none" # Freeze the backbone parameters or not, support none and backbone.
+
+ "class_num": 81 # Dataset class number
+ "image_shape": [300, 300] # Image height and width used as input to the model
+ "mindrecord_dir": "/data/MindRecord_COCO" # MindRecord path
+ "coco_root": "/data/coco2017" # COCO2017 dataset path
+ "voc_root": "/data/voc_dataset" # VOC original dataset path
+ "voc_json": "annotations/voc_instances_val.json" # is the path of json file with coco format for evaluation
+ "image_dir": "" # Other dataset image path, if coco or voc used, it will be useless
+ "anno_path": "" # Other dataset annotation path, if coco or voc used, it will be useless
+
+ ```
+
+### [Training Process](#contents)
+
+To train the model, run `train.py`. If the `mindrecord_dir` is empty, it will generate [mindrecord](https://www.mindspore.cn/docs/programming_guide/en/master/convert_dataset.html) files by `coco_root`(coco dataset), `voc_root`(voc dataset) or `image_dir` and `anno_path`(own dataset). **Note if mindrecord_dir isn't empty, it will use mindrecord_dir instead of raw images.**
+
+#### Training on Ascend
+
+- Distribute mode
+
+```shell
+ bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE] [PRE_TRAINED](optional) [PRE_TRAINED_EPOCH_SIZE](optional)
+```
+
+We need five or seven parameters for this scripts.
+
+- `DEVICE_NUM`: the device number for distributed train.
+- `EPOCH_NUM`: epoch num for distributed train.
+- `LR`: learning rate init value for distributed train.
+- `DATASET`:the dataset mode for distributed train.
+- `RANK_TABLE_FILE :` the path of [rank_table.json](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools), it is better to use absolute path.
+- `PRE_TRAINED :` the path of pretrained checkpoint file, it is better to use absolute path.
+- `PRE_TRAINED_EPOCH_SIZE :` the epoch num of pretrained.
+
+Training result will be stored in the current path, whose folder name begins with "LOG". Under this, you can find checkpoint file together with result like the followings in log
+
+```shell
+epoch: 1 step: 458, loss is 3.1681802
+epoch time: 228752.4654865265, per step time: 499.4595316299705
+epoch: 2 step: 458, loss is 2.8847265
+epoch time: 38912.93382644653, per step time: 84.96273761232868
+epoch: 3 step: 458, loss is 2.8398118
+epoch time: 38769.184827804565, per step time: 84.64887516987896
+...
+
+epoch: 498 step: 458, loss is 0.70908034
+epoch time: 38771.079778671265, per step time: 84.65301261718616
+epoch: 499 step: 458, loss is 0.7974688
+epoch time: 38787.413120269775, per step time: 84.68867493508685
+epoch: 500 step: 458, loss is 0.5548882
+epoch time: 39064.8467540741, per step time: 85.29442522723602
+```
+
+### [Evaluation Process](#contents)
+
+#### Evaluation on Ascend
+
+```shell
+bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
+```
+
+We need two parameters for this scripts.
+
+- `DATASET`:the dataset mode of evaluation dataset.
+- `CHECKPOINT_PATH`: the absolute path for checkpoint file.
+- `DEVICE_ID`: the device id for eval.
+
+> checkpoint can be produced in training process.
+
+Inference result will be stored in the example path, whose folder name begins with "eval". Under this, you can find result like the followings in log.
+
+```shell
+Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
+Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.474
+Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
+Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.120
+Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.350
+Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.315
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.489
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.511
+Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.208
+Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.557
+Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.689
+
+========================================
+
+mAP: 0.32719216721918915
+
+```
+
+## [Export Process](#contents)
+
+### [Export](#content)
+
+```shell
+python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_format[EXPORT_FORMAT]
+```
+
+`EXPORT_FORMAT` should be in ["AIR", "MINDIR"]
+
+## [Inference Process](#contents)
+
+### [Inference](#content)
+
+Before performing inference, we need to export model first. Air model can only be exported in Ascend 910 environment, mindir model can be exported in any environment.
+Current batch_ Size can only be set to 1.
+
+```shell
+# Ascend310 inference
+bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID]
+```
+
+Inference result will be stored in the example path, you can find result like the followings in acc.log.
+
+```shell
+Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
+Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.475
+Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
+Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.115
+Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.353
+Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.455
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.314
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.485
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.509
+Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.200
+Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.554
+Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.692
+
+mAP: 0.3266651054070853
+```
+
+### [Performance](#contents)
+
+| 参数 | Ascend |
+| ------------------- | --------------------- |
+| 模型版本 | SSD resnet50 |
+| 资源 | Ascend 910 |
+| 上传日期 | 2020-03-29 |
+| MindSpore版本 | 1.1.0 |
+| 数据集 | COCO2017 |
+| mAP | IoU=0.50: 32.7% |
+| 模型大小 | 281M(.ckpt文件) |
+
+## [Export MindIR](#contents)
+
+```shell
+python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --file_format [FILE_FORMAT]
+```
+
+The ckpt_file parameter is required,
+`EXPORT_FORMAT` should be in ["AIR", "MINDIR"]
+
+## [Description of Random Situation](#contents)
+
+In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
+
+## [ModelZoo Homepage](#contents)
+
+ Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).
diff --git a/research/cv/ssd_resnet50/README_CN.md b/research/cv/ssd_resnet50/README_CN.md
index ba92664d1e0f142b670df405caeec8fecaaf1419..081e8678603060c2e143fe8a15926bb558927ff5 100644
--- a/research/cv/ssd_resnet50/README_CN.md
+++ b/research/cv/ssd_resnet50/README_CN.md
@@ -1,304 +1,304 @@
-# 目录
-
-
-
-- [目录](#目录)
-- [SSD说明](#ssd说明)
-- [模型架构](#模型架构)
-- [数据集](#数据集)
-- [环境要求](#环境要求)
-- [快速入门](#快速入门)
-- [脚本说明](#脚本说明)
- - [脚本及样例代码](#脚本及样例代码)
- - [脚本参数](#脚本参数)
- - [训练过程](#训练过程)
- - [Ascend上训练](#ascend上训练)
- - [评估过程](#评估过程)
- - [Ascend处理器环境评估](#ascend处理器环境评估)
- - [性能](#性能)
- - [导出过程](#导出过程)
- - [导出](#导出)
- - [推理过程](#推理过程)
- - [推理](#推理)
-- [随机情况说明](#随机情况说明)
-- [ModelZoo主页](#modelzoo主页)
-
-
-
-# SSD说明
-
-SSD将边界框的输出空间离散成一组默认框,每个特征映射位置具有不同的纵横比和尺度。在预测时,网络对每个默认框中存在的对象类别进行评分,并对框进行调整以更好地匹配对象形状。此外,网络将多个不同分辨率的特征映射的预测组合在一起,自然处理各种大小的对象。
-
-[论文](https://arxiv.org/abs/1512.02325): Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.European Conference on Computer Vision (ECCV), 2016 (In press).
-
-# 模型架构
-
-SSD方法基于前向卷积网络,该网络产生固定大小的边界框集合,并针对这些框内存在的对象类实例进行评分,然后通过非极大值抑制步骤进行最终检测。早期的网络层基于高质量图像分类的标准体系结构,被称为基础网络。后来通过向网络添加辅助结构进行检测。
-
-# 数据集
-
-使用的数据集: [COCO2017]()
-
-- 数据集大小:19 GB
- - 训练集:18 GB,118000张图像
- - 验证集:1 GB,5000张图像
- - 标注:241 MB,实例,字幕,person_keypoints等
-- 数据格式:图像和json文件
- - 注意:数据在dataset.py中处理
-
-# 环境要求
-
-- 安装[MindSpore](https://www.mindspore.cn/install)。
-
-- 下载数据集COCO2017。
-
-- 本示例默认使用COCO2017作为训练数据集,您也可以使用自己的数据集。
-
- 1. 如果使用coco数据集。**执行脚本时选择数据集coco。**
- 安装Cython和pycocotool,也可以安装mmcv进行数据处理。
-
- ```python
- pip install Cython
-
- pip install pycocotools
-
- ```
-
- 并在`config.py`中更改COCO_ROOT和其他您需要的设置。目录结构如下:
-
- ```text
- .
- └─cocodataset
- ├─annotations
- ├─instance_train2017.json
- └─instance_val2017.json
- ├─val2017
- └─train2017
-
- ```
-
- 2. 如果使用自己的数据集。**执行脚本时选择数据集为other。**
- 将数据集信息整理成TXT文件,每行如下:
-
- ```text
- train2017/0000001.jpg 0,259,401,459,7 35,28,324,201,2 0,30,59,80,2
-
- ```
-
- 每行是按空间分割的图像标注,第一列是图像的相对路径,其余为[xmin,ymin,xmax,ymax,class]格式的框和类信息。我们从`IMAGE_DIR`(数据集目录)和`ANNO_PATH`(TXT文件路径)的相对路径连接起来的图像路径中读取图像。在`config.py`中设置`IMAGE_DIR`和`ANNO_PATH`。
-
-# 快速入门
-
-通过官方网站安装MindSpore后,您可以按照如下步骤进行训练和评估:
-
-```shell script
-# Ascend分布式训练
-bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE]
-```
-
-```shell script
-# 单卡训练
-bash run_standalone_train.sh
-```
-
-```shell script
-# Ascend处理器环境运行eval
-bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
-```
-
-# 脚本说明
-
-## 脚本及样例代码
-
-```text
-.
-└─ cv
- └─ ssd
- ├─ README.md ## SSD相关说明
- ├─ ascend310_infer ## 实现310推理源代码
- ├─ scripts
- ├─ run_distribute_train.sh ## Ascend分布式shell脚本
- ├─ run_infer_310.sh ## Ascend推理shell脚本
- └─ run_eval.sh ## Ascend评估shell脚本
- ├─ src
- ├─ __init__.py ## 初始化文件
- ├─ box_util.py ## bbox工具
- ├─ coco_eval.py ## coco指标工具
- ├─ config.py ## 总配置
- ├─ dataset.py ## 创建并处理数据集
- ├─ init_params.py ## 参数工具
- ├─ lr_schedule.py ## 学习率生成器
- └─ ssd.py ## SSD架构
- ├─ eval.py ## 评估脚本
- ├─ export.py ## 导出 AIR,MINDIR模型的脚本
- ├─ postprogress.py ## 310推理后处理脚本
- ├─ train.py ## 训练脚本
- └─ mindspore_hub_conf.py ## MindSpore Hub接口
-```
-
-## 脚本参数
-
- ```text
- train.py和config.py中主要参数如下:
-
- "device_num": 1 # 使用设备数量
- "lr": 0.05 # 学习率初始值
- "dataset": coco # 数据集名称
- "epoch_size": 500 # 轮次大小
- "batch_size": 32 # 输入张量的批次大小
- "pre_trained": None # 预训练检查点文件路径
- "pre_trained_epoch_size": 0 # 预训练轮次大小
- "save_checkpoint_epochs": 10 # 两个检查点之间的轮次间隔。默认情况下,每10个轮次都会保存检查点。
- "loss_scale": 1024 # 损失放大
-
- "class_num": 81 # 数据集类数
- "image_shape": [300, 300] # 作为模型输入的图像高和宽
- "mindrecord_dir": "/data/MindRecord_COCO" # MindRecord路径
- "coco_root": "/data/coco2017" # COCO2017数据集路径
- "voc_root": "" # VOC原始数据集路径
- "image_dir": "" # 其他数据集图片路径,如果使用coco或voc,此参数无效。
- "anno_path": "" # 其他数据集标注路径,如果使用coco或voc,此参数无效。
-
- ```
-
-## 训练过程
-
-运行`train.py`训练模型。如果`mindrecord_dir`为空,则会通过`coco_root`(coco数据集)或`image_dir`和`anno_path`(自己的数据集)生成[MindRecord](https://www.mindspore.cn/docs/programming_guide/zh-CN/master/convert_dataset.html)文件。**注意,如果mindrecord_dir不为空,将使用mindrecord_dir代替原始图像。**
-
-### Ascend上训练
-
-- 分布式
-
-```shell script
- bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE] [PRE_TRAINED](optional) [PRE_TRAINED_EPOCH_SIZE](optional)
-```
-
-此脚本需要五或七个参数。
-
-- `DEVICE_NUM`:分布式训练的设备数。
-- `EPOCH_NUM`:分布式训练的轮次数。
-- `LR`:分布式训练的学习率初始值。
-- `DATASET`:分布式训练的数据集模式。
-- `RANK_TABLE_FILE`:[rank_table.json](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools)的路径。最好使用绝对路径。
-- `PRE_TRAINED`:预训练检查点文件的路径。最好使用绝对路径。
-- `PRE_TRAINED_EPOCH_SIZE`:预训练的轮次数。
-
- 训练结果保存在当前路径中,文件夹名称以"LOG"开头。 您可在此文件夹中找到检查点文件以及结果,如下所示。
-
-```text
-epoch: 1 step: 458, loss is 3.1681802
-epoch time: 228752.4654865265, per step time: 499.4595316299705
-epoch: 2 step: 458, loss is 2.8847265
-epoch time: 38912.93382644653, per step time: 84.96273761232868
-epoch: 3 step: 458, loss is 2.8398118
-epoch time: 38769.184827804565, per step time: 84.64887516987896
-...
-
-epoch: 498 step: 458, loss is 0.70908034
-epoch time: 38771.079778671265, per step time: 84.65301261718616
-epoch: 499 step: 458, loss is 0.7974688
-epoch time: 38787.413120269775, per step time: 84.68867493508685
-epoch: 500 step: 458, loss is 0.5548882
-epoch time: 39064.8467540741, per step time: 85.29442522723602
-```
-
-## 评估过程
-
-### Ascend处理器环境评估
-
-```shell script
-bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
-```
-
-此脚本需要两个参数。
-
-- `DATASET`:评估数据集的模式。
-- `CHECKPOINT_PATH`:检查点文件的绝对路径。
-- `DEVICE_ID`: 评估的设备ID。
-
-> 在训练过程中可以生成检查点。
-
-推理结果保存在示例路径中,文件夹名称以“eval”开头。您可以在日志中找到类似以下的结果。
-
-```text
-Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
-Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.474
-Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
-Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.120
-Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.350
-Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.315
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.489
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.511
-Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.208
-Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.557
-Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.689
-
-========================================
-
-mAP: 0.32719216721918915
-
-```
-
-## 导出过程
-
-### 导出
-
-```shell
-python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_format[EXPORT_FORMAT]
-```
-
-`EXPORT_FORMAT`可选 ["AIR", "MINDIR"]
-
-## 推理过程
-
-### 推理
-
-在还行推理之前我们需要先导出模型。Air模型只能在昇腾910环境上导出,mindir可以在任意环境上导出。batch_size只支持1。
-
-```shell
-# Ascend310 inference
-bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID]
-```
-
-推理结果被保存到了当前目录,可以在acc.log中获得类似下面的结果。
-
-```shell
-Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
-Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.475
-Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
-Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.115
-Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.353
-Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.455
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.314
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.485
-Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.509
-Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.200
-Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.554
-Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.692
-
-mAP: 0.3266651054070853
-```
-
-### 性能
-
-| 参数 | Ascend |
-| ------------------- | --------------------- |
-| 模型版本 | SSD resnet50 |
-| 资源 | Ascend 910 |
-| 上传日期 | 2021-03-29 |
-| MindSpore版本 | 1.1.0 |
-| 数据集 | COCO2017 |
-| mAP | IoU=0.50: 32.7% |
-| 模型大小 | 281M(.ckpt文件) |
-
-参数ckpt_file为必填项,
-`EXPORT_FORMAT` 必须在 ["AIR", "MINDIR"]中选择。
-
-# 随机情况说明
-
-dataset.py中设置了“create_dataset”函数内的种子,同时还使用了train.py中的随机种子。
-
-# ModelZoo主页
-
- 请浏览官网[主页](https://gitee.com/mindspore/mindspore/tree/master/model_zoo)。
+# 目录
+
+
+
+- [目录](#目录)
+- [SSD说明](#ssd说明)
+- [模型架构](#模型架构)
+- [数据集](#数据集)
+- [环境要求](#环境要求)
+- [快速入门](#快速入门)
+- [脚本说明](#脚本说明)
+ - [脚本及样例代码](#脚本及样例代码)
+ - [脚本参数](#脚本参数)
+ - [训练过程](#训练过程)
+ - [Ascend上训练](#ascend上训练)
+ - [评估过程](#评估过程)
+ - [Ascend处理器环境评估](#ascend处理器环境评估)
+ - [性能](#性能)
+ - [导出过程](#导出过程)
+ - [导出](#导出)
+ - [推理过程](#推理过程)
+ - [推理](#推理)
+- [随机情况说明](#随机情况说明)
+- [ModelZoo主页](#modelzoo主页)
+
+
+
+# SSD说明
+
+SSD将边界框的输出空间离散成一组默认框,每个特征映射位置具有不同的纵横比和尺度。在预测时,网络对每个默认框中存在的对象类别进行评分,并对框进行调整以更好地匹配对象形状。此外,网络将多个不同分辨率的特征映射的预测组合在一起,自然处理各种大小的对象。
+
+[论文](https://arxiv.org/abs/1512.02325): Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.European Conference on Computer Vision (ECCV), 2016 (In press).
+
+# 模型架构
+
+SSD方法基于前向卷积网络,该网络产生固定大小的边界框集合,并针对这些框内存在的对象类实例进行评分,然后通过非极大值抑制步骤进行最终检测。早期的网络层基于高质量图像分类的标准体系结构,被称为基础网络。后来通过向网络添加辅助结构进行检测。
+
+# 数据集
+
+使用的数据集: [COCO2017]()
+
+- 数据集大小:19 GB
+ - 训练集:18 GB,118000张图像
+ - 验证集:1 GB,5000张图像
+ - 标注:241 MB,实例,字幕,person_keypoints等
+- 数据格式:图像和json文件
+ - 注意:数据在dataset.py中处理
+
+# 环境要求
+
+- 安装[MindSpore](https://www.mindspore.cn/install)。
+
+- 下载数据集COCO2017。
+
+- 本示例默认使用COCO2017作为训练数据集,您也可以使用自己的数据集。
+
+ 1. 如果使用coco数据集。**执行脚本时选择数据集coco。**
+ 安装Cython和pycocotool,也可以安装mmcv进行数据处理。
+
+ ```python
+ pip install Cython
+
+ pip install pycocotools
+
+ ```
+
+ 并在`config.py`中更改COCO_ROOT和其他您需要的设置。目录结构如下:
+
+ ```text
+ .
+ └─cocodataset
+ ├─annotations
+ ├─instance_train2017.json
+ └─instance_val2017.json
+ ├─val2017
+ └─train2017
+
+ ```
+
+ 2. 如果使用自己的数据集。**执行脚本时选择数据集为other。**
+ 将数据集信息整理成TXT文件,每行如下:
+
+ ```text
+ train2017/0000001.jpg 0,259,401,459,7 35,28,324,201,2 0,30,59,80,2
+
+ ```
+
+ 每行是按空间分割的图像标注,第一列是图像的相对路径,其余为[xmin,ymin,xmax,ymax,class]格式的框和类信息。我们从`IMAGE_DIR`(数据集目录)和`ANNO_PATH`(TXT文件路径)的相对路径连接起来的图像路径中读取图像。在`config.py`中设置`IMAGE_DIR`和`ANNO_PATH`。
+
+# 快速入门
+
+通过官方网站安装MindSpore后,您可以按照如下步骤进行训练和评估:
+
+```shell script
+# Ascend分布式训练
+bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE]
+```
+
+```shell script
+# 单卡训练
+bash run_standalone_train.sh
+```
+
+```shell script
+# Ascend处理器环境运行eval
+bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
+```
+
+# 脚本说明
+
+## 脚本及样例代码
+
+```text
+.
+└─ cv
+ └─ ssd
+ ├─ README.md ## SSD相关说明
+ ├─ ascend310_infer ## 实现310推理源代码
+ ├─ scripts
+ ├─ run_distribute_train.sh ## Ascend分布式shell脚本
+ ├─ run_infer_310.sh ## Ascend推理shell脚本
+ └─ run_eval.sh ## Ascend评估shell脚本
+ ├─ src
+ ├─ __init__.py ## 初始化文件
+ ├─ box_util.py ## bbox工具
+ ├─ coco_eval.py ## coco指标工具
+ ├─ config.py ## 总配置
+ ├─ dataset.py ## 创建并处理数据集
+ ├─ init_params.py ## 参数工具
+ ├─ lr_schedule.py ## 学习率生成器
+ └─ ssd.py ## SSD架构
+ ├─ eval.py ## 评估脚本
+ ├─ export.py ## 导出 AIR,MINDIR模型的脚本
+ ├─ postprogress.py ## 310推理后处理脚本
+ ├─ train.py ## 训练脚本
+ └─ mindspore_hub_conf.py ## MindSpore Hub接口
+```
+
+## 脚本参数
+
+ ```text
+ train.py和config.py中主要参数如下:
+
+ "device_num": 1 # 使用设备数量
+ "lr": 0.05 # 学习率初始值
+ "dataset": coco # 数据集名称
+ "epoch_size": 500 # 轮次大小
+ "batch_size": 32 # 输入张量的批次大小
+ "pre_trained": None # 预训练检查点文件路径
+ "pre_trained_epoch_size": 0 # 预训练轮次大小
+ "save_checkpoint_epochs": 10 # 两个检查点之间的轮次间隔。默认情况下,每10个轮次都会保存检查点。
+ "loss_scale": 1024 # 损失放大
+
+ "class_num": 81 # 数据集类数
+ "image_shape": [300, 300] # 作为模型输入的图像高和宽
+ "mindrecord_dir": "/data/MindRecord_COCO" # MindRecord路径
+ "coco_root": "/data/coco2017" # COCO2017数据集路径
+ "voc_root": "" # VOC原始数据集路径
+ "image_dir": "" # 其他数据集图片路径,如果使用coco或voc,此参数无效。
+ "anno_path": "" # 其他数据集标注路径,如果使用coco或voc,此参数无效。
+
+ ```
+
+## 训练过程
+
+运行`train.py`训练模型。如果`mindrecord_dir`为空,则会通过`coco_root`(coco数据集)或`image_dir`和`anno_path`(自己的数据集)生成[MindRecord](https://www.mindspore.cn/docs/programming_guide/zh-CN/master/convert_dataset.html)文件。**注意,如果mindrecord_dir不为空,将使用mindrecord_dir代替原始图像。**
+
+### Ascend上训练
+
+- 分布式
+
+```shell script
+ bash run_distribute_train.sh [DEVICE_NUM] [EPOCH_SIZE] [LR] [DATASET] [RANK_TABLE_FILE] [PRE_TRAINED](optional) [PRE_TRAINED_EPOCH_SIZE](optional)
+```
+
+此脚本需要五或七个参数。
+
+- `DEVICE_NUM`:分布式训练的设备数。
+- `EPOCH_NUM`:分布式训练的轮次数。
+- `LR`:分布式训练的学习率初始值。
+- `DATASET`:分布式训练的数据集模式。
+- `RANK_TABLE_FILE`:[rank_table.json](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools)的路径。最好使用绝对路径。
+- `PRE_TRAINED`:预训练检查点文件的路径。最好使用绝对路径。
+- `PRE_TRAINED_EPOCH_SIZE`:预训练的轮次数。
+
+ 训练结果保存在当前路径中,文件夹名称以"LOG"开头。 您可在此文件夹中找到检查点文件以及结果,如下所示。
+
+```text
+epoch: 1 step: 458, loss is 3.1681802
+epoch time: 228752.4654865265, per step time: 499.4595316299705
+epoch: 2 step: 458, loss is 2.8847265
+epoch time: 38912.93382644653, per step time: 84.96273761232868
+epoch: 3 step: 458, loss is 2.8398118
+epoch time: 38769.184827804565, per step time: 84.64887516987896
+...
+
+epoch: 498 step: 458, loss is 0.70908034
+epoch time: 38771.079778671265, per step time: 84.65301261718616
+epoch: 499 step: 458, loss is 0.7974688
+epoch time: 38787.413120269775, per step time: 84.68867493508685
+epoch: 500 step: 458, loss is 0.5548882
+epoch time: 39064.8467540741, per step time: 85.29442522723602
+```
+
+## 评估过程
+
+### Ascend处理器环境评估
+
+```shell script
+bash run_eval.sh [DATASET] [CHECKPOINT_PATH] [DEVICE_ID]
+```
+
+此脚本需要两个参数。
+
+- `DATASET`:评估数据集的模式。
+- `CHECKPOINT_PATH`:检查点文件的绝对路径。
+- `DEVICE_ID`: 评估的设备ID。
+
+> 在训练过程中可以生成检查点。
+
+推理结果保存在示例路径中,文件夹名称以“eval”开头。您可以在日志中找到类似以下的结果。
+
+```text
+Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
+Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.474
+Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
+Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.120
+Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.350
+Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.315
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.489
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.511
+Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.208
+Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.557
+Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.689
+
+========================================
+
+mAP: 0.32719216721918915
+
+```
+
+## 导出过程
+
+### 导出
+
+```shell
+python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_format[EXPORT_FORMAT]
+```
+
+`EXPORT_FORMAT`可选 ["AIR", "MINDIR"]
+
+## 推理过程
+
+### 推理
+
+在还行推理之前我们需要先导出模型。Air模型只能在昇腾910环境上导出,mindir可以在任意环境上导出。batch_size只支持1。
+
+```shell
+# Ascend310 inference
+bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID]
+```
+
+推理结果被保存到了当前目录,可以在acc.log中获得类似下面的结果。
+
+```shell
+Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327
+Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.475
+Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.358
+Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.115
+Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.353
+Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.455
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.314
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.485
+Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.509
+Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.200
+Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.554
+Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.692
+
+mAP: 0.3266651054070853
+```
+
+### 性能
+
+| 参数 | Ascend |
+| ------------------- | --------------------- |
+| 模型版本 | SSD resnet50 |
+| 资源 | Ascend 910 |
+| 上传日期 | 2021-03-29 |
+| MindSpore版本 | 1.1.0 |
+| 数据集 | COCO2017 |
+| mAP | IoU=0.50: 32.7% |
+| 模型大小 | 281M(.ckpt文件) |
+
+参数ckpt_file为必填项,
+`EXPORT_FORMAT` 必须在 ["AIR", "MINDIR"]中选择。
+
+# 随机情况说明
+
+dataset.py中设置了“create_dataset”函数内的种子,同时还使用了train.py中的随机种子。
+
+# ModelZoo主页
+
+ 请浏览官网[主页](https://gitee.com/mindspore/mindspore/tree/master/model_zoo)。
diff --git a/research/cv/ssd_resnet50/ascend310_infer/CMakeLists.txt b/research/cv/ssd_resnet50/ascend310_infer/CMakeLists.txt
index ee3c85447340e0449ff2b70ed24f60a17e07b2b6..5da775f3746b97dae4573ee089b4db4414591bec 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/CMakeLists.txt
+++ b/research/cv/ssd_resnet50/ascend310_infer/CMakeLists.txt
@@ -1,14 +1,14 @@
-cmake_minimum_required(VERSION 3.14.1)
-project(Ascend310Infer)
-add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -std=c++17 -Werror -Wall -fPIE -Wl,--allow-shlib-undefined")
-set(PROJECT_SRC_ROOT ${CMAKE_CURRENT_LIST_DIR}/)
-option(MINDSPORE_PATH "mindspore install path" "")
-include_directories(${MINDSPORE_PATH})
-include_directories(${MINDSPORE_PATH}/include)
-include_directories(${PROJECT_SRC_ROOT})
-find_library(MS_LIB libmindspore.so ${MINDSPORE_PATH}/lib)
-file(GLOB_RECURSE MD_LIB ${MINDSPORE_PATH}/_c_dataengine*)
-
-add_executable(main src/main.cc src/utils.cc)
-target_link_libraries(main ${MS_LIB} ${MD_LIB} gflags)
+cmake_minimum_required(VERSION 3.14.1)
+project(Ascend310Infer)
+add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -std=c++17 -Werror -Wall -fPIE -Wl,--allow-shlib-undefined")
+set(PROJECT_SRC_ROOT ${CMAKE_CURRENT_LIST_DIR}/)
+option(MINDSPORE_PATH "mindspore install path" "")
+include_directories(${MINDSPORE_PATH})
+include_directories(${MINDSPORE_PATH}/include)
+include_directories(${PROJECT_SRC_ROOT})
+find_library(MS_LIB libmindspore.so ${MINDSPORE_PATH}/lib)
+file(GLOB_RECURSE MD_LIB ${MINDSPORE_PATH}/_c_dataengine*)
+
+add_executable(main src/main.cc src/utils.cc)
+target_link_libraries(main ${MS_LIB} ${MD_LIB} gflags)
diff --git a/research/cv/ssd_resnet50/ascend310_infer/aipp.cfg b/research/cv/ssd_resnet50/ascend310_infer/aipp.cfg
index 363d5d36fd1f24e3a6e880745d7150076f777bd0..83acabb343e82acc95877b0fbe5445b90cb47104 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/aipp.cfg
+++ b/research/cv/ssd_resnet50/ascend310_infer/aipp.cfg
@@ -1,26 +1,26 @@
-aipp_op {
- aipp_mode : static
- input_format : YUV420SP_U8
- related_input_rank : 0
- csc_switch : true
- rbuv_swap_switch : false
- matrix_r0c0 : 256
- matrix_r0c1 : 0
- matrix_r0c2 : 359
- matrix_r1c0 : 256
- matrix_r1c1 : -88
- matrix_r1c2 : -183
- matrix_r2c0 : 256
- matrix_r2c1 : 454
- matrix_r2c2 : 0
- input_bias_0 : 0
- input_bias_1 : 128
- input_bias_2 : 128
-
- mean_chn_0 : 124
- mean_chn_1 : 117
- mean_chn_2 : 104
- var_reci_chn_0 : 0.0171247538316637
- var_reci_chn_1 : 0.0175070028011204
- var_reci_chn_2 : 0.0174291938997821
+aipp_op {
+ aipp_mode : static
+ input_format : YUV420SP_U8
+ related_input_rank : 0
+ csc_switch : true
+ rbuv_swap_switch : false
+ matrix_r0c0 : 256
+ matrix_r0c1 : 0
+ matrix_r0c2 : 359
+ matrix_r1c0 : 256
+ matrix_r1c1 : -88
+ matrix_r1c2 : -183
+ matrix_r2c0 : 256
+ matrix_r2c1 : 454
+ matrix_r2c2 : 0
+ input_bias_0 : 0
+ input_bias_1 : 128
+ input_bias_2 : 128
+
+ mean_chn_0 : 124
+ mean_chn_1 : 117
+ mean_chn_2 : 104
+ var_reci_chn_0 : 0.0171247538316637
+ var_reci_chn_1 : 0.0175070028011204
+ var_reci_chn_2 : 0.0174291938997821
}
\ No newline at end of file
diff --git a/research/cv/ssd_resnet50/ascend310_infer/build.sh b/research/cv/ssd_resnet50/ascend310_infer/build.sh
index 68255919420d6270a91677f9052af77434187068..5382250c235ce8904c29c303a07e4a724588f43d 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/build.sh
+++ b/research/cv/ssd_resnet50/ascend310_infer/build.sh
@@ -1,28 +1,28 @@
-#!/bin/bash
-# Copyright 2021 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.
-# ============================================================================
-if [ ! -d out ]; then
- mkdir out
-fi
-
-cd out
-
-if [ -f "Makefile" ]; then
- make clean
-fi
-
-cmake .. \
- -DMINDSPORE_PATH="`pip3.7 show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`"
-make
+#!/bin/bash
+# Copyright 2021 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.
+# ============================================================================
+if [ ! -d out ]; then
+ mkdir out
+fi
+
+cd out
+
+if [ -f "Makefile" ]; then
+ make clean
+fi
+
+cmake .. \
+ -DMINDSPORE_PATH="`pip3.7 show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`"
+make
diff --git a/research/cv/ssd_resnet50/ascend310_infer/inc/utils.h b/research/cv/ssd_resnet50/ascend310_infer/inc/utils.h
index efebe03a8c1179f5a1f9d5f7ee07e0352a9937c6..6d66b313019614e146c5dc8d15a906ac170e8648 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/inc/utils.h
+++ b/research/cv/ssd_resnet50/ascend310_infer/inc/utils.h
@@ -1,32 +1,32 @@
-/**
- * Copyright 2021 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.
- */
-
-#ifndef MINDSPORE_INFERENCE_UTILS_H_
-#define MINDSPORE_INFERENCE_UTILS_H_
-
-#include
-#include
-#include
-#include
-#include
-#include "include/api/types.h"
-
-std::vector GetAllFiles(std::string_view dirName);
-DIR *OpenDir(std::string_view dirName);
-std::string RealPath(std::string_view path);
-mindspore::MSTensor ReadFileToTensor(const std::string &file);
-int WriteResult(const std::string& imageFile, const std::vector &outputs);
-#endif
+/**
+ * Copyright 2021 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.
+ */
+
+#ifndef MINDSPORE_INFERENCE_UTILS_H_
+#define MINDSPORE_INFERENCE_UTILS_H_
+
+#include
+#include
+#include
+#include
+#include
+#include "include/api/types.h"
+
+std::vector GetAllFiles(std::string_view dirName);
+DIR *OpenDir(std::string_view dirName);
+std::string RealPath(std::string_view path);
+mindspore::MSTensor ReadFileToTensor(const std::string &file);
+int WriteResult(const std::string& imageFile, const std::vector &outputs);
+#endif
diff --git a/research/cv/ssd_resnet50/ascend310_infer/src/main.cc b/research/cv/ssd_resnet50/ascend310_infer/src/main.cc
index 4b92f1a0719d29ed69e4d015a40025dd727d3416..f38cf71f57ebef706f0b13ad35776c2ede28ea2c 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/src/main.cc
+++ b/research/cv/ssd_resnet50/ascend310_infer/src/main.cc
@@ -1,165 +1,165 @@
-/**
- * Copyright 2021 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.
- */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "include/api/model.h"
-#include "include/api/context.h"
-#include "include/api/types.h"
-#include "include/api/serialization.h"
-#include "include/dataset/vision_ascend.h"
-#include "include/dataset/execute.h"
-#include "include/dataset/vision.h"
-#include "inc/utils.h"
-
-using mindspore::Context;
-using mindspore::Serialization;
-using mindspore::Model;
-using mindspore::Status;
-using mindspore::ModelType;
-using mindspore::GraphCell;
-using mindspore::kSuccess;
-using mindspore::MSTensor;
-using mindspore::dataset::Execute;
-using mindspore::dataset::TensorTransform;
-using mindspore::dataset::vision::DvppDecodeResizeJpeg;
-using mindspore::dataset::vision::Resize;
-using mindspore::dataset::vision::HWC2CHW;
-using mindspore::dataset::vision::Normalize;
-using mindspore::dataset::vision::Decode;
-
-DEFINE_string(mindir_path, "", "mindir path");
-DEFINE_string(dataset_path, ".", "dataset path");
-DEFINE_int32(device_id, 0, "device id");
-DEFINE_string(aipp_path, "./aipp.cfg", "aipp path");
-DEFINE_string(cpu_dvpp, "DVPP", "cpu or dvpp process");
-DEFINE_int32(image_height, 640, "image height");
-DEFINE_int32(image_width, 640, "image width");
-
-int main(int argc, char **argv) {
- gflags::ParseCommandLineFlags(&argc, &argv, true);
- if (RealPath(FLAGS_mindir_path).empty()) {
- std::cout << "Invalid mindir" << std::endl;
- return 1;
- }
-
- auto context = std::make_shared();
- auto ascend310 = std::make_shared();
- ascend310->SetDeviceID(FLAGS_device_id);
- ascend310->SetBufferOptimizeMode("off_optimize");
- context->MutableDeviceInfo().push_back(ascend310);
- mindspore::Graph graph;
- Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph);
- if (FLAGS_cpu_dvpp == "DVPP") {
- if (RealPath(FLAGS_aipp_path).empty()) {
- std::cout << "Invalid aipp path" << std::endl;
- return 1;
- } else {
- ascend310->SetInsertOpConfigPath(FLAGS_aipp_path);
- }
- }
-
- Model model;
- Status ret = model.Build(GraphCell(graph), context);
- if (ret != kSuccess) {
- std::cout << "ERROR: Build failed." << std::endl;
- return 1;
- }
-
- auto all_files = GetAllFiles(FLAGS_dataset_path);
- if (all_files.empty()) {
- std::cout << "ERROR: no input data." << std::endl;
- return 1;
- }
-
- std::map costTime_map;
- size_t size = all_files.size();
-
- for (size_t i = 0; i < size; ++i) {
- struct timeval start = {0};
- struct timeval end = {0};
- double startTimeMs;
- double endTimeMs;
- std::vector inputs;
- std::vector outputs;
- std::cout << "Start predict input files:" << all_files[i] << std::endl;
- if (FLAGS_cpu_dvpp == "DVPP") {
- auto resizeShape = {static_cast (FLAGS_image_height), static_cast (FLAGS_image_width)};
- Execute resize_op(std::shared_ptr(new DvppDecodeResizeJpeg(resizeShape)));
- auto imgDvpp = std::make_shared();
- resize_op(ReadFileToTensor(all_files[i]), imgDvpp.get());
- inputs.emplace_back(imgDvpp->Name(), imgDvpp->DataType(), imgDvpp->Shape(),
- imgDvpp->Data().get(), imgDvpp->DataSize());
- } else {
- std::shared_ptr decode(new Decode());
- std::shared_ptr hwc2chw(new HWC2CHW());
- std::shared_ptr normalize(
- new Normalize({123.675, 116.28, 103.53}, {58.395, 57.120, 57.375}));
- auto resizeShape = {FLAGS_image_height, FLAGS_image_width};
- std::shared_ptr resize(new Resize(resizeShape));
- Execute composeDecode({decode, resize, normalize, hwc2chw});
- auto img = MSTensor();
- auto image = ReadFileToTensor(all_files[i]);
- composeDecode(image, &img);
- std::vector model_inputs = model.GetInputs();
- if (model_inputs.empty()) {
- std::cout << "Invalid model, inputs is empty." << std::endl;
- return 1;
- }
- inputs.emplace_back(model_inputs[0].Name(), model_inputs[0].DataType(), model_inputs[0].Shape(),
- img.Data().get(), img.DataSize());
- }
-
- gettimeofday(&start, nullptr);
- ret = model.Predict(inputs, &outputs);
- gettimeofday(&end, nullptr);
- if (ret != kSuccess) {
- std::cout << "Predict " << all_files[i] << " failed." << std::endl;
- return 1;
- }
- startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
- endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
- costTime_map.insert(std::pair(startTimeMs, endTimeMs));
- WriteResult(all_files[i], outputs);
- }
- double average = 0.0;
- int inferCount = 0;
-
- for (auto iter = costTime_map.begin(); iter != costTime_map.end(); iter++) {
- double diff = 0.0;
- diff = iter->second - iter->first;
- average += diff;
- inferCount++;
- }
- average = average / inferCount;
- std::stringstream timeCost;
- timeCost << "NN inference cost average time: "<< average << " ms of infer_count " << inferCount << std::endl;
- std::cout << "NN inference cost average time: "<< average << "ms of infer_count " << inferCount << std::endl;
- std::string fileName = "./time_Result" + std::string("/test_perform_static.txt");
- std::ofstream fileStream(fileName.c_str(), std::ios::trunc);
- fileStream << timeCost.str();
- fileStream.close();
- costTime_map.clear();
- return 0;
-}
+/**
+ * Copyright 2021 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.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "include/api/model.h"
+#include "include/api/context.h"
+#include "include/api/types.h"
+#include "include/api/serialization.h"
+#include "include/dataset/vision_ascend.h"
+#include "include/dataset/execute.h"
+#include "include/dataset/vision.h"
+#include "inc/utils.h"
+
+using mindspore::Context;
+using mindspore::Serialization;
+using mindspore::Model;
+using mindspore::Status;
+using mindspore::ModelType;
+using mindspore::GraphCell;
+using mindspore::kSuccess;
+using mindspore::MSTensor;
+using mindspore::dataset::Execute;
+using mindspore::dataset::TensorTransform;
+using mindspore::dataset::vision::DvppDecodeResizeJpeg;
+using mindspore::dataset::vision::Resize;
+using mindspore::dataset::vision::HWC2CHW;
+using mindspore::dataset::vision::Normalize;
+using mindspore::dataset::vision::Decode;
+
+DEFINE_string(mindir_path, "", "mindir path");
+DEFINE_string(dataset_path, ".", "dataset path");
+DEFINE_int32(device_id, 0, "device id");
+DEFINE_string(aipp_path, "./aipp.cfg", "aipp path");
+DEFINE_string(cpu_dvpp, "DVPP", "cpu or dvpp process");
+DEFINE_int32(image_height, 640, "image height");
+DEFINE_int32(image_width, 640, "image width");
+
+int main(int argc, char **argv) {
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
+ if (RealPath(FLAGS_mindir_path).empty()) {
+ std::cout << "Invalid mindir" << std::endl;
+ return 1;
+ }
+
+ auto context = std::make_shared();
+ auto ascend310 = std::make_shared();
+ ascend310->SetDeviceID(FLAGS_device_id);
+ ascend310->SetBufferOptimizeMode("off_optimize");
+ context->MutableDeviceInfo().push_back(ascend310);
+ mindspore::Graph graph;
+ Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph);
+ if (FLAGS_cpu_dvpp == "DVPP") {
+ if (RealPath(FLAGS_aipp_path).empty()) {
+ std::cout << "Invalid aipp path" << std::endl;
+ return 1;
+ } else {
+ ascend310->SetInsertOpConfigPath(FLAGS_aipp_path);
+ }
+ }
+
+ Model model;
+ Status ret = model.Build(GraphCell(graph), context);
+ if (ret != kSuccess) {
+ std::cout << "ERROR: Build failed." << std::endl;
+ return 1;
+ }
+
+ auto all_files = GetAllFiles(FLAGS_dataset_path);
+ if (all_files.empty()) {
+ std::cout << "ERROR: no input data." << std::endl;
+ return 1;
+ }
+
+ std::map costTime_map;
+ size_t size = all_files.size();
+
+ for (size_t i = 0; i < size; ++i) {
+ struct timeval start = {0};
+ struct timeval end = {0};
+ double startTimeMs;
+ double endTimeMs;
+ std::vector inputs;
+ std::vector outputs;
+ std::cout << "Start predict input files:" << all_files[i] << std::endl;
+ if (FLAGS_cpu_dvpp == "DVPP") {
+ auto resizeShape = {static_cast (FLAGS_image_height), static_cast (FLAGS_image_width)};
+ Execute resize_op(std::shared_ptr(new DvppDecodeResizeJpeg(resizeShape)));
+ auto imgDvpp = std::make_shared();
+ resize_op(ReadFileToTensor(all_files[i]), imgDvpp.get());
+ inputs.emplace_back(imgDvpp->Name(), imgDvpp->DataType(), imgDvpp->Shape(),
+ imgDvpp->Data().get(), imgDvpp->DataSize());
+ } else {
+ std::shared_ptr decode(new Decode());
+ std::shared_ptr hwc2chw(new HWC2CHW());
+ std::shared_ptr normalize(
+ new Normalize({123.675, 116.28, 103.53}, {58.395, 57.120, 57.375}));
+ auto resizeShape = {FLAGS_image_height, FLAGS_image_width};
+ std::shared_ptr resize(new Resize(resizeShape));
+ Execute composeDecode({decode, resize, normalize, hwc2chw});
+ auto img = MSTensor();
+ auto image = ReadFileToTensor(all_files[i]);
+ composeDecode(image, &img);
+ std::vector model_inputs = model.GetInputs();
+ if (model_inputs.empty()) {
+ std::cout << "Invalid model, inputs is empty." << std::endl;
+ return 1;
+ }
+ inputs.emplace_back(model_inputs[0].Name(), model_inputs[0].DataType(), model_inputs[0].Shape(),
+ img.Data().get(), img.DataSize());
+ }
+
+ gettimeofday(&start, nullptr);
+ ret = model.Predict(inputs, &outputs);
+ gettimeofday(&end, nullptr);
+ if (ret != kSuccess) {
+ std::cout << "Predict " << all_files[i] << " failed." << std::endl;
+ return 1;
+ }
+ startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
+ endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
+ costTime_map.insert(std::pair(startTimeMs, endTimeMs));
+ WriteResult(all_files[i], outputs);
+ }
+ double average = 0.0;
+ int inferCount = 0;
+
+ for (auto iter = costTime_map.begin(); iter != costTime_map.end(); iter++) {
+ double diff = 0.0;
+ diff = iter->second - iter->first;
+ average += diff;
+ inferCount++;
+ }
+ average = average / inferCount;
+ std::stringstream timeCost;
+ timeCost << "NN inference cost average time: "<< average << " ms of infer_count " << inferCount << std::endl;
+ std::cout << "NN inference cost average time: "<< average << "ms of infer_count " << inferCount << std::endl;
+ std::string fileName = "./time_Result" + std::string("/test_perform_static.txt");
+ std::ofstream fileStream(fileName.c_str(), std::ios::trunc);
+ fileStream << timeCost.str();
+ fileStream.close();
+ costTime_map.clear();
+ return 0;
+}
diff --git a/research/cv/ssd_resnet50/ascend310_infer/src/utils.cc b/research/cv/ssd_resnet50/ascend310_infer/src/utils.cc
index c947e4d5f451b90bd4728aa3a92c4cfab174f5e6..5987daee43935da835a01872487fdcb2049405c4 100644
--- a/research/cv/ssd_resnet50/ascend310_infer/src/utils.cc
+++ b/research/cv/ssd_resnet50/ascend310_infer/src/utils.cc
@@ -1,129 +1,129 @@
-/**
- * Copyright 2021 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.
- */
-
-#include
-#include
-#include
-#include "inc/utils.h"
-
-using mindspore::MSTensor;
-using mindspore::DataType;
-
-std::vector GetAllFiles(std::string_view dirName) {
- struct dirent *filename;
- DIR *dir = OpenDir(dirName);
- if (dir == nullptr) {
- return {};
- }
- std::vector res;
- while ((filename = readdir(dir)) != nullptr) {
- std::string dName = std::string(filename->d_name);
- if (dName == "." || dName == ".." || filename->d_type != DT_REG) {
- continue;
- }
- res.emplace_back(std::string(dirName) + "/" + filename->d_name);
- }
- std::sort(res.begin(), res.end());
- for (auto &f : res) {
- std::cout << "image file: " << f << std::endl;
- }
- return res;
-}
-
-int WriteResult(const std::string& imageFile, const std::vector &outputs) {
- std::string homePath = "./result_Files";
- for (size_t i = 0; i < outputs.size(); ++i) {
- size_t outputSize;
- std::shared_ptr netOutput;
- netOutput = outputs[i].Data();
- outputSize = outputs[i].DataSize();
- int pos = imageFile.rfind('/');
- std::string fileName(imageFile, pos + 1);
- fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
- std::string outFileName = homePath + "/" + fileName;
- FILE * outputFile = fopen(outFileName.c_str(), "wb");
- fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
- fclose(outputFile);
- outputFile = nullptr;
- }
- return 0;
-}
-
-mindspore::MSTensor ReadFileToTensor(const std::string &file) {
- if (file.empty()) {
- std::cout << "Pointer file is nullptr" << std::endl;
- return mindspore::MSTensor();
- }
-
- std::ifstream ifs(file);
- if (!ifs.good()) {
- std::cout << "File: " << file << " is not exist" << std::endl;
- return mindspore::MSTensor();
- }
-
- if (!ifs.is_open()) {
- std::cout << "File: " << file << "open failed" << std::endl;
- return mindspore::MSTensor();
- }
-
- ifs.seekg(0, std::ios::end);
- size_t size = ifs.tellg();
- mindspore::MSTensor buffer(file, mindspore::DataType::kNumberTypeUInt8, {static_cast(size)}, nullptr, size);
-
- ifs.seekg(0, std::ios::beg);
- ifs.read(reinterpret_cast(buffer.MutableData()), size);
- ifs.close();
-
- return buffer;
-}
-
-
-DIR *OpenDir(std::string_view dirName) {
- if (dirName.empty()) {
- std::cout << " dirName is null ! " << std::endl;
- return nullptr;
- }
- std::string realPath = RealPath(dirName);
- struct stat s;
- lstat(realPath.c_str(), &s);
- if (!S_ISDIR(s.st_mode)) {
- std::cout << "dirName is not a valid directory !" << std::endl;
- return nullptr;
- }
- DIR *dir;
- dir = opendir(realPath.c_str());
- if (dir == nullptr) {
- std::cout << "Can not open dir " << dirName << std::endl;
- return nullptr;
- }
- std::cout << "Successfully opened the dir " << dirName << std::endl;
- return dir;
-}
-
-std::string RealPath(std::string_view path) {
- char realPathMem[PATH_MAX] = {0};
- char *realPathRet = nullptr;
- realPathRet = realpath(path.data(), realPathMem);
-
- if (realPathRet == nullptr) {
- std::cout << "File: " << path << " is not exist.";
- return "";
- }
-
- std::string realPath(realPathMem);
- std::cout << path << " realpath is: " << realPath << std::endl;
- return realPath;
-}
+/**
+ * Copyright 2021 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.
+ */
+
+#include
+#include
+#include
+#include "inc/utils.h"
+
+using mindspore::MSTensor;
+using mindspore::DataType;
+
+std::vector GetAllFiles(std::string_view dirName) {
+ struct dirent *filename;
+ DIR *dir = OpenDir(dirName);
+ if (dir == nullptr) {
+ return {};
+ }
+ std::vector res;
+ while ((filename = readdir(dir)) != nullptr) {
+ std::string dName = std::string(filename->d_name);
+ if (dName == "." || dName == ".." || filename->d_type != DT_REG) {
+ continue;
+ }
+ res.emplace_back(std::string(dirName) + "/" + filename->d_name);
+ }
+ std::sort(res.begin(), res.end());
+ for (auto &f : res) {
+ std::cout << "image file: " << f << std::endl;
+ }
+ return res;
+}
+
+int WriteResult(const std::string& imageFile, const std::vector &outputs) {
+ std::string homePath = "./result_Files";
+ for (size_t i = 0; i < outputs.size(); ++i) {
+ size_t outputSize;
+ std::shared_ptr netOutput;
+ netOutput = outputs[i].Data();
+ outputSize = outputs[i].DataSize();
+ int pos = imageFile.rfind('/');
+ std::string fileName(imageFile, pos + 1);
+ fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
+ std::string outFileName = homePath + "/" + fileName;
+ FILE * outputFile = fopen(outFileName.c_str(), "wb");
+ fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
+ fclose(outputFile);
+ outputFile = nullptr;
+ }
+ return 0;
+}
+
+mindspore::MSTensor ReadFileToTensor(const std::string &file) {
+ if (file.empty()) {
+ std::cout << "Pointer file is nullptr" << std::endl;
+ return mindspore::MSTensor();
+ }
+
+ std::ifstream ifs(file);
+ if (!ifs.good()) {
+ std::cout << "File: " << file << " is not exist" << std::endl;
+ return mindspore::MSTensor();
+ }
+
+ if (!ifs.is_open()) {
+ std::cout << "File: " << file << "open failed" << std::endl;
+ return mindspore::MSTensor();
+ }
+
+ ifs.seekg(0, std::ios::end);
+ size_t size = ifs.tellg();
+ mindspore::MSTensor buffer(file, mindspore::DataType::kNumberTypeUInt8, {static_cast(size)}, nullptr, size);
+
+ ifs.seekg(0, std::ios::beg);
+ ifs.read(reinterpret_cast(buffer.MutableData()), size);
+ ifs.close();
+
+ return buffer;
+}
+
+
+DIR *OpenDir(std::string_view dirName) {
+ if (dirName.empty()) {
+ std::cout << " dirName is null ! " << std::endl;
+ return nullptr;
+ }
+ std::string realPath = RealPath(dirName);
+ struct stat s;
+ lstat(realPath.c_str(), &s);
+ if (!S_ISDIR(s.st_mode)) {
+ std::cout << "dirName is not a valid directory !" << std::endl;
+ return nullptr;
+ }
+ DIR *dir;
+ dir = opendir(realPath.c_str());
+ if (dir == nullptr) {
+ std::cout << "Can not open dir " << dirName << std::endl;
+ return nullptr;
+ }
+ std::cout << "Successfully opened the dir " << dirName << std::endl;
+ return dir;
+}
+
+std::string RealPath(std::string_view path) {
+ char realPathMem[PATH_MAX] = {0};
+ char *realPathRet = nullptr;
+ realPathRet = realpath(path.data(), realPathMem);
+
+ if (realPathRet == nullptr) {
+ std::cout << "File: " << path << " is not exist.";
+ return "";
+ }
+
+ std::string realPath(realPathMem);
+ std::cout << path << " realpath is: " << realPath << std::endl;
+ return realPath;
+}
diff --git a/research/cv/ssd_resnet50/eval.py b/research/cv/ssd_resnet50/eval.py
index 830398b2ab7ba3eebf5ea5cf32a36a587363c3a8..a3e9fede3ac16300a32b45eb5394c321066a4238 100644
--- a/research/cv/ssd_resnet50/eval.py
+++ b/research/cv/ssd_resnet50/eval.py
@@ -1,98 +1,98 @@
-# Copyright 2021 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.
-# ============================================================================
-
-"""Evaluation for SSD"""
-
-import os
-import argparse
-import time
-import numpy as np
-from mindspore import context, Tensor
-from mindspore.train.serialization import load_checkpoint, load_param_into_net
-from src.ssd import SsdInferWithDecoder, ssd_resnet50
-from src.dataset import create_ssd_dataset, create_mindrecord
-from src.config import config
-from src.eval_utils import metrics
-from src.box_utils import default_boxes
-
-def ssd_eval(dataset_path, ckpt_path, anno_json):
- """SSD evaluation."""
- batch_size = 1
- ds = create_ssd_dataset(dataset_path, batch_size=batch_size, repeat_num=1,
- is_training=False, use_multiprocessing=False)
- if config.model == "ssd_resnet50":
- net = ssd_resnet50(config=config)
- else:
- raise ValueError(f'config.model: {config.model} is not supported')
- net = SsdInferWithDecoder(net, Tensor(default_boxes), config)
-
- print("Load Checkpoint!")
- param_dict = load_checkpoint(ckpt_path)
- net.init_parameters_data()
- load_param_into_net(net, param_dict)
-
- net.set_train(False)
- i = batch_size
- total = ds.get_dataset_size() * batch_size
- start = time.time()
- pred_data = []
- print("\n========================================\n")
- print("total images num: ", total)
- print("Processing, please wait a moment.")
- for data in ds.create_dict_iterator(output_numpy=True, num_epochs=1):
- img_id = data['img_id']
- img_np = data['image']
- image_shape = data['image_shape']
-
- output = net(Tensor(img_np))
- for batch_idx in range(img_np.shape[0]):
- pred_data.append({"boxes": output[0].asnumpy()[batch_idx],
- "box_scores": output[1].asnumpy()[batch_idx],
- "img_id": int(np.squeeze(img_id[batch_idx])),
- "image_shape": image_shape[batch_idx]})
- percent = round(i / total * 100., 2)
-
- print(f' {str(percent)} [{i}/{total}]', end='\r')
- i += batch_size
- cost_time = int((time.time() - start) * 1000)
- print(f' 100% [{total}/{total}] cost {cost_time} ms')
- mAP = metrics(pred_data, anno_json)
- print("\n========================================\n")
- print(f"mAP: {mAP}")
-
-def get_eval_args():
- parser = argparse.ArgumentParser(description='SSD evaluation')
- parser.add_argument("--device_id", type=int, default=0, help="Device id, default is 0.")
- parser.add_argument("--dataset", type=str, default="coco", help="Dataset, default is coco.")
- parser.add_argument("--checkpoint_path", type=str, required=True, help="Checkpoint file path.")
- parser.add_argument("--run_platform", type=str, default="Ascend", choices=("Ascend", "GPU", "CPU"),
- help="run platform, support Ascend ,GPU and CPU.")
- return parser.parse_args()
-
-if __name__ == '__main__':
- args_opt = get_eval_args()
- if args_opt.dataset == "coco":
- json_path = os.path.join(config.coco_root, config.instances_set.format(config.val_data_type))
- elif args_opt.dataset == "voc":
- json_path = os.path.join(config.voc_root, config.voc_json)
- else:
- raise ValueError('SSD eval only support dataset mode is coco and voc!')
-
- context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.run_platform, device_id=args_opt.device_id)
-
- mindrecord_file = create_mindrecord(args_opt.dataset, "ssd_eval.mindrecord", False)
-
- print("Start Eval!")
- ssd_eval(mindrecord_file, args_opt.checkpoint_path, json_path)
+# Copyright 2021 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.
+# ============================================================================
+
+"""Evaluation for SSD"""
+
+import os
+import argparse
+import time
+import numpy as np
+from mindspore import context, Tensor
+from mindspore.train.serialization import load_checkpoint, load_param_into_net
+from src.ssd import SsdInferWithDecoder, ssd_resnet50
+from src.dataset import create_ssd_dataset, create_mindrecord
+from src.config import config
+from src.eval_utils import metrics
+from src.box_utils import default_boxes
+
+def ssd_eval(dataset_path, ckpt_path, anno_json):
+ """SSD evaluation."""
+ batch_size = 1
+ ds = create_ssd_dataset(dataset_path, batch_size=batch_size, repeat_num=1,
+ is_training=False, use_multiprocessing=False)
+ if config.model == "ssd_resnet50":
+ net = ssd_resnet50(config=config)
+ else:
+ raise ValueError(f'config.model: {config.model} is not supported')
+ net = SsdInferWithDecoder(net, Tensor(default_boxes), config)
+
+ print("Load Checkpoint!")
+ param_dict = load_checkpoint(ckpt_path)
+ net.init_parameters_data()
+ load_param_into_net(net, param_dict)
+
+ net.set_train(False)
+ i = batch_size
+ total = ds.get_dataset_size() * batch_size
+ start = time.time()
+ pred_data = []
+ print("\n========================================\n")
+ print("total images num: ", total)
+ print("Processing, please wait a moment.")
+ for data in ds.create_dict_iterator(output_numpy=True, num_epochs=1):
+ img_id = data['img_id']
+ img_np = data['image']
+ image_shape = data['image_shape']
+
+ output = net(Tensor(img_np))
+ for batch_idx in range(img_np.shape[0]):
+ pred_data.append({"boxes": output[0].asnumpy()[batch_idx],
+ "box_scores": output[1].asnumpy()[batch_idx],
+ "img_id": int(np.squeeze(img_id[batch_idx])),
+ "image_shape": image_shape[batch_idx]})
+ percent = round(i / total * 100., 2)
+
+ print(f' {str(percent)} [{i}/{total}]', end='\r')
+ i += batch_size
+ cost_time = int((time.time() - start) * 1000)
+ print(f' 100% [{total}/{total}] cost {cost_time} ms')
+ mAP = metrics(pred_data, anno_json)
+ print("\n========================================\n")
+ print(f"mAP: {mAP}")
+
+def get_eval_args():
+ parser = argparse.ArgumentParser(description='SSD evaluation')
+ parser.add_argument("--device_id", type=int, default=0, help="Device id, default is 0.")
+ parser.add_argument("--dataset", type=str, default="coco", help="Dataset, default is coco.")
+ parser.add_argument("--checkpoint_path", type=str, required=True, help="Checkpoint file path.")
+ parser.add_argument("--run_platform", type=str, default="Ascend", choices=("Ascend", "GPU", "CPU"),
+ help="run platform, support Ascend ,GPU and CPU.")
+ return parser.parse_args()
+
+if __name__ == '__main__':
+ args_opt = get_eval_args()
+ if args_opt.dataset == "coco":
+ json_path = os.path.join(config.coco_root, config.instances_set.format(config.val_data_type))
+ elif args_opt.dataset == "voc":
+ json_path = os.path.join(config.voc_root, config.voc_json)
+ else:
+ raise ValueError('SSD eval only support dataset mode is coco and voc!')
+
+ context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.run_platform, device_id=args_opt.device_id)
+
+ mindrecord_file = create_mindrecord(args_opt.dataset, "ssd_eval.mindrecord", False)
+
+ print("Start Eval!")
+ ssd_eval(mindrecord_file, args_opt.checkpoint_path, json_path)
diff --git a/research/cv/ssd_resnet50/export.py b/research/cv/ssd_resnet50/export.py
index 290ed3763a306a1d515742fa9e8e3855742299f0..21c90210cd90c5ec732d77fd621e4d6491c1ae0e 100644
--- a/research/cv/ssd_resnet50/export.py
+++ b/research/cv/ssd_resnet50/export.py
@@ -1,52 +1,52 @@
-# Copyright 2021 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"""
-import argparse
-import numpy as np
-from mindspore import context, Tensor, dtype
-from mindspore.train.serialization import load_checkpoint, load_param_into_net, export
-from src.ssd import SsdInferWithDecoder, ssd_resnet50
-from src.config import config
-from src.box_utils import default_boxes
-
-parser = argparse.ArgumentParser(description='SSD export')
-parser.add_argument("--device_id", type=int, default=0, help="Device id")
-parser.add_argument("--batch_size", type=int, default=1, help="batch size")
-parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
-parser.add_argument("--file_name", type=str, default="ssd", help="output file name.")
-parser.add_argument('--file_format', type=str, choices=["AIR", "MINDIR"], default='AIR', help='file format')
-parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"], default="Ascend",
- help="device target")
-args = parser.parse_args()
-
-context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
-if args.device_target == "Ascend":
- context.set_context(device_id=args.device_id)
-
-if __name__ == '__main__':
- if config.model == "ssd_resnet50":
- net = ssd_resnet50(config=config)
- else:
- raise ValueError(f'config.model: {config.model} is not supported')
- net = SsdInferWithDecoder(net, Tensor(default_boxes), config)
-
- param_dict = load_checkpoint(args.ckpt_file)
- net.init_parameters_data()
- load_param_into_net(net, param_dict)
- net.set_train(False)
-
- input_shp = [args.batch_size, 3] + config.img_shape
- input_array = Tensor(np.random.uniform(-1.0, 1.0, size=input_shp), dtype.float32)
- export(net, input_array, file_name=args.file_name, file_format=args.file_format)
+# Copyright 2021 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"""
+import argparse
+import numpy as np
+from mindspore import context, Tensor, dtype
+from mindspore.train.serialization import load_checkpoint, load_param_into_net, export
+from src.ssd import SsdInferWithDecoder, ssd_resnet50
+from src.config import config
+from src.box_utils import default_boxes
+
+parser = argparse.ArgumentParser(description='SSD export')
+parser.add_argument("--device_id", type=int, default=0, help="Device id")
+parser.add_argument("--batch_size", type=int, default=1, help="batch size")
+parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
+parser.add_argument("--file_name", type=str, default="ssd", help="output file name.")
+parser.add_argument('--file_format', type=str, choices=["AIR", "MINDIR"], default='AIR', help='file format')
+parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"], default="Ascend",
+ help="device target")
+args = parser.parse_args()
+
+context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
+if args.device_target == "Ascend":
+ context.set_context(device_id=args.device_id)
+
+if __name__ == '__main__':
+ if config.model == "ssd_resnet50":
+ net = ssd_resnet50(config=config)
+ else:
+ raise ValueError(f'config.model: {config.model} is not supported')
+ net = SsdInferWithDecoder(net, Tensor(default_boxes), config)
+
+ param_dict = load_checkpoint(args.ckpt_file)
+ net.init_parameters_data()
+ load_param_into_net(net, param_dict)
+ net.set_train(False)
+
+ input_shp = [args.batch_size, 3] + config.img_shape
+ input_array = Tensor(np.random.uniform(-1.0, 1.0, size=input_shp), dtype.float32)
+ export(net, input_array, file_name=args.file_name, file_format=args.file_format)
diff --git a/research/cv/ssd_resnet50/infer/__init__.py b/research/cv/ssd_resnet50/infer/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..5561fecbf78c85332d430b130e077a13dcf4280b
--- /dev/null
+++ b/research/cv/ssd_resnet50/infer/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (C) 2021.Huawei Technologies Co., Ltd. All rights reserved.
+#
+# 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.
diff --git a/research/cv/ssd_resnet50/infer/convert/aipp.cfg b/research/cv/ssd_resnet50/infer/convert/aipp.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..f40bc1b108ec4fd1f400ca916b91c524bfb162b1
--- /dev/null
+++ b/research/cv/ssd_resnet50/infer/convert/aipp.cfg
@@ -0,0 +1,12 @@
+aipp_op {
+aipp_mode: static
+input_format : RGB888_U8
+csc_switch : false
+rbuv_swap_switch : true
+mean_chn_0 : 124
+mean_chn_1 : 117
+mean_chn_2 : 104
+ var_reci_chn_0 : 0.0171247538316637
+ var_reci_chn_1 : 0.0175070028011204
+ var_reci_chn_2 : 0.0174291938997821
+}
\ No newline at end of file
diff --git a/research/cv/ssd_resnet50/infer/convert/convert_om.sh b/research/cv/ssd_resnet50/infer/convert/convert_om.sh
new file mode 100644
index 0000000000000000000000000000000000000000..c9bd774fc19f683a8a01a2935e294c8f7385596a
--- /dev/null
+++ b/research/cv/ssd_resnet50/infer/convert/convert_om.sh
@@ -0,0 +1,25 @@
+# 转化模型
+input_air_path=$1
+output_om_path=$2
+aipp_cfg=$3
+
+export ASCEND_ATC_PATH=/usr/local/Ascend/atc/bin/atc
+export LD_LIBRARY_PATH=/usr/local/Ascend/atc/lib64:$LD_LIBRARY_PATH
+export PATH=/usr/local/python3.7.5/bin:/usr/local/Ascend/atc/ccec_compiler/bin:/usr/local/Ascend/atc/bin:$PATH
+export PYTHONPATH=/usr/local/Ascend/atc/python/site-packages:/usr/local/Ascend/atc/python/site-packages/auto_tune.egg/auto_tune:/usr/local/Ascend/atc/python/site-packages/schedule_search.egg
+export ASCEND_OPP_PATH=/usr/local/Ascend/opp
+
+export ASCEND_SLOG_PRINT_TO_STDOUT=1
+
+echo "Input AIR file path: ${input_air_path}"
+echo "Output OM file path: ${output_om_path}"
+echo "AIPP cfg file path: ${aipp_cfg}"
+
+atc --input_format=NCHW --framework=1 \
+--model=${input_air_path} \
+--output=${output_om_path} \
+--soc_version=Ascend310 \
+--disable_reuse_memory=0 \
+--insert_op_conf=${aipp_cfg} \
+--precision_mode=allow_fp32_to_fp16 \
+--op_select_implmode=high_precision
\ No newline at end of file
diff --git a/research/cv/ssd_resnet50/infer/mxbase/C++/CMakeLists.txt b/research/cv/ssd_resnet50/infer/mxbase/C++/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..f509e7d8bf1de35d7e0557cb230cf34a1010f9ae
--- /dev/null
+++ b/research/cv/ssd_resnet50/infer/mxbase/C++/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 3.10.0)
+project(ssd_ms)
+
+set(TARGET ssd_resnet50)
+
+SET(CMAKE_BUILD_TYPE "Debug")
+SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
+SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
+
+add_definitions(-DENABLE_DVPP_INTERFACE)
+add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
+add_definitions(-Dgoogle=mindxsdk_private)
+add_compile_options(-std=c++11 -fPIE -fstack-protector-all -fPIC -Wall)
+add_link_options(-Wl,-z,relro,-z,now,-z,noexecstack -pie)
+
+# Check environment variable
+if(NOT DEFINED ENV{ASCEND_HOME})
+ message(FATAL_ERROR "please define environment variable:ASCEND_HOME")
+endif()
+if(NOT DEFINED ENV{ASCEND_VERSION})
+ message(WARNING "please define environment variable:ASCEND_VERSION")
+endif()
+if(NOT DEFINED ENV{ARCH_PATTERN})
+ message(WARNING "please define environment variable:ARCH_PATTERN")
+endif()
+
+# 设置acllib的头文件和动态链接库
+set(ACL_INC_DIR $ENV{ASCEND_HOME}/${ASCEND_VERSION}/${ARCH_PATTERN}/acllib/include)
+set(ACL_LIB_DIR $ENV{ASCEND_HOME}/${ASCEND_VERSION}/${ARCH_PATTERN}/acllib/lib64)
+
+# 设置MxBase的头文件和动态链接库
+set(MXBASE_ROOT_DIR $ENV{MX_SDK_HOME})
+set(MXBASE_INC ${MXBASE_ROOT_DIR}/include)
+set(MXBASE_LIB_DIR ${MXBASE_ROOT_DIR}/lib)
+set(MXBASE_POST_LIB_DIR ${MXBASE_ROOT_DIR}/lib/modelpostprocessors)
+set(MXBASE_POST_PROCESS_DIR ${MXBASE_ROOT_DIR}/include/MxBase/postprocess/include)
+
+# 设置opensource的头文件和动态链接库
+# 主要包含OpenCV、Google log等开源库
+set(OPENSOURCE_DIR ${MXBASE_ROOT_DIR}/opensource)
+
+include_directories(${ACL_INC_DIR})
+include_directories(${OPENSOURCE_DIR}/include)
+include_directories(${OPENSOURCE_DIR}/include/opencv4)
+
+include_directories(${MXBASE_INC})
+include_directories(${MXBASE_POST_PROCESS_DIR})
+link_directories(${ACL_LIB_DIR})
+link_directories(${OPENSOURCE_DIR}/lib)
+link_directories(${MXBASE_LIB_DIR})
+link_directories(${MXBASE_POST_LIB_DIR})
+
+# 本地编译链接文件,根据mxbase目录下文件添加修改
+add_executable(${TARGET} ResNet50_main.cpp ResNet50Base.cpp)
+
+# 链接动态链接库,后处理lib:yolov3postprocess根据实际情况修改
+target_link_libraries(${TARGET} glog cpprest mxbase SsdMobilenetFpn_MindsporePost opencv_world stdc++fs)
+
+install(TARGETS ${TARGET} RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/)
\ No newline at end of file
diff --git a/research/cv/ssd_resnet50/infer/mxbase/C++/ResNet50Base.cpp b/research/cv/ssd_resnet50/infer/mxbase/C++/ResNet50Base.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64a88de4e95c6066c0f4a9712a3dd29b94880021
--- /dev/null
+++ b/research/cv/ssd_resnet50/infer/mxbase/C++/ResNet50Base.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2021. Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * 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.
+ */
+
+// 主代码逻辑
+#include "SSDResNet50.h"
+#include
+#include
+#include