Skip to content

Commit

Permalink
在程序中使用os.path.append添加环境变量,不再使用命令设置
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangXinNan committed Jun 11, 2020
1 parent e036c80 commit ed9065c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ output/
*~
*.vscode
*.idea

*.log
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
8 changes: 1 addition & 7 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
7 changes: 5 additions & 2 deletions tools/infer/predict_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -25,7 +29,6 @@
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):
Expand Down

0 comments on commit ed9065c

Please sign in to comment.