This article is a mirror article of machine translation, please click here to jump to the original article.

View: 55804|Reply: 4

[.NET Core] .NET Core calls Baidu PaddleOCR to recognize images and texts

[Copy link]
Posted on 3/15/2021 6:21:43 PM | | | |
Before we get to know PaddleOCR, let's first understand PaddlePaddle. Based on Baidu's years of deep learning technology research and business applications, PaddlePaddle is China's first open source, technologically leading, and fully functional industrial-grade deep learning platform, integrating deep learning core training and inference frameworks, basic model libraries, end-to-end development kits, and rich tool components. At present, Flying Paddle has gathered more than 2.65 million developers, served 100,000 enterprises, and generated 340,000 models based on the Flying Paddle open source deep learning platform. Flying Paddle helps developers quickly realize AI ideas and quickly launch AI services. Help more and more industries complete AI empowerment and realize industrial intelligent upgrading.

Official Website:The hyperlink login is visible.

PaddleOCR aims to create a rich, leading, and practical OCR tool library to help users train better models and implement them.

First look at the renderings:


(Original picture)


(After identification,The labeled border is drawn by itself based on the returned result

Baidu Flying Paddle requires Windows environment

Windows 7/8/10 Pro/Enterprise (64bit)
The GPU version supports CUDA 9.0/10.0/10.1/10.2/11.0, and only supports a single card
Python version 2.7.15+/3.5.1+/3.6+/3.7+/3.8+ (64 bit)
pip version 20.2.2+ (64 bit)

Note: If you are using a higher version of Python, such as Python 3.9, you will get the following error:

ERROR: Could not find a version that satisfies the requirement paddlepaddle (from versions: none)
ERROR: No matching distribution found for paddlepaddle
Solution:

Download a supported version, for example: version 3.8.8, download address:The hyperlink login is visible.

You need to confirm that Python and pip are 64-bit, and the processor architecture is x86_64 (or x64, Intel 64, AMD64) architecture, and currently PaddlePaddle does not support arm64 architecture. The first line below outputs "64bit", and the second line outputs "x86_64", "x64" or "AMD64".



D:\itsvse>python --version
Python 3.8.8

D:\itsvse>pip --version
pip 20.2.3 from c:\program files\python38\lib\site-packages\pip (python 3.8)

D:\itsvse>python -c "import platform;print(platform.architecture()[0]);print(platform.machine())"
64bit
AMD64
Windows 10 installs the PaddlePaddle CPU version

Command:

Verify the installation

After the installation is complete, you can use python or python3 to enter the python interpreter, enter import paddle, and then type paddle.utils.run_check()

if it appearsPaddlePaddle is installed successfully!, indicating that you have successfully installed. As shown below:



(Do not execute) uninstall command:

Install PaddleHub

Command:


Download Clone PaddleOCR

Use the git clone command to download conditionally, and unconditionally download it directly into a compressed package and then unzip it, address:The hyperlink login is visible.

I downloaded it directly and unzipped it to the folder :D:\itsvse\PaddleOCR-release-2.0.

Download the inference model

Before installing the service module, you need to prepare the inference model and put it in the correct path.

Detection Model:The hyperlink login is visible.
Direction Classifier:The hyperlink login is visible.
Identify the model:The hyperlink login is visible.

After downloading it, I placed it under the D:\itsvse\PaddleOCR-release-2.0\deploy\model folder, as shown below:



Install the detection + identification series service module

Modify the "D:\itsvse\PaddleOCR-release-2.0\deploy\hubserving\ocr_system\params.py" configuration as follows:

Use the cmd window to execute the following command under the D:\itsvse\PaddleOCR-release-2.0 folder:

Remark:To modify the python file under \hubserving\ocr_system, you need to reinstall the deployment or execute the above command

Errors may be reported as follows:


ModuleNotFoundError: No module named 'imgaug'
ModuleNotFoundError: No module named 'pyclipper'
ModuleNotFoundError: No module named 'lmdb'
Just use pip to install, for example: pip install imgaug

The installation is as follows:

[2021-03-15 15:59:37,549] [    INFO] - Successfully uninstalled ocr_system
[2021-03-15 15:59:38,237] [    INFO] - Successfully installed ocr_system-1.0.0



Start the ocr_system service

Here the configuration parameters use the configuration file, first modify the "D:\itsvse\PaddleOCR-release-2.0\deploy\hubserving\ocr_system\config.json" configuration, as follows:

Start the service with the following command:



Test the picture with the python client

Put the image you want to test into the "D:\itsvse\PaddleOCR-release-2.0\doc\imgs1" folder, and run the following command in D:\itsvse\PaddleOCR-release-2.0:



test_hubserving.py The source code is as follows:

Test the picture using the .NET Core client

Directly upload the code, as follows:

{"msg":"","results":[[{"confidence":0.9994004964828491,"text":"Blog Statistics","text_region":[[23,18],[85,18],[85,33],[23,32]]},{"confidence":0.9951881170272827,"text":"Hello everyone, I am a little scumbag, and I started a blog on April 5, 2015","text_region":[[22,74],[471,74],[471,93],[22,93]]},{"confidence":0.9985174536705017,"text":"As of this time2021-03-1516:19:52","text_region":[[23,111],[ 217,111],[217,126],[23,126]]},{"confidence":0.9762932062149048,"text":"Cumulative about. .NET 1184 articles, 6844154 times in total, 10505 comments in total","text_region":[[24,153],[448,153],[448,165],[24,165]]},{"confidence":0.9847920536994934,"text":"Total of 2807 articles, cumulative reading 14210224 times, 19074 reviews","text_region":[[24,177],[414,177],[414,188],[24,189]]}]],"status":"000"}


Since I am using the server side of virtual machine deployment, sometimes memory errors are reported:

Fail to alloc memory of 268418688 size.
Temporary solution, restart the server.

Resources:

The hyperlink login is visible.
The hyperlink login is visible.

(End)





Previous:ASP.NET Core(4) filter unified ModelState model validation
Next:2PC &&&3PC of distributed transactions
Posted on 6/16/2021 12:38:26 PM |
Mark Yibo, come to learn
 Landlord| Posted on 11/13/2024 9:44:47 AM |
Windows PaddlePaddle installation tutorial
https://www.itsvse.com/thread-10873-1-1.html
 Landlord| Posted on 12/31/2024 1:25:03 PM |
.NET/C# uses FastDeploy to deploy OCR models to recognize text
https://www.itsvse.com/thread-10911-1-1.html
 Landlord| Posted on 4/24/2025 9:20:18 AM |
.NET/C# uses Tesseract to OCR text recognition for images
https://www.itsvse.com/thread-10994-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com