Paddle OCR, windows/mac installation guide

Foreword:

        Now there are many Baidu PaddleOCR installation tutorials on the Internet, but the common problem is the lack of explanation of the entire installation process framework, and the problems encountered are various, which makes it easy for Xiaobai to be confused during installation.

        This article will take Anaconda--jupyter notebook as an example to sort out the installation framework of PaddleOCR, and provide several common errors and solutions, hoping to help you successfully install PaddleOCR efficiently:

1. Install PaddlePaddle on the official website

2. Download the PaddleOCR package on github

3. Install the package that supports PaddleOCR


1. Install PaddlePaddle

Official Quick Install PaddlePaddle

According to your own computer, choose the windows pip python3 cpu version to install

1. Make sure that the installed windows is 64-bit
. 2. Make sure that the python version is one of the following 3.5.1+/3.6+/3.7+, and it is 64-bit. If the version does not match, the download of Paddle is abnormal .

python --version

The following command can output whether python is 64bit and processor architecture

python -c "import platform;print(platform.architecture([0]);print(platform.machine())"

Make sure there is pip corresponding to python, version 9.0.1+

python -m ensurepip
python -m pip --version

4. Install paddlepaddle ( choose according to the official website

#执行以下命令安装(推荐使用百度源)
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
#或
conda install paddlepaddle==2.3.1 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

 2. Download the PaddleOCR package on github

According to step 3 of the project documentation , clone the PaddleOCR code and create a new directory locally

#推荐
git clone https://github.com/PaddlePaddle/PaddleOCR
#因为网络问题无法pull成功,也可选择使用码云上的托管, 码云托管代码可能无法实时同步本github项目更新,存在3~5天延时,请优先使用推荐方式
git clone https://gitee.com/paddlepaddle/PaddleOCR

You can also download the zip file directly here and unzip it to the corresponding location

3. Install the package that supports PaddleOCR

Enter the PaddleOCR file after successfully downloading github

cd PaddleOCR

python -m pip install -r requirements.txt

Prone problems here:

        1. The location of the PaddleOCR document: just put it in the default directory

        2. The requirements.txt file cannot be found: use dir to list all the files in the directory, and then copy and paste

This step explains:

install requirement.txt is actually the last step of the installation, which is to install the necessary packages to support PaddleOCR, most of which are listed in requirements.txt.

The usual error reporting is also reported at this step, because some package installation problems need to be downloaded here manually. There are already many errors and solutions on the Internet to solve " some packages cannot be installed ". Here are a few common examples:

1. shapely package:

The official emphasizes that in the windows environment, it is recommended to download the shapely installation package from here to complete the installation. The shapely library installed directly through pip may have the problem of [winRrror 126] The specified module cannot be found.

Download the file that matches your computer and python version 

After downloading, put it in the PaddleOCR folder (same level as requirements.txt) and install it (the process of downloading other packages is the same

pip install Shapely-1.7.1-cp37-cp37m-win_amd64.whl(根据下载文件的名字改

2. Running setup.py install for python-Levenshtein ... error:

Download and install Python-Levenshtein

Note: Many blogs on the website now mention the steps to install the C++ environment. In fact, it is also to solve the problem that a certain python package cannot be installed. It is recommended to take the above steps for installation, which is relatively simple and fast.

4. Use of PaddleOCR

1. jupyter notebook/pycharm in paddle virtual environment

Jupyter notebook should switch the kernel to paddle (environment name)

Pycharm is the same, the specific process can refer to:  use Anaconda to install pytorch and paddle deep learning environment + pycharm installation --- no additional installation of CUDA and cudnn (suitable for nanny-level teaching for Xiaobai)_Paoge takes you to learn blog-CSDN blog _Use anaconda to install pytorch

2. Example of use:

pip install paddleocr
from paddleocr import PaddleOCR, draw_ocr
 
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory

img_path = r'C:\Users\Administrator.PC-201704222111\Desktop\66.png'
result = ocr.ocr(img_path, cls=True)
for line in result:
    print(line)


Summarize

The above is the content of this sharing. At that time, when installing paddle ocr, because I did not understand the structure of the installation and the relationship between each step, I encountered many difficult problems, so I wrote this installation guide.

I hope it can help you understand several important steps of installing paddle, and you can find answers to questions efficiently with a clear mind and thinking when searching for content not mentioned in the article!

Reference 1: Installation and use of PaddleOCR under windows10

Reference 2:   Python | How to install PaddleOCR correctly

(Reference 2 is installed from another angle, directly in pip install paddleocr, and then solve any problems you encounter, and I suggest you take a look)

Reference 3:  Use Anaconda to install pytorch and paddle deep learning environment + pycharm installation --- no additional installation of CUDA and cudnn (suitable for nanny-level teaching for Xiaobai)

(If you are a Pycharm user, you can refer to the explanation in the part of Pycharm and virtual environment in reference 3)

Guess you like

Origin blog.csdn.net/HarryLi0520/article/details/126035799