diff --git a/PPOCRLabel/Makefile b/PPOCRLabel/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7d72a890cbfb297de5e5329261092b8af481751a --- /dev/null +++ b/PPOCRLabel/Makefile @@ -0,0 +1,35 @@ +# ex: set ts=8 noet: + +all: qt5 test + +test: testpy3 + +testpy2: + python -m unittest discover tests + +testpy3: + python3 -m unittest discover tests + +qt4: qt4py2 + +qt5: qt5py3 + +qt4py2: + pyrcc4 -py2 -o libs/resources.py resources.qrc + +qt4py3: + pyrcc4 -py3 -o libs/resources.py resources.qrc + +qt5py3: + pyrcc5 -o libs/resources.py resources.qrc + +clean: + rm -rf ~/.labelImgSettings.pkl *.pyc dist labelImg.egg-info __pycache__ build + +pip_upload: + python3 setup.py upload + +long_description: + restview --long-description + +.PHONY: all diff --git a/PPOCRLabel/README.md b/PPOCRLabel/README.md index 93fd64ffe1d0923d3e754e3964fa7c62509d0df0..1b46e412765e980dd0b90bc63d92ddd62ffed5e0 100644 --- a/PPOCRLabel/README.md +++ b/PPOCRLabel/README.md @@ -24,11 +24,9 @@ python PPOCRLabel.py #### Ubuntu Linux ``` -sudo apt-get install pyqt5-dev-tools -sudo apt-get install trash-cli +pip3 install pyqt5 +pip3 install trash-cli cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下 -sudo pip3 install -r requirements/requirements-linux-python3.txt -make qt5py3 python3 PPOCRLabel.py ``` @@ -38,7 +36,6 @@ pip3 install pyqt5 pip3 uninstall opencv-python # 由于mac版本的opencv与pyqt有冲突,需先手动卸载opencv pip3 install opencv-contrib-python-headless # 安装headless版本的open-cv cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下 -make qt5py3 python3 PPOCRLabel.py ``` @@ -75,6 +72,20 @@ python3 PPOCRLabel.py | rec_gt.txt | 识别标签。可直接用于PPOCR识别模型训练。需用户手动点击菜单栏“PaddleOCR” - "保存识别结果"后产生。 | | crop_img | 识别数据。按照检测框切割后的图片。与rec_gt.txt同时产生。 | +## 说明 +### 内置模型 + - 默认模型:PPOCRLabel默认使用PaddleOCR中的中英文超轻量OCR模型,支持中英文与数字识别,多种语言检测。 + - 模型语言切换:用户可通过菜单栏中 "PaddleOCR" - "选择模型" 切换内置模型语言,目前支持的语言包括法文、德文、韩文、日文。具体模型下载链接可参考[PaddleOCR模型列表](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/models_list.md). + - 自定义模型:用户可根据[自定义模型代码使用](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/whl.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9E%8B),通过修改PPOCRLabel.py中针对[PaddleOCR类的实例化](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/PPOCRLabel/PPOCRLabel.py#L110)替换成自己训练的模型 + +### 错误提示 +- 如果同时使用whl包安装了paddleocr,其优先级大于通过paddleocr.py调用PaddleOCR类,whl包未更新时会导致程序异常。 +- PPOCRLabel**不支持对中文文件名**的图片进行自动标注。 +- 如果您在打开软件过程中出现**objc[XXXXX]**开头的错误,证明您的opencv版本太高,建议安装4.2版本: +``` +pip install opencv-python==4.2.0.32 +``` + ### 参考资料 1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg) diff --git a/PPOCRLabel/README_en.md b/PPOCRLabel/README_en.md index 7ebbb97c1f2693942f5949a17c68f54b5d6a6cbe..d503dd3d39d065769ef6e64a4737637b486788ac 100644 --- a/PPOCRLabel/README_en.md +++ b/PPOCRLabel/README_en.md @@ -26,11 +26,9 @@ python PPOCRLabel.py --lang en #### Ubuntu Linux ``` -sudo apt-get install pyqt5-dev-tools -sudo apt-get install trash-cli +pip3 install pyqt5 +pip3 install trash-cli cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder -sudo pip3 install -r requirements/requirements-linux-python3.txt -make qt5py3 python3 PPOCRLabel.py --lang en ``` @@ -40,7 +38,6 @@ pip3 install pyqt5 pip3 uninstall opencv-python # Uninstall opencv manually as it conflicts with pyqt pip3 install opencv-contrib-python-headless # Install the headless version of opencv cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder -make qt5py3 python3 PPOCRLabel.py --lang en ``` @@ -92,6 +89,14 @@ Therefore, if the recognition result has been manually changed before, it may ch | rec_gt.txt | The recognition label file, which can be directly used for PPOCR identification model training, is generated after the user clicks on the menu bar "PaddleOCR"-"Save recognition result". | | crop_img | The recognition data, generated at the same time with *rec_gt.txt* | + +### Built-in Model +- Default model: PPOCRLabel uses the Chinese and English ultra-lightweight OCR model in PaddleOCR by default, supports Chinese, English and number recognition, and multiple language detection. +- Model language switching: Changing the built-in model language is supportable by clicking "PaddleOCR"-"Choose OCR Model" in the menu bar. Currently supported languages​include French, German, Korean, and Japanese. +For specific model download links, please refer to [PaddleOCR Model List](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/models_list_en.md#multilingual-recognition-modelupdating) +- Custom model: The model trained by users can be replaced by modifying PPOCRLabel.py in [PaddleOCR class instantiation](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/PPOCRLabel/PPOCRLabel.py#L110) referring [Custom Model Code](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/whl_en.md#use-custom-model) + + ## Related 1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg) diff --git a/PPOCRLabel/build-tools/.gitignore b/PPOCRLabel/build-tools/.gitignore deleted file mode 100644 index e05bf6bf57739a813c00bad0c045b224ff37705f..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -*.spec -build -dist -pyinstaller -python-2.* -pywin32* -virtual-wine -venv_wine -PyQt4-* -lxml-* -windows_v* -linux_v* diff --git a/PPOCRLabel/build-tools/README.md b/PPOCRLabel/build-tools/README.md deleted file mode 100644 index 8e4cc5dae4af9a75416cd3595de480f72a7bb305..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/README.md +++ /dev/null @@ -1,35 +0,0 @@ -### Deploy to PyPI - -``` -cd [ROOT] -sh build-tools/build-for-pypi.sh -``` - -### Build for Ubuntu - -``` -cd build-tools -sh run-in-container.sh -sh envsetup.sh -sh build-ubuntu-binary.sh -``` - -### Build for Windows - -``` -cd build-tools -sh run-in-container.sh -sh envsetup.sh -sh build-windows-binary.sh -``` - -### Build for macOS High Sierra -``` -cd build-tools -./build-for-macos.sh -``` - -Note: If there are some problems, try to -``` -sudo rm -rf virtual-wne venv_wine -``` diff --git a/PPOCRLabel/build-tools/build-for-macos.sh b/PPOCRLabel/build-tools/build-for-macos.sh deleted file mode 100644 index dfe926b72a0df1f939301a18be641a2a5adcbad8..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/build-for-macos.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -brew install python@2 -pip install --upgrade virtualenv - -# clone labelimg source -rm -rf /tmp/labelImgSetup -mkdir /tmp/labelImgSetup -cd /tmp/labelImgSetup -curl https://codeload.github.com/tzutalin/labelImg/zip/master --output labelImg.zip -unzip labelImg.zip -rm labelImg.zip - -# setup python3 space -virtualenv --system-site-packages -p python3 /tmp/labelImgSetup/labelImg-py3 -source /tmp/labelImgSetup/labelImg-py3/bin/activate -cd labelImg-master - -# build labelImg app -pip install py2app -pip install PyQt5 lxml -make qt5py3 -rm -rf build dist -python setup.py py2app -A -mv "/tmp/labelImgSetup/labelImg-master/dist/labelImg.app" /Applications -# deactivate python3 -deactivate -cd ../ -rm -rf /tmp/labelImgSetup -echo 'DONE' diff --git a/PPOCRLabel/build-tools/build-for-pypi.sh b/PPOCRLabel/build-tools/build-for-pypi.sh deleted file mode 100644 index d5ad5c7c4b638e68114a477a6342a718ffb878a8..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/build-for-pypi.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# Packaging and Release -docker run --workdir=$(pwd)/ --volume="/home/$USER:/home/$USER" tzutalin/py2qt4 /bin/sh -c 'make qt4py2; make test;sudo python setup.py sdist;sudo python setup.py install' - -while true; do - read -p "Do you wish to deploy this to PyPI(twine upload dist/* or pip install dist/*)?" yn - case $yn in - [Yy]* ) docker run -it --rm --workdir=$(pwd)/ --volume="/home/$USER:/home/$USER" tzutalin/py2qt4; break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -# python setup.py register -# python setup.py sdist upload -# Net pypi: twine upload dist/* - -# Test before upladoing: pip install dist/labelImg.tar.gz diff --git a/PPOCRLabel/build-tools/build-ubuntu-binary.sh b/PPOCRLabel/build-tools/build-ubuntu-binary.sh deleted file mode 100644 index dbe530287bfe9afe730f00252e414e3728e0b746..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/build-ubuntu-binary.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -### Ubuntu use pyinstall v3.0 -THIS_SCRIPT_PATH=`readlink -f $0` -THIS_SCRIPT_DIR=`dirname ${THIS_SCRIPT_PATH}` -cd pyinstaller -git checkout v3.2 -cd ${THIS_SCRIPT_DIR} - -rm -r build -rm -r dist -rm labelImg.spec -python pyinstaller/pyinstaller.py --hidden-import=xml \ - --hidden-import=xml.etree \ - --hidden-import=xml.etree.ElementTree \ - --hidden-import=lxml.etree \ - -D -F -n labelImg -c "../labelImg.py" -p ../libs -p ../ - -FOLDER=$(git describe --abbrev=0 --tags) -FOLDER="linux_"$FOLDER -rm -rf "$FOLDER" -mkdir "$FOLDER" -cp dist/labelImg $FOLDER -cp -rf ../data $FOLDER/data -zip "$FOLDER.zip" -r $FOLDER diff --git a/PPOCRLabel/build-tools/build-windows-binary.sh b/PPOCRLabel/build-tools/build-windows-binary.sh deleted file mode 100644 index 566e88f9db0865da793486c78cc234b85b16c484..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/build-windows-binary.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -### Window requires pyinstall v2.1 -wine msiexec -i python-2.7.8.msi -wine pywin32-218.win32-py2.7.exe -wine PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe -wine lxml-3.7.3.win32-py2.7.exe - -THIS_SCRIPT_PATH=`readlink -f $0` -THIS_SCRIPT_DIR=`dirname ${THIS_SCRIPT_PATH}` -cd pyinstaller -git checkout v2.1 -cd ${THIS_SCRIPT_DIR} -echo ${THIS_SCRIPT_DIR} - -#. venv_wine/bin/activate -rm -r build -rm -r dist -rm labelImg.spec - -wine c:/Python27/python.exe pyinstaller/pyinstaller.py --hidden-import=xml \ - --hidden-import=xml.etree \ - --hidden-import=xml.etree.ElementTree \ - --hidden-import=lxml.etree \ - -D -F -n labelImg -c "../labelImg.py" -p ../libs -p ../ - -FOLDER=$(git describe --abbrev=0 --tags) -FOLDER="windows_"$FOLDER -rm -rf "$FOLDER" -mkdir "$FOLDER" -cp dist/labelImg.exe $FOLDER -cp -rf ../data $FOLDER/data -zip "$FOLDER.zip" -r $FOLDER diff --git a/PPOCRLabel/build-tools/envsetup.sh b/PPOCRLabel/build-tools/envsetup.sh deleted file mode 100644 index 242b0c569f5738caad415f34a7f16a620157f6ee..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/envsetup.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -THIS_SCRIPT_PATH=`readlink -f $0` -THIS_SCRIPT_DIR=`dirname ${THIS_SCRIPT_PATH}` -#OS Ubuntu 14.04 -### Common packages for linux/windows -if [ ! -e "pyinstaller" ]; then - git clone https://github.com/pyinstaller/pyinstaller - cd pyinstaller - git checkout v2.1 -b v2.1 - cd ${THIS_SCRIPT_DIR} -fi - -echo "Going to clone and download packages for building windows" -#Pacakges -#> pyinstaller (2.1) -#> wine (1.6.2) -#> virtual-wine (0.1) -#> python-2.7.8.msi -#> pywin32-218.win32-py2.7.exe - -## tool to install on Ubuntu -#$ sudo apt-get install wine - -### Clone a repo to create virtual wine env -if [ ! -e "virtual-wine" ]; then - git clone https://github.com/htgoebel/virtual-wine.git -fi - -apt-get install scons -### Create virtual env -rm -rf venv_wine -./virtual-wine/vwine-setup venv_wine -#### Active virutal env -. venv_wine/bin/activate - -### Use wine to install packages to virtual env -if [ ! -e "python-2.7.8.msi" ]; then - wget "https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi" -fi - -if [ ! -e "pywin32-218.win32-py2.7.exe" ]; then - wget "http://nchc.dl.sourceforge.net/project/pywin32/pywin32/Build%20218/pywin32-218.win32-py2.7.exe" -fi - -if [ ! -e "PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe" ]; then - wget "http://nchc.dl.sourceforge.net/project/pyqt/PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe" -fi - -if [ ! -e "lxml-3.7.3.win32-py2.7.exe" ]; then - wget "https://pypi.python.org/packages/a3/f6/a28c5cf63873f6c55a3eb7857b736379229b85ba918261d2e88cf886905e/lxml-3.7.3.win32-py2.7.exe#md5=a0f746355876aca4ca5371cb0f1d13ce" -fi - diff --git a/PPOCRLabel/build-tools/run-in-container.sh b/PPOCRLabel/build-tools/run-in-container.sh deleted file mode 100644 index 980699d67753a291616c576d723dc4ff898a1e41..0000000000000000000000000000000000000000 --- a/PPOCRLabel/build-tools/run-in-container.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -docker run -it \ - --user $(id -u) \ - -e DISPLAY=unix$DISPLAY \ - --workdir=$(pwd) \ - --volume="/home/$USER:/home/$USER" \ - --volume="/etc/group:/etc/group:ro" \ - --volume="/etc/passwd:/etc/passwd:ro" \ - --volume="/etc/shadow:/etc/shadow:ro" \ - --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - tzutalin/py2qt4 - diff --git a/doc/doc_ch/whl.md b/doc/doc_ch/whl.md index 1b04a9a8a967f39516db0c0f1be3e3842a87278b..5d118a21b3f8ca82cd8677995a4b3fa07ec9e607 100644 --- a/doc/doc_ch/whl.md +++ b/doc/doc_ch/whl.md @@ -4,6 +4,8 @@ ### 安装whl包 +首先需要参照[安装文档](installation.md)安装paddlepaddle,然后开始安装paddleocr package + pip安装 ```bash pip install paddleocr @@ -166,7 +168,7 @@ paddleocr -h * 检测+分类+识别全流程 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true --cls true +paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true ``` 结果是一个list,每个item包含了文本框,文字和识别置信度 ```bash @@ -190,7 +192,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg * 分类+识别 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --cls true --det false +paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false ``` 结果是一个list,每个item只包含识别结果和识别置信度 @@ -222,7 +224,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --det false * 单独执行分类 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --cls true --det false --rec false +paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false --rec false ``` 结果是一个list,每个item只包含分类结果和分类置信度 @@ -258,7 +260,7 @@ im_show.save('result.jpg') ### 通过命令行使用 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_dir} --rec_model_dir {your_rec_model_dir} --rec_char_dict_path {your_rec_char_dict_path} --cls_model_dir {your_cls_model_dir} --use_angle_cls true --cls true +paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_dir} --rec_model_dir {your_rec_model_dir} --rec_char_dict_path {your_rec_char_dict_path} --cls_model_dir {your_cls_model_dir} --use_angle_cls true ``` ## 参数说明 @@ -295,4 +297,4 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_ | lang | 模型语言类型,目前支持 中文(ch)和英文(en) | ch | | det | 前向时使用启动检测 | TRUE | | rec | 前向时是否启动识别 | TRUE | -| cls | 前向时是否启动分类 | FALSE | +| cls | 前向时是否启动分类, 此参数仅存在于`代码使用`模式 | FALSE | diff --git a/doc/doc_en/whl_en.md b/doc/doc_en/whl_en.md index ffbced346f7a3f661f382b5f2d826c20fef2c012..30baf83c450b3706439359ab32b7caab41623ac7 100644 --- a/doc/doc_en/whl_en.md +++ b/doc/doc_en/whl_en.md @@ -2,6 +2,9 @@ ## Get started quickly ### install package + +First, you need to refer to [installation document](installation_en.md) to install paddlepaddle, and then start to install paddleocr package + install by pypi ```bash pip install paddleocr @@ -172,7 +175,7 @@ paddleocr -h * detection classification and recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --use_angle_cls true -cls true --lang en +paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --use_angle_cls true --lang en ``` Output will be a list, each item contains bounding box, text and recognition confidence @@ -198,7 +201,7 @@ Output will be a list, each item contains bounding box, text and recognition con * classification and recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true -cls true --det false --lang en +paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true --det false --lang en ``` Output will be a list, each item contains text and recognition confidence @@ -221,7 +224,7 @@ Output will be a list, each item only contains bounding box * only recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --det false --cls false --lang en +paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --det false --lang en ``` Output will be a list, each item contains text and recognition confidence @@ -231,7 +234,7 @@ Output will be a list, each item contains text and recognition confidence * only classification ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true -cls true --det false --rec false +paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true --det false --rec false ``` Output will be a list, each item contains classification result and confidence @@ -268,7 +271,7 @@ im_show.save('result.jpg') ### Use by command line ```bash -paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_dir} --rec_model_dir {your_rec_model_dir} --rec_char_dict_path {your_rec_char_dict_path} --cls_model_dir {your_cls_model_dir} --use_angle_cls true --cls true +paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_dir} --rec_model_dir {your_rec_model_dir} --rec_char_dict_path {your_rec_char_dict_path} --cls_model_dir {your_cls_model_dir} --use_angle_cls true ``` ## Parameter Description @@ -305,4 +308,4 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_ | lang | The support language, now only Chinese(ch)、English(en)、French(french)、German(german)、Korean(korean)、Japanese(japan) are supported | ch | | det | Enable detction when `ppocr.ocr` func exec | TRUE | | rec | Enable recognition when `ppocr.ocr` func exec | TRUE | -| cls | Enable classification when `ppocr.ocr` func exec | FALSE | +| cls | Enable classification when `ppocr.ocr` func exec,this parameter only exists in `code usage` mode | FALSE | diff --git a/doc/joinus.PNG b/doc/joinus.PNG index 148dd9b72d0492474cdcec4f2196c6980f917ded..cf6bc366fb0a703b7249423d8179995779869b55 100644 Binary files a/doc/joinus.PNG and b/doc/joinus.PNG differ diff --git a/paddleocr.py b/paddleocr.py index 8e39084b9a2d4ea3464ad1c753a1f2ba2164a305..c86e06b019667f5654aa9257f417f02faae2a8ae 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -117,14 +117,16 @@ def maybe_download(model_storage_directory, url): os.remove(tmp_path) -def parse_args(mMain=True): + +def parse_args(mMain=True,add_help=True): + import argparse def str2bool(v): return v.lower() in ("true", "t", "1") if mMain: - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser(add_help=add_help) # params for prediction engine parser.add_argument("--use_gpu", type=str2bool, default=True) parser.add_argument("--ir_optim", type=str2bool, default=True) @@ -211,6 +213,7 @@ def parse_args(mMain=True): ) + class PaddleOCR(predict_system.TextSystem): def __init__(self, **kwargs): """ @@ -218,7 +221,7 @@ class PaddleOCR(predict_system.TextSystem): args: **kwargs: other params show in paddleocr --help """ - postprocess_params = parse_args(mMain=False) + postprocess_params = parse_args(mMain=False, add_help=False) postprocess_params.__dict__.update(**kwargs) self.use_angle_cls = postprocess_params.use_angle_cls lang = postprocess_params.lang diff --git a/ppocr/modeling/architectures/rec_model.py b/ppocr/modeling/architectures/rec_model.py index 9f8c779cf27c71fd230bd70115795ff51ba6f63c..8bc5cb0e5502ae139a1ef54008c82e975fb211e1 100755 --- a/ppocr/modeling/architectures/rec_model.py +++ b/ppocr/modeling/architectures/rec_model.py @@ -160,6 +160,7 @@ class RecModel(object): "We set img_shape to be the same , it may affect the inference effect" ) image_shape = deepcopy(self.image_shape) + image_shape.insert(0, -1) image = fluid.data(name='image', shape=image_shape, dtype='float32') image.stop_gradient = False if self.loss_type == "srn": diff --git a/requirements.txt b/requirements.txt index aa1b6db4c207ac2ce669ca79055b333642792627..4d9e8650f5d55658c56997888e1ade2fe456721d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ pyclipper lmdb tqdm numpy -opencv-python +opencv-python==4.2.0.32 diff --git a/setup.py b/setup.py index d831a3a34f81357c5807127d763ffeb18974c0ff..06fd46de40b2f74ded0700ead39278476b906f2c 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup( package_dir={'paddleocr': ''}, include_package_data=True, entry_points={"console_scripts": ["paddleocr= paddleocr.paddleocr:main"]}, - version='1.1.1', + version='1.1.2', install_requires=requirements, license='Apache License 2.0', description='Awesome OCR toolkits based on PaddlePaddle (8.6M ultra-lightweight pre-trained model, support training and deployment among server, mobile, embeded and IoT devices', diff --git a/tools/export_model.py b/tools/export_model.py index 0bd06b98dcacc06893becbefacbea198c432bc39..7630a77edccc582b07e01f7e585399c65bfc046c 100644 --- a/tools/export_model.py +++ b/tools/export_model.py @@ -15,6 +15,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from ppocr.utils.utility import enable_static_mode import os import sys @@ -43,7 +44,6 @@ logger = initial_logger() from ppocr.utils.save_load import init_model - def main(): startup_prog, eval_program, place, config, _ = program.preprocess() @@ -72,4 +72,5 @@ def main(): if __name__ == '__main__': + enable_static_mode() main() diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index 12966718d3e135bb3400522898187c4f1addfdc1..21f9bf90b9546dfb86266a07683d4af1200d53fa 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -191,10 +191,13 @@ if __name__ == "__main__": if count > 0: total_time += elapse count += 1 - print("Predict time of %s:" % image_file, elapse) + logger.info("The predicted time of img: {} is {}:".format(image_file, + elapse)) src_im = utility.draw_text_det_res(dt_boxes, image_file) - img_name_pure = os.path.split(image_file)[-1] # image_file.split("/")[-1] - img_path = os.path.join(draw_img_save, "det_res_%s" % img_name_pure) - cv2.imwrite(img_path, src_im) + img_name_pure = image_file.split("/")[-1] + cv2.imwrite( + os.path.join(draw_img_save, "det_res_%s" % img_name_pure), src_im) + logger.info("The visualized img saved in {}".format( + os.path.join(draw_img_save, "det_res_%s" % img_name_pure))) if count > 1: - print("Avg Time:", total_time / (count - 1)) + logger.info("Avg Time:", total_time / (count - 1))