Curved Text Detection by PaddleOCR
Less than 1 minuteDeep Learning InferenceOCRCurved Text DetectionPaddleOCR
Text Detection Task is an old topic of Detction tasks. Curved text is much more free form. in this Post, we show you how to run the curved text detection by PaddleOCR.
Setup Environment
Create a virtual environment named paddle_env.
conda create --name paddle_env python=3.8
Then activate it.
conda activate paddle_env
Install paddlepaddle and paddle ocr packages through pip.
python -m pip install paddlepaddle
pip install "paddleocr>=2.0.1" # Recommend to use version 2.0.1+
Test Environment
Test the installations.
wget https://paddleocr.bj.bcebos.com/dygraph_v2.1/ppocr_img.zip
unzip ppocr_img.zip
paddleocr --image_dir ./ppocr_img/imgs_en/img_12.jpg \
--use_angle_cls true --lang en --use_gpu false
Curved Text Detection with SAST
Clone PaddleOCR repo from github. Checkout the dynamic graph branch.
git clone https://github.com/PaddlePaddle/PaddleOCR.git
cd PaddleOCR
git checkout dygraph
Download the training model of SAST.
mkdir models
cd models
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_totaltext_v2.0_train.tar
tar -xvf det_r50_vd_sast_totaltext_v2.0_train.tar
cd - #return to PaddleOCR repo path
The training model of SAST need to be converted into inference model.
python tools/export_model.py -c configs/det/det_r50_vd_sast_totaltext.yml \
-o Global.pretrained_model=./models/det_r50_vd_sast_totaltext_v2.0_train/best_accuracy \
Global.save_inference_dir=./inference/det_sast_tt
After convertion succeed, a new folder named inference will be created.
Now we are good to run the curved text detction.
python tools/infer/predict_det.py --det_algorithm="SAST" \
--image_dir="./doc/imgs_en/img623.jpg" \
--det_model_dir="./inference/det_sast_tt/" \
--det_sast_polygon=True