Browse Source

!6809 modified psenet for safe

Merge pull request !6809 from 吴书全/psenet0923
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
40918bc46a
4 changed files with 20 additions and 10 deletions
  1. +14
    -8
      model_zoo/official/cv/psenet/README.md
  2. +1
    -1
      model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp
  3. +4
    -0
      model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h
  4. +1
    -1
      model_zoo/official/cv/psenet/train.py

+ 14
- 8
model_zoo/official/cv/psenet/README.md View File

@@ -57,11 +57,15 @@ After installing MindSpore via the official website, you can start training and
# run distributed training example # run distributed training example
sh scripts/run_distribute_train.sh pretrained_model.ckpt sh scripts/run_distribute_train.sh pretrained_model.ckpt
#setup opencv library
download pyblind11, opencv3.4,setup opencv3.4
#download opencv library
download pyblind11, opencv3.4
#make so file
run src/ETSNET/pse/Makefile; make libadaptor.so
#install pyblind11 opencv3.4
setup pyblind11(install the library by the pip command)
setup opencv3.4(compile source code install the library)
#enter the path ,run Makefile to product file
cd ./src/ETSNET/pse/;make
#run test.py #run test.py
python test.py --ckpt=pretrained_model.ckpt python test.py --ckpt=pretrained_model.ckpt
@@ -81,10 +85,10 @@ sh scripts/run_eval_ascend.sh
├── README.md // descriptions about PSENet ├── README.md // descriptions about PSENet
├── scripts ├── scripts
├── run_distribute_train.sh // shell script for distributed ├── run_distribute_train.sh // shell script for distributed
└── eval_ic15.sh // shell script for evaluation
└── run_eval_ascend.sh // shell script for evaluation
├── src ├── src
├── __init__.py ├── __init__.py
├── generate_hccn_file.py // creating rank.json
├── generate_hccn_file.py // creating rank.json
├── ETSNET ├── ETSNET
├── __init__.py ├── __init__.py
├── base.py // convolution and BN operator ├── base.py // convolution and BN operator
@@ -127,7 +131,7 @@ sh scripts/run_distribute_train.sh pretrained_model.ckpt
``` ```
The above shell script will run distribute training in the background. You can view the results through the file The above shell script will run distribute training in the background. You can view the results through the file
`device[X]/log`. The loss value will be achieved as follows:
`device[X]/test_*.log`. The loss value will be achieved as follows:
``` ```
# grep "epoch: " device_*/loss.log # grep "epoch: " device_*/loss.log
@@ -140,6 +144,8 @@ device_1/log:epcoh: 2, step: 40, loss is 0.76629
``` ```
## [Evaluation Process](#contents) ## [Evaluation Process](#contents)
### run test code
python test.py --ckpt=./device*/ckpt*/ETSNet-*.ckpt
### Eval Script for ICDAR2015 ### Eval Script for ICDAR2015
#### Usage #### Usage
@@ -187,7 +193,7 @@ Calculated!{"precision": 0.814796668299853, "recall": 0.8006740491092923, "hmean
| MindSpore Version | 1.0-alpha | | MindSpore Version | 1.0-alpha |
| Dataset | ICDAR2015 | | Dataset | ICDAR2015 |
| outputs | probability | | outputs | probability |
| Accuracy | 1pc: 81%; 8pcs: 81% |
| Accuracy | 1pc: 81%; 4pcs: 81% |
## [How to use](#contents) ## [How to use](#contents)


+ 1
- 1
model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp View File

@@ -49,7 +49,7 @@ namespace pse_adaptor {
Mat label_mat; Mat label_mat;
int label_num = connectedComponents(kernals[kernals.size() - 1], label_mat, 4); int label_num = connectedComponents(kernals[kernals.size() - 1], label_mat, 4);
vector<int> area(label_num + 1, 0) vector<int> area(label_num + 1, 0)
memset(area, 0, sizeof(area));
memset_s(area, 0, sizeof(area));
for (int x = 0; x < label_mat.rows; ++x) { for (int x = 0; x < label_mat.rows; ++x) {
for (int y = 0; y < label_mat.cols; ++y) { for (int y = 0; y < label_mat.cols; ++y) {
int label = label_mat.at<int>(x, y); int label = label_mat.at<int>(x, y);


+ 4
- 0
model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h View File

@@ -13,3 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */

#ifndef ADAPTOR_H
#define ADAPTOR_H
#endif

+ 1
- 1
model_zoo/official/cv/psenet/train.py View File

@@ -49,7 +49,7 @@ def train():
rank_id = 0 rank_id = 0
if args.run_distribute: if args.run_distribute:
context.set_auto_parallel_context(device_num=args.device_num, parallel_mode=ParallelMode.DATA_PARALLEL, context.set_auto_parallel_context(device_num=args.device_num, parallel_mode=ParallelMode.DATA_PARALLEL,
gradients_mean=True, parameter_broadcast=True)
gradients_mean=True)
init() init()
rank_id = get_rank() rank_id = get_rank()


Loading…
Cancel
Save