From ed9065c72bc82c64bb0b65c17243f32f60f38967 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Thu, 11 Jun 2020 09:45:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=A8=8B=E5=BA=8F=E4=B8=AD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8os.path.append=E6=B7=BB=E5=8A=A0=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ README.md | 8 +------- README_en.md | 8 +------- tools/infer/predict_system.py | 7 +++++-- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 3db08180..f936b570 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ output/ *~ *.vscode *.idea + +*.log diff --git a/README.md b/README.md index 908ad2fc..3aa2c7cf 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,7 @@ cd .. 以下代码实现了文本检测、识别串联推理,在执行预测时,需要通过参数image_dir指定单张图像或者图像集合的路径、参数det_model_dir指定检测inference模型的路径和参数rec_model_dir指定识别inference模型的路径。可视化识别结果默认保存到 ./inference_results 文件夹里面。 -``` -# 设置PYTHONPATH环境变量 -export PYTHONPATH=. - -# windows下设置环境变量 -SET PYTHONPATH=. - +```bash # 预测image_dir指定的单张图像 python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_det_mv3_db/" --rec_model_dir="./inference/ch_rec_mv3_crnn/" diff --git a/README_en.md b/README_en.md index f8aa4e7f..cfc147c8 100644 --- a/README_en.md +++ b/README_en.md @@ -67,13 +67,7 @@ cd .. The following code implements text detection and recognition inference tandemly. When performing prediction, you need to specify the path of a single image or image folder through the parameter `image_dir`, the parameter `det_model_dir` specifies the path to detection model, and the parameter `rec_model_dir` specifies the path to the recognition model. The visual prediction results are saved to the `./inference_results` folder by default. -``` -# Set PYTHONPATH environment variable -export PYTHONPATH=. - -# Setting environment variable in Windows -SET PYTHONPATH=. - +```bash # Prediction on a single image by specifying image path to image_dir python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_det_mv3_db/" --rec_model_dir="./inference/ch_rec_mv3_crnn/" diff --git a/tools/infer/predict_system.py b/tools/infer/predict_system.py index 3953fa0d..1019279a 100755 --- a/tools/infer/predict_system.py +++ b/tools/infer/predict_system.py @@ -11,7 +11,11 @@ # 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 sys +__dir__ = os.path.dirname(__file__) +sys.path.append(__dir__) +sys.path.append(os.path.join(__dir__, '../..')) import utility from ppocr.utils.utility import initial_logger logger = initial_logger() @@ -25,7 +29,6 @@ import time from ppocr.utils.utility import get_image_file_list from PIL import Image from tools.infer.utility import draw_ocr -import os class TextSystem(object): -- GitLab