From 2b4f62f98ed5fa49d2204061e146a9a4ccd916d9 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 8 Oct 2021 11:19:38 +0800 Subject: [PATCH] update install doc --- doc/doc_ch/environment.md | 47 ++++++++++++++++++--- doc/doc_en/environment_en.md | 80 ++++++++++++++++++++++++++++++------ 2 files changed, 109 insertions(+), 18 deletions(-) diff --git a/doc/doc_ch/environment.md b/doc/doc_ch/environment.md index a5500810..ef7fb415 100644 --- a/doc/doc_ch/environment.md +++ b/doc/doc_ch/environment.md @@ -1,6 +1,13 @@ # 运行环境准备 + Windows和Mac用户推荐使用Anaconda搭建Python环境,Linux用户建议使用docker搭建PyThon环境。 +推荐环境: +- PaddlePaddle >= 2.0.0 (2.1.2) +- python3.7 +- CUDA10.1 / CUDA10.2 +- CUDNN 7.6 + 如果对于Python环境熟悉的用户可以直接跳到第2步安装PaddlePaddle。 * [1. Python环境搭建](#1) @@ -8,6 +15,7 @@ Windows和Mac用户推荐使用Anaconda搭建Python环境,Linux用户建议使 + [1.2 Mac](#1.2) + [1.3 Linux](#1.3) * [2. 安装PaddlePaddle](#2) +* [3. 安装PaddleOCR依赖](#3) @@ -123,13 +131,13 @@ Windows和Mac用户推荐使用Anaconda搭建Python环境,Linux用户建议使 # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/Users/xxx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then - eval "$__conda_setup" + eval "$__conda_setup" else - if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then - . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" - else - export PATH="/Users/xxx/opt/anaconda3/bin:$PATH" - fi + if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then + . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" + else + export PATH="/Users/xxx/opt/anaconda3/bin:$PATH" + fi fi unset __conda_setup # <<< conda initialize <<< @@ -303,6 +311,14 @@ sudo nvidia-docker run --name ppocr -v $PWD:/paddle --shm-size=64G --network=hos # ctrl+P+Q可退出docker 容器,重新进入docker 容器使用如下命令 sudo docker container exec -it ppocr /bin/bash ``` +docker 环境中默认的python3 版本为python3.5,PaddleOCR 建议使用Python3.7,在执行python命令时,可以使用python3.7而不是python3。如下,输入python3.7命令并回车,可以看到使用的是python3.7版本。 +``` +λ root@Linux /paddle python3.7 +Python 3.7.0 (default, Aug 2 2021, 05:30:22) +[GCC 8.2.0] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> +``` @@ -322,7 +338,26 @@ python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple 更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 + +## 3. 安装PaddleOCR依赖 + +下载paddleOCR 代码 +``` +【推荐】git clone https://github.com/PaddlePaddle/PaddleOCR + +如果因为网络问题无法pull成功,也可选择使用码云上的托管: +git clone https://gitee.com/paddlepaddle/PaddleOCR +注:码云托管代码可能无法实时同步本github项目更新,存在3~5天延时,请优先使用推荐方式。 +``` +安装PaddleOCR 依赖 +``` +cd PaddleOCR +pip3 install -r requirements.txt +# docker 中使用pip3.7 代替pip3 +# pip3.7 install -r requirements.txt +``` +注意,windows环境下,建议从[这里](https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely)下载shapely安装包完成安装, 直接通过pip安装的shapely库可能出现[winRrror 126] 找不到指定模块的问题。 diff --git a/doc/doc_en/environment_en.md b/doc/doc_en/environment_en.md index 96a46cce..bc93cc74 100644 --- a/doc/doc_en/environment_en.md +++ b/doc/doc_en/environment_en.md @@ -1,10 +1,18 @@ # Environment Preparation +Recommended working environment: +- PaddlePaddle >= 2.0.0 (2.1.2) +- python3.7 +- CUDA10.1 / CUDA10.2 +- CUDNN 7.6 + * [1. Python Environment Setup](#1) + [1.1 Windows](#1.1) + [1.2 Mac](#1.2) + [1.3 Linux](#1.3) * [2. Install PaddlePaddle 2.0](#2) +* [3. Install PaddleOCR Dependencies](#3) + @@ -38,7 +46,7 @@ - Check conda to add environment variables and ignore the warning that add conda to path - + #### 1.1.2 Opening the terminal and creating the conda environment @@ -69,7 +77,7 @@ # View the current location of python where python ``` - + create environment The above anaconda environment and python environment are installed @@ -133,13 +141,13 @@ The above anaconda environment and python environment are installed # !!! Contents within this block are managed by 'conda init' !!! __conda_setup="$('/Users/xxx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then - eval "$__conda_setup" + eval "$__conda_setup" else - if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then - . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" - else - export PATH="/Users/xxx/opt/anaconda3/bin:$PATH" - fi + if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then + . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" + else + export PATH="/Users/xxx/opt/anaconda3/bin:$PATH" + fi fi unset __conda_setup # <<< conda initialize <<< @@ -197,11 +205,11 @@ Linux users can choose to run either Anaconda or Docker. If you are familiar wit - **Download Anaconda**. - Download at: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D - + - + - Select the appropriate version for your operating system - Type `uname -m` in the terminal to check the command set used by your system @@ -216,12 +224,12 @@ Linux users can choose to run either Anaconda or Docker. If you are familiar wit sudo yum install wget # CentOS ``` ```bash - # Then use wget to download from Tsinghua source + # Then use wget to download from Tsinghua source # If you want to download Anaconda3-2021.05-Linux-x86_64.sh, the download command is as follows wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh # If you want to download another version, you need to change the file name after the last 1 / to the version you want to download ``` - + - To install Anaconda. - Type `sh Anaconda3-2021.05-Linux-x86_64.sh` at the command line @@ -310,6 +318,25 @@ cd /home/Projects # If using CPU, use docker instead of nvidia-docker to create docker sudo docker run --name ppocr -v $PWD:/paddle --network=host -it paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82 /bin/bash + +# If using GPU, use nvidia-docker to create docker +sudo nvidia-docker run --name ppocr -v $PWD:/paddle --shm-size=64G --network=host -it paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82 /bin/bash + +``` +You can also visit [DockerHub](https://hub.docker.com/r/paddlepaddle/paddle/tags/) to get the image that fits your machine. + +``` +# ctrl+P+Q to exit docker, to re-enter docker using the following command: +sudo docker container exec -it ppocr /bin/bash +``` + +The default python3 version in the docker environment is python3.5. Python3.7 is recommended to run PaddleOCR. When executing python commands, you can use python3.7 instead of python3. As follows, enter the python3.7 command and press Enter, you can see that the python3.7 version is used. +``` +λ root@Linux /paddle python3.7 +Python 3.7.0 (default, Aug 2 2021, 05:30:22) +[GCC 8.2.0] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> ``` @@ -330,3 +357,32 @@ python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple For more software version requirements, please refer to the instructions in [Installation Document](https://www.paddlepaddle.org.cn/install/quick) for operation. + +## 3. Install PaddleOCR Dependencies + +Download PaddleOCR code. +``` +# Recommend +git clone https://github.com/PaddlePaddle/PaddleOCR + +# If you cannot pull successfully due to network problems, you can also choose to use the code hosting on the cloud: + +git clone https://gitee.com/paddlepaddle/PaddleOCR + +# Note: The cloud-hosting code may not be able to synchronize the update with this GitHub project in real time. There might be a delay of 3-5 days. Please give priority to the recommended method. +``` + +Install third-party libraries +``` +cd PaddleOCR +pip3 install -r requirements.txt +# use pip3.7 instead of pip3 in docker +# pip3.7 install -r requirements.txt + +``` + +If you getting this error OSError: [WinError 126] The specified module could not be found when you install shapely on windows. + +Please try to download Shapely whl file using [http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely](http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely). + +Reference: [Solve shapely installation on windows](https://stackoverflow.com/questions/44398265/install-shapely-oserror-winerror-126-the-specified-module-could-not-be-found) -- GitLab