From 143f5dbd5a988ed3302f62eac9ed53e08ae8e9af Mon Sep 17 00:00:00 2001 From: wsq3 <877518222@qq.com> Date: Wed, 23 Sep 2020 21:46:59 +0800 Subject: [PATCH] modified psenet for safe --- model_zoo/official/cv/psenet/README.md | 22 ++++++++++++------- .../cv/psenet/src/ETSNET/pse/adaptor.cpp | 2 +- .../cv/psenet/src/ETSNET/pse/adaptor.h | 4 ++++ model_zoo/official/cv/psenet/train.py | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/model_zoo/official/cv/psenet/README.md b/model_zoo/official/cv/psenet/README.md index 054f933d02..80bfff34d2 100644 --- a/model_zoo/official/cv/psenet/README.md +++ b/model_zoo/official/cv/psenet/README.md @@ -57,11 +57,15 @@ After installing MindSpore via the official website, you can start training and # run distributed training example 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 python test.py --ckpt=pretrained_model.ckpt @@ -81,10 +85,10 @@ sh scripts/run_eval_ascend.sh ├── README.md // descriptions about PSENet ├── scripts ├── run_distribute_train.sh // shell script for distributed - └── eval_ic15.sh // shell script for evaluation + └── run_eval_ascend.sh // shell script for evaluation ├── src ├── __init__.py - ├── generate_hccn_file.py // creating rank.json + ├── generate_hccn_file.py // creating rank.json ├── ETSNET ├── __init__.py ├── 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 -`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 @@ -140,6 +144,8 @@ device_1/log:epcoh: 2, step: 40, loss is 0.76629 ``` ## [Evaluation Process](#contents) +### run test code +python test.py --ckpt=./device*/ckpt*/ETSNet-*.ckpt ### Eval Script for ICDAR2015 #### Usage @@ -187,7 +193,7 @@ Calculated!{"precision": 0.814796668299853, "recall": 0.8006740491092923, "hmean | MindSpore Version | 1.0-alpha | | Dataset | ICDAR2015 | | outputs | probability | -| Accuracy | 1pc: 81%; 8pcs: 81% | +| Accuracy | 1pc: 81%; 4pcs: 81% | ## [How to use](#contents) diff --git a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp index f2305d4085..95125278ae 100644 --- a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp +++ b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp @@ -49,7 +49,7 @@ namespace pse_adaptor { Mat label_mat; int label_num = connectedComponents(kernals[kernals.size() - 1], label_mat, 4); vector 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 y = 0; y < label_mat.cols; ++y) { int label = label_mat.at(x, y); diff --git a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h index ebb8decd08..f9f87c2e09 100644 --- a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h +++ b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.h @@ -13,3 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#ifndef ADAPTOR_H +#define ADAPTOR_H +#endif diff --git a/model_zoo/official/cv/psenet/train.py b/model_zoo/official/cv/psenet/train.py index 513e284950..35c6c9bb95 100644 --- a/model_zoo/official/cv/psenet/train.py +++ b/model_zoo/official/cv/psenet/train.py @@ -49,7 +49,7 @@ def train(): rank_id = 0 if args.run_distribute: 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() rank_id = get_rank()