- [Continue Training on the Pretrained Model](#continue-training-on-the-pretrained-model)
- [Transfer Learning](#transfer-learning)
- [Transfer Learning](#transfer-learning)
# [PSENet Description](#contents)
With the development of convolutional neural network, scene text detection technology has been developed rapidly. However, there are still two problems in this algorithm, which hinders its application in industry. On the one hand, most of the existing algorithms require quadrilateral bounding boxes to accurately locate arbitrary shape text. On the other hand, two adjacent instances of text can cause error detection overwriting both instances. Traditionally, a segmentation-based approach can solve the first problem, but usually not the second. To solve these two problems, a new PSENet (PSENet) is proposed, which can accurately detect arbitrary shape text instances. More specifically, PSENet generates different scale kernels for each text instance and gradually expands the minimum scale kernel to a text instance with full shape. Because of the large geometric margins between the minimum scale kernels, our method can effectively segment closed text instances, making it easier to detect arbitrary shape text instances. The effectiveness of PSENet has been verified by numerous experiments on CTW1500, full text, ICDAR 2015, and ICDAR 2017 MLT.
[Paper](https://openaccess.thecvf.com/content_CVPR_2019/html/Wang_Shape_Robust_Text_Detection_With_Progressive_Scale_Expansion_Network_CVPR_2019_paper.html): Wenhai Wang, Enze Xie, Xiang Li, Wenbo Hou, Tong Lu, Gang Yu, Shuai Shao; Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019, pp. 9336-9345
With the development of convolutional neural network, scene text detection technology has been developed rapidly. However, there are still two problems in this algorithm, which hinders its application in industry. On the one hand, most of the existing algorithms require quadrilateral bounding boxes to accurately locate arbitrary shape text. On the other hand, two adjacent instances of text can cause error detection overwriting both instances. Traditionally, a segmentation-based approach can solve the first problem, but usually not the second. To solve these two problems, a new PSENet (PSENet) is proposed, which can accurately detect arbitrary shape text instances. More specifically, PSENet generates different scale kernels for each text instance and gradually expands the minimum scale kernel to a text instance with full shape. Because of the large geometric margins between the minimum scale kernels, our method can effectively segment closed text instances, making it easier to detect arbitrary shape text instances. The effectiveness of PSENet has been verified by numerous experiments on CTW1500, full text, ICDAR 2015, and ICDAR 2017 MLT.
[Paper](https://openaccess.thecvf.com/content_CVPR_2019/html/Wang_Shape_Robust_Text_Detection_With_Progressive_Scale_Expansion_Network_CVPR_2019_paper.html): Wenhai Wang, Enze Xie, Xiang Li, Wenbo Hou, Tong Lu, Gang Yu, Shuai Shao; Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019, pp. 9336-9345
# PSENet Example
## Description
Progressive Scale Expansion Network (PSENet) is a text detector which is able to well detect the arbitrary-shape text in natural scene.
# [Dataset](#contents)
@@ -39,23 +40,26 @@ Progressive Scale Expansion Network (PSENet) is a text detector which is able to
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.
A training set of 1000 images containing about 4500 readable words
A training set of 1000 images containing about 4500 readable words
A testing set containing about 2000 readable words
# [Environment Requirements](#contents)
- Hardware(Ascend)
- Prepare hardware environment with Ascend processor. If you want to try Ascend , please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.
- Prepare hardware environment with Ascend processor. If you want to try Ascend , please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.
- Framework
- [MindSpore](http://www.mindspore.cn/install/en)
- [MindSpore](http://www.mindspore.cn/install/en)
- For more information, please check the resources below:
After installing MindSpore via the official website, you can start training and evaluation as follows:
After installing MindSpore via the official website, you can start training and evaluation as follows:
```python
# run distributed training example
sh scripts/run_distribute_train.sh rank_table_file pretrained_model.ckpt
@@ -83,34 +87,34 @@ sh scripts/run_eval_ascend.sh
# [Script Description](#contents)
## [Script and Sample Code](#contents)
```
```path
└── PSENet
├── README.md // descriptions about PSENet
├── scripts
├── run_distribute_train.sh // shell script for distributed
└── run_eval_ascend.sh // shell script for evaluation
├── src
├── __init__.py
├── ETSNET
├── __init__.py
├── base.py // convolution and BN operator
├── dice_loss.py // calculate PSENet loss value
├── etsnet.py // Subnet in PSENet
├── fpn.py // Subnet in PSENet
├── resnet50.py // Subnet in PSENet
├── pse // Subnet in PSENet
├── README.md // descriptions about PSENet
├── scripts
├── run_distribute_train.sh // shell script for distributed
└── run_eval_ascend.sh // shell script for evaluation
├──src
├── __init__.py
├── ETSNET
├── __init__.py
├── base.py // convolution and BN operator
├── dice_loss.py // calculate PSENet loss value
├── etsnet.py // Subnet in PSENet
├── fpn.py // Subnet in PSENet
├── resnet50.py // Subnet in PSENet
├── pse // Subnet in PSENet
├── __init__.py
├── adaptor.cpp
├── adaptor.h
├── Makefile
├── config.py // parameter configuration
├── dataset.py // creating dataset
├── lr_schedule.py // learning ratio generation
└── network_define.py // PSENet architecture
├── export.py // export mindir file
├── mindspore_hub_conf.py // hub config file
├── test.py // test script
└── train.py // training script
├──config.py // parameter configuration
├──dataset.py // creating dataset
├──network_define.py // learning ratio generation
├──export.py // export mindir file
├──mindspore_hub_conf.py // hub config file
├──test.py // test script
├──train.py // training script
```
@@ -120,26 +124,26 @@ sh scripts/run_eval_ascend.sh
Major parameters in train.py and config.py are:
--pre_trained: Whether training from scratch or training based on the
pre-trained model.Optional values are True, False.
pre-trained model.Optional values are True, False.
--device_id: Device ID used to train or evaluate the dataset. Ignore it
when you use train.sh for distributed training.
--device_num: devices used when you use train.sh for distributed training.
```
## [Training Process](#contents)
### Distributed Training
```
```shell
sh scripts/run_distribute_train.sh rank_table_file pretrained_model.ckpt
```
rank_table_file which is specified by RANK_TABLE_FILE is needed when you are running a distribute task. You can generate it by using the [hccl_tools](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools).
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]/test_*.log`. The loss value will be achieved as follows:
```
```log
# grep "epoch: " device_*/loss.log
device_0/log:epoch: 1, step: 20, loss is 0.80383
device_0/log:epcoh: 2, step: 40, loss is 0.77951
@@ -150,25 +154,32 @@ device_1/log:epcoh: 2, step: 40, loss is 0.76629
+ step 1: download eval method from [here](https://rrc.cvc.uab.es/?ch=4&com=tasks#TextLocalization).
+ step 2: click "My Methods" button,then download Evaluation Scripts.
+ step 3: it is recommended to symlink the eval method root to $MINDSPORE/model_zoo/psenet/eval_ic15/. if your folder structure is different,you may need to change the corresponding paths in eval script files.
```
step 1: download eval method from [here](https://rrc.cvc.uab.es/?ch=4&com=tasks#TextLocalization).
step 2: click "My Methods" button,then download Evaluation Scripts.
step 3: it is recommended to symlink the eval method root to $MINDSPORE/model_zoo/psenet/eval_ic15/. if your folder structure is different,you may need to change the corresponding paths in eval script files.
If you need to use the trained model to perform inference on multiple hardware platforms, such as GPU, Ascend 910 or Ascend 310, you can refer to this [Link](https://www.mindspore.cn/tutorial/training/en/master/advanced_use/migrate_3rd_scripts.html). Following the steps below, this is a simple example: