From d173bba374407025ccf684ca28f1e387fe8aa0ba Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 30 Jul 2021 09:57:23 +0800 Subject: [PATCH] auto compile post_process of pse --- doc/doc_ch/detection.md | 7 ------- doc/doc_en/detection_en.md | 6 ------ ppocr/postprocess/pse_postprocess/pse/__init__.py | 5 +++++ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/doc/doc_ch/detection.md b/doc/doc_ch/detection.md index dead9658..f8ea9a1c 100644 --- a/doc/doc_ch/detection.md +++ b/doc/doc_ch/detection.md @@ -81,13 +81,6 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/ python3 tools/train.py -c configs/det/det_mv3_db.yml -o Optimizer.base_lr=0.0001 ``` -若训练PSE算法,需先编译后处理 - -```bash -cd ppocr/postprocess/pse_postprocess/pse -python3 setup.py build_ext --inplace -``` - #### 断点训练 如果训练程序中断,如果希望加载训练中断的模型从而恢复训练,可以通过指定Global.checkpoints指定要加载的模型路径: diff --git a/doc/doc_en/detection_en.md b/doc/doc_en/detection_en.md index f9cf3d64..31e24197 100644 --- a/doc/doc_en/detection_en.md +++ b/doc/doc_en/detection_en.md @@ -69,12 +69,6 @@ python3 tools/train.py -c configs/det/det_mv3_db.yml -o Optimizer.base_lr=0.0001 python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/det/det_mv3_db.yml -o Optimizer.base_lr=0.0001 ``` -If you train the PSE algorithm, you need to compile the post-processing first. -```bash -cd ppocr/postprocess/pse_postprocess/pse -python3 setup.py build_ext --inplace -``` - #### load trained model and continue training If you expect to load trained model and continue the training again, you can specify the parameter `Global.checkpoints` as the model path to be loaded. diff --git a/ppocr/postprocess/pse_postprocess/pse/__init__.py b/ppocr/postprocess/pse_postprocess/pse/__init__.py index e603ce47..a917c705 100644 --- a/ppocr/postprocess/pse_postprocess/pse/__init__.py +++ b/ppocr/postprocess/pse_postprocess/pse/__init__.py @@ -11,5 +11,10 @@ # 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. +import os +import subprocess + +if subprocess.call('cd ppocr/postprocess/pse_postprocess/pse;python3 setup.py build_ext --inplace;cd -', shell=True) != 0: + raise RuntimeError('Cannot compile pse: {}'.format(os.path.dirname(os.path.realpath(__file__)))) from .pse import pse \ No newline at end of file -- GitLab