News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

DDDDOCR installation and use

posted on 2023-06-06 12:25     read(293)     comment(0)     like(0)     collect(4)


DDDDOCR image verification code recognition technology

When we browse the web every day, a picture often pops up for you to verify. Some are sliding verification, and some are verification by entering corresponding characters. Today I will introduce such a technology to you, which can be specially used to identify the verification code of the picture . function.

package download

When it comes to package download, we will think of it through the command line pip install ddddocror through adding packages in the pycharm framework.
insert image description here

But in the process of downloading this package, the following errors are always reminded:

C:\Users\Test>pip install ddddocr
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting ddddocr
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/43/f7/febabbc3580e811accf89ca5236c7de0062b07adf535edc66587ff9149cb/ddddocr-1.0.6-py3-none-any.whl (6.9 MB)
Collecting numpy
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/39/f104eb30cc3da44d1e10622418c5e6eb5ac224f0f20c97dba44cf2de2af9/numpy-1.24.1-cp311-cp311-win_amd64.whl (14.8 MB)
ERROR: Ignored the following versions that require a different python version: 1.0.8 Requires-Python <3.8; 1.1.0 Requires-Python <3.9; 1.2.0 Requires-Python <3.10; 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11; 1.3.0 Requires-Python <3.10; 1.3.1 Requires-Python <3.10; 1.4.0 Requires-Python <3.10; 1.4.1 Requires-Python <3.10; 1.4.2 Requires-Python <3.10; 1.4.3 Requires-Python <3.10; 1.4.4 Requires-Python <=3.10; 1.4.5 Requires-Python <3.11; 1.4.6 Requires-Python <3.11; 1.4.7 Requires-Python <3.11
ERROR: Could not find a version that satisfies the requirement onnxruntime (from ddddocr) (from versions: none)
ERROR: No matching distribution found for onnxruntime

I also checked a lot of methods, specifying the domestic mirror source , considering the change of the package name due to version changes, etc., but nothing worked. After troubled me for a few hours, I settled down and opened the source address of the development package again https://github.com/sml2h3/ddddocr. When checking the explanation, I found that this package currently only supports python 3.10 version, and my current version is the latest python 3.11.0. So the package cannot be imported.
insert image description here
If the problem is located, then it is easy to solve. There is still a pitfall (not counting, maybe I didn’t understand it, and I will find it later). In fact, it is reasonable to just roll back the python version to 3.10. Okay, but I didn't want to uninstall and reinstall, so I directly downloaded a tool of the anaconda python management package, wasting a lot of time on it, and I won't introduce it for the time being.

Solution

1. Uninstall the original Python version, and delete the folder where Python is stored. Here I am D:\python, and then go to the official website to find a version 3.10 to download. I downloaded 3.10.9 https://www.python.org/downloads/release/python-3109/;
insert image description here

2. Install the downloaded python package;

C:\Users\Test>python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

3. At this time, download the ddddocr package and onnxruntime package, pip install ddddocr, pip install onnxruntime, and it can be downloaded successfully at this time. If it cannot be used, install it again in pycharm.

C:\Users\Test>pip install ddddocr
C:\Users\Test>pip install onnxruntime

4. Recreate a project, set the interpreter to the path you just downloaded, create a py file, and start compiling.
insert image description here

package use

Here I use the following picture:
insert image description here
Then create a .py file and put the above picture in the same directory as this .py file.

import ddddocr
# 实例化
ocr = ddddocr.DdddOcr()
# 以二进制格式打开verf.png图片用于只读
with open('verf.png', 'rb') as f:
	# 用来读取文件
	img_bytes = f.read()
# 识别图片中的内容
res = ocr.classification(img_bytes)
# 输出内容
print('识别出的验证码为:' + res)

The execution results are as follows:

D:\pythonProject\venv\Scripts\python.exe D:\pythonProject\venv\11.py 
欢迎使用ddddocr,本项目专注带动行业内卷,个人博客:wenanzhe.com
训练数据支持来源于:http://146.56.204.113:19199/preview
爬虫框架feapder可快速一键接入,快速开启爬虫之旅:https://github.com/Boris-code/feapder
谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口:https://yescaptcha.com/i/NSwk7i
识别出的验证码为:jyfq

Process finished with exit code 0

Here the author has also printed out some information. If you don’t want to use it, you can use CTEL+click to import ddddocrjump ddddocrto the page and comment out the text you don’t want to read:
insert image description here
and then return to execute. The result is as follows:

D:\pythonProject\venv\Scripts\python.exe D:\pythonProject\venv\11.py 
识别出的验证码为:jyfq

Process finished with exit code 0

Summarize

When you encounter a problem, you still have to find the root cause from the source. Because you are too anxious, you have not carefully checked the author's description of the ddddocr package, so you have taken a lot of detours. In summary, the most important thing to install the ddddocr package is to pay attention to its version. Question, if you can install it locally, then writing and compiling will be smooth.



Category of website: technical article > Blog

Author:evilangel

link:http://www.pythonblackhole.com/blog/article/80476/939f9963c0cea97190e8/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

0 0
collect article
collected

Comment content: (supports up to 255 characters)